mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[snap] feature -> new custom action 'change channel'
This commit is contained in:
@@ -11,7 +11,7 @@ from PyQt5.QtWidgets import QTableWidget, QTableView, QMenu, QAction, QTableWidg
|
||||
QHeaderView, QLabel, QHBoxLayout, QToolBar, QSizePolicy
|
||||
|
||||
from bauh.api.abstract.cache import MemoryCache
|
||||
from bauh.api.abstract.model import PackageStatus
|
||||
from bauh.api.abstract.model import PackageStatus, CustomSoftwareAction
|
||||
from bauh.commons.html import strip_html, bold
|
||||
from bauh.view.qt import dialog
|
||||
from bauh.view.qt.colors import GREEN, BROWN
|
||||
@@ -166,31 +166,34 @@ class AppsTable(QTableWidget):
|
||||
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.i18n_label_key])
|
||||
|
||||
if action.icon_path:
|
||||
item.setIcon(QIcon(action.icon_path))
|
||||
|
||||
def custom_action():
|
||||
if action.i18n_confirm_key:
|
||||
body = self.i18n[action.i18n_confirm_key].format(bold(pkg.model.name))
|
||||
else:
|
||||
body = '{} ?'.format(self.i18n[action.i18n_label_key])
|
||||
|
||||
if dialog.ask_confirmation(
|
||||
title=self.i18n[action.i18n_label_key],
|
||||
body=self._parag(body),
|
||||
i18n=self.i18n):
|
||||
self.window.begin_execute_custom_action(pkg, action)
|
||||
|
||||
item.triggered.connect(custom_action)
|
||||
menu_row.addAction(item)
|
||||
actions = [self._map_custom_action(pkg, a) for a in pkg.model.get_custom_supported_actions()]
|
||||
menu_row.addActions(actions)
|
||||
|
||||
menu_row.adjustSize()
|
||||
menu_row.popup(QCursor.pos())
|
||||
menu_row.exec_()
|
||||
|
||||
def _map_custom_action(self, pkg: PackageView, action: CustomSoftwareAction) -> QAction:
|
||||
item = QAction(self.i18n[action.i18n_label_key])
|
||||
|
||||
if action.icon_path:
|
||||
item.setIcon(QIcon(action.icon_path))
|
||||
|
||||
def custom_action():
|
||||
if action.i18n_confirm_key:
|
||||
body = self.i18n[action.i18n_confirm_key].format(bold(pkg.model.name))
|
||||
else:
|
||||
body = '{} ?'.format(self.i18n[action.i18n_label_key])
|
||||
|
||||
if dialog.ask_confirmation(
|
||||
title=self.i18n[action.i18n_label_key],
|
||||
body=self._parag(body),
|
||||
i18n=self.i18n):
|
||||
self.window.begin_execute_custom_action(pkg, action)
|
||||
|
||||
item.triggered.connect(custom_action)
|
||||
return item
|
||||
|
||||
def refresh(self, pkg: PackageView):
|
||||
self._update_row(pkg, update_check_enabled=False, change_update_col=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user