mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 16:44:15 +02:00
[feature] ignore updates: Arch/AUR packages
This commit is contained in:
@@ -121,6 +121,7 @@ class AppsTable(QTableWidget):
|
||||
menu_row.setCursor(QCursor(Qt.PointingHandCursor))
|
||||
|
||||
if pkg.model.installed:
|
||||
|
||||
if pkg.model.has_history():
|
||||
action_history = QAction(self.i18n["manage_window.apps_table.row.actions.history"])
|
||||
action_history.setIcon(QIcon(resource.get_path('img/history.svg')))
|
||||
@@ -145,6 +146,21 @@ class AppsTable(QTableWidget):
|
||||
action_downgrade.setIcon(QIcon(resource.get_path('img/downgrade.svg')))
|
||||
menu_row.addAction(action_downgrade)
|
||||
|
||||
if pkg.model.supports_ignored_updates():
|
||||
if pkg.model.is_update_ignored():
|
||||
action_ignore_updates = QAction(
|
||||
self.i18n["manage_window.apps_table.row.actions.ignore_updates_reverse"])
|
||||
action_ignore_updates.setIcon(QIcon(resource.get_path('img/revert_update_ignored.svg')))
|
||||
else:
|
||||
action_ignore_updates = QAction(self.i18n["manage_window.apps_table.row.actions.ignore_updates"])
|
||||
action_ignore_updates.setIcon(QIcon(resource.get_path('img/ignore_update.svg')))
|
||||
|
||||
def ignore_updates():
|
||||
self.window.ignore_updates(pkg)
|
||||
|
||||
action_ignore_updates.triggered.connect(ignore_updates)
|
||||
menu_row.addAction(action_ignore_updates)
|
||||
|
||||
if bool(pkg.model.get_custom_supported_actions()):
|
||||
for action in pkg.model.get_custom_supported_actions():
|
||||
item = QAction(self.i18n[action.i18_label_key])
|
||||
@@ -263,7 +279,7 @@ class AppsTable(QTableWidget):
|
||||
if change_update_col:
|
||||
col_update = None
|
||||
|
||||
if update_check_enabled and pkg.model.update:
|
||||
if update_check_enabled and not pkg.model.is_update_ignored() and pkg.model.update:
|
||||
col_update = QToolBar()
|
||||
col_update.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
||||
col_update.addWidget(UpdateToggleButton(pkg=pkg,
|
||||
@@ -351,11 +367,15 @@ class AppsTable(QTableWidget):
|
||||
else:
|
||||
tooltip = self.i18n['version.unknown']
|
||||
|
||||
if pkg.model.update:
|
||||
if pkg.model.update and not pkg.model.is_update_ignored():
|
||||
label_version.setStyleSheet("color: {}; font-weight: bold".format(GREEN))
|
||||
tooltip = self.i18n['version.installed_outdated']
|
||||
|
||||
if pkg.model.installed and pkg.model.update and pkg.model.version and pkg.model.latest_version and pkg.model.version != pkg.model.latest_version:
|
||||
if pkg.model.is_update_ignored():
|
||||
label_version.setStyleSheet("color: {}; font-weight: bold".format(BROWN))
|
||||
tooltip = self.i18n['version.updates_ignored']
|
||||
|
||||
if pkg.model.installed and pkg.model.update and not pkg.model.is_update_ignored() and pkg.model.version and pkg.model.latest_version and pkg.model.version != pkg.model.latest_version:
|
||||
tooltip = '{}. {}: {}'.format(tooltip, self.i18n['version.latest'], pkg.model.latest_version)
|
||||
label_version.setText(label_version.text() + ' > {}'.format(pkg.model.latest_version))
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ def update_info(pkgv: PackageView, pkgs_info: dict):
|
||||
else:
|
||||
pkgs_info['napps_count'] += 1
|
||||
|
||||
if pkgv.model.update:
|
||||
if pkgv.model.update and not pkgv.model.is_update_ignored():
|
||||
if pkgv.model.is_application():
|
||||
pkgs_info['app_updates'] += 1
|
||||
else:
|
||||
|
||||
@@ -907,3 +907,26 @@ class GetScreenshots(AsyncAction):
|
||||
self.notify_finished({'pkg': self.pkg, 'screenshots': self.manager.get_screenshots(self.pkg.model)})
|
||||
|
||||
self.pkg = None
|
||||
|
||||
|
||||
class IgnorePackageUpdates(AsyncAction):
|
||||
|
||||
def __init__(self, manager: SoftwareManager, pkg: PackageView = None):
|
||||
super(IgnorePackageUpdates, self).__init__()
|
||||
self.pkg = pkg
|
||||
self.manager = manager
|
||||
|
||||
def run(self):
|
||||
if self.pkg:
|
||||
try:
|
||||
if self.pkg.model.is_update_ignored():
|
||||
self.manager.revert_ignored_update(self.pkg.model)
|
||||
res = {'action': 'ignore_updates_reverse', 'success': not self.pkg.model.is_update_ignored(), 'pkg': self.pkg}
|
||||
else:
|
||||
self.manager.ignore_update(self.pkg.model)
|
||||
res = {'action': 'ignore_updates', 'success': self.pkg.model.is_update_ignored(), 'pkg': self.pkg}
|
||||
|
||||
self.notify_finished(res)
|
||||
|
||||
finally:
|
||||
self.pkg = None
|
||||
@@ -34,7 +34,8 @@ from bauh.view.qt.settings import SettingsWindow
|
||||
from bauh.view.qt.thread import UpgradeSelected, RefreshApps, UninstallApp, DowngradeApp, GetAppInfo, \
|
||||
GetAppHistory, SearchPackages, InstallPackage, AnimateProgress, NotifyPackagesReady, FindSuggestions, \
|
||||
ListWarnings, \
|
||||
AsyncAction, LaunchApp, ApplyFilters, CustomSoftwareAction, GetScreenshots, CustomAction, NotifyInstalledLoaded
|
||||
AsyncAction, LaunchApp, ApplyFilters, CustomSoftwareAction, GetScreenshots, CustomAction, NotifyInstalledLoaded, \
|
||||
IgnorePackageUpdates
|
||||
from bauh.view.qt.view_model import PackageView, PackageViewStatus
|
||||
from bauh.view.util import util, resource
|
||||
from bauh.view.util.translation import I18n
|
||||
@@ -322,6 +323,9 @@ class ManageWindow(QWidget):
|
||||
self.thread_notify_pkgs_ready.signal_changed.connect(self._update_package_data)
|
||||
self.thread_notify_pkgs_ready.signal_finished.connect(self._update_state_when_pkgs_ready)
|
||||
|
||||
self.thread_ignore_updates = IgnorePackageUpdates(manager=self.manager)
|
||||
self._bind_async_action(self.thread_ignore_updates, finished_call=self.finish_ignore_updates)
|
||||
|
||||
self.toolbar_bottom = QToolBar()
|
||||
self.toolbar_bottom.setIconSize(QSize(16, 16))
|
||||
self.toolbar_bottom.setStyleSheet('QToolBar { spacing: 3px }')
|
||||
@@ -1256,3 +1260,22 @@ class ManageWindow(QWidget):
|
||||
menu_row.adjustSize()
|
||||
menu_row.popup(QCursor.pos())
|
||||
menu_row.exec_()
|
||||
|
||||
def ignore_updates(self, pkg: PackageView):
|
||||
status_key = 'ignore_updates' if not pkg.model.is_update_ignored() else 'ignore_updates_reverse'
|
||||
self._begin_action(self.i18n['manage_window.status.{}'.format(status_key)].format(pkg.model.name))
|
||||
self.thread_ignore_updates.pkg = pkg
|
||||
self.thread_ignore_updates.start()
|
||||
|
||||
def finish_ignore_updates(self, res: dict):
|
||||
self.finish_action()
|
||||
|
||||
if res['success']:
|
||||
self.table_apps.update_package(res['pkg'])
|
||||
dialog.show_message(title=self.i18n['success'].capitalize(),
|
||||
body=self.i18n['action.{}.success'.format(res['action'])].format(bold(res['pkg'].model.name)),
|
||||
type_=MessageType.INFO)
|
||||
else:
|
||||
dialog.show_message(title=self.i18n['fail'].capitalize(),
|
||||
body=self.i18n['action.{}.fail'.format(res['action'])].format(bold(res['pkg'].model.name)),
|
||||
type_=MessageType.ERROR)
|
||||
|
||||
Reference in New Issue
Block a user