mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 06:14:16 +02:00
BAUH_SYSTEM_NOTIFICATIONS
This commit is contained in:
@@ -33,9 +33,9 @@ class UpdateCheck(QThread):
|
||||
|
||||
class TrayIcon(QSystemTrayIcon):
|
||||
|
||||
def __init__(self, locale_keys: dict, manager: SoftwareManager, manage_window: ManageWindow, check_interval: int = 60, update_notification: bool = True):
|
||||
def __init__(self, i18n: dict, manager: SoftwareManager, manage_window: ManageWindow, check_interval: int = 60, update_notification: bool = True):
|
||||
super(TrayIcon, self).__init__()
|
||||
self.locale_keys = locale_keys
|
||||
self.i18n = i18n
|
||||
self.manager = manager
|
||||
|
||||
self.icon_default = QIcon(resource.get_path('img/logo.png'))
|
||||
@@ -44,13 +44,13 @@ class TrayIcon(QSystemTrayIcon):
|
||||
|
||||
self.menu = QMenu()
|
||||
|
||||
self.action_manage = self.menu.addAction(self.locale_keys['tray.action.manage'])
|
||||
self.action_manage = self.menu.addAction(self.i18n['tray.action.manage'])
|
||||
self.action_manage.triggered.connect(self.show_manage_window)
|
||||
|
||||
self.action_about = self.menu.addAction(self.locale_keys['tray.action.about'])
|
||||
self.action_about = self.menu.addAction(self.i18n['tray.action.about'])
|
||||
self.action_about.triggered.connect(self.show_about)
|
||||
|
||||
self.action_exit = self.menu.addAction(self.locale_keys['tray.action.exit'])
|
||||
self.action_exit = self.menu.addAction(self.i18n['tray.action.exit'])
|
||||
self.action_exit.triggered.connect(lambda: QCoreApplication.exit())
|
||||
|
||||
self.setContextMenu(self.menu)
|
||||
@@ -71,7 +71,7 @@ class TrayIcon(QSystemTrayIcon):
|
||||
self.manage_window = manage_window
|
||||
|
||||
def set_default_tooltip(self):
|
||||
self.setToolTip('{} ({})'.format(self.locale_keys['manage_window.title'], __app_name__).lower())
|
||||
self.setToolTip('{} ({})'.format(self.i18n['manage_window.title'], __app_name__).lower())
|
||||
|
||||
def handle_click(self, reason):
|
||||
if reason == self.Trigger:
|
||||
@@ -95,7 +95,8 @@ class TrayIcon(QSystemTrayIcon):
|
||||
|
||||
if update_keys.difference(self.last_updates):
|
||||
self.last_updates = update_keys
|
||||
msg = '{}: {}'.format(self.locale_keys['notification.new_updates'], len(updates))
|
||||
n_updates = len(updates)
|
||||
msg = self.i18n['notification.update{}'.format('' if n_updates == 1 else 's')].format(n_updates)
|
||||
self.setToolTip(msg)
|
||||
|
||||
if self.update_notification and notify_user:
|
||||
@@ -122,7 +123,7 @@ class TrayIcon(QSystemTrayIcon):
|
||||
def show_about(self):
|
||||
|
||||
if self.dialog_about is None:
|
||||
self.dialog_about = AboutDialog(self.locale_keys)
|
||||
self.dialog_about = AboutDialog(self.i18n)
|
||||
|
||||
if self.dialog_about.isHidden():
|
||||
self.dialog_about.show()
|
||||
|
||||
@@ -44,8 +44,9 @@ class ManageWindow(QWidget):
|
||||
signal_user_res = pyqtSignal(bool)
|
||||
signal_table_update = pyqtSignal()
|
||||
|
||||
def __init__(self, i18n: dict, icon_cache: MemoryCache, manager: SoftwareManager, disk_cache: bool, download_icons: bool,
|
||||
screen_size, suggestions: bool, display_limit: int, config: Configuration, context: ApplicationContext, tray_icon=None):
|
||||
def __init__(self, i18n: dict, icon_cache: MemoryCache, manager: SoftwareManager, disk_cache: bool,
|
||||
download_icons: bool, screen_size, suggestions: bool, display_limit: int, config: Configuration,
|
||||
context: ApplicationContext, notifications: bool, tray_icon=None):
|
||||
super(ManageWindow, self).__init__()
|
||||
self.i18n = i18n
|
||||
self.manager = manager
|
||||
@@ -61,6 +62,7 @@ class ManageWindow(QWidget):
|
||||
self.screen_size = screen_size
|
||||
self.config = config
|
||||
self.context = context
|
||||
self.notifications = notifications
|
||||
|
||||
self.icon_app = QIcon(resource.get_path('img/logo.svg'))
|
||||
self.resize(ManageWindow.__BASE_HEIGHT__, ManageWindow.__BASE_HEIGHT__)
|
||||
@@ -457,7 +459,7 @@ class ManageWindow(QWidget):
|
||||
self.checkbox_console.setChecked(True)
|
||||
|
||||
def _can_notify_user(self):
|
||||
return self.isHidden() or self.isMinimized()
|
||||
return self.notifications and (self.isHidden() or self.isMinimized())
|
||||
|
||||
def _finish_downgrade(self, res: dict):
|
||||
self.finish_action()
|
||||
|
||||
@@ -49,7 +49,8 @@ tray.action.about=About
|
||||
tray.action.refreshing=Refreshing
|
||||
action.info.tooltip=Click here to see information about this application
|
||||
action.settings.tooltip=Click here to open extra actions
|
||||
notification.new_updates=Updates
|
||||
notification.update={} available update
|
||||
notification.updates={} available updates
|
||||
notification.update_selected.success=app(s) updated successfully
|
||||
notification.update_selected.failed=Update failed
|
||||
notification.install.failed=installation failed
|
||||
|
||||
@@ -51,7 +51,8 @@ tray.action.about=Sobre
|
||||
tray.action.refreshing=Recargando
|
||||
action.info.tooltip=Haga clic aquí para ver informaciones sobre este aplicativo
|
||||
action.settings.tooltip=Haga clic aquí para abrir acciones adicionales
|
||||
notification.new_updates=Actualizaciones
|
||||
notification.update={} actualización disponible
|
||||
notification.updates={} actualizaciones disponibles
|
||||
notification.update_selected.success=aplicativo(s) actualizado(s) con éxito
|
||||
notification.update_selected.failed=La actualización falló
|
||||
notification.install.failed=la instalación ha fallado
|
||||
|
||||
@@ -49,7 +49,8 @@ tray.action.manage=Gerenciar aplicativos
|
||||
tray.action.exit=Fechar
|
||||
tray.action.about=Sobre
|
||||
tray.action.refreshing=Recarregando
|
||||
notification.new_updates=Atualizações
|
||||
notification.update={} atualização disponível
|
||||
notification.updates={} atualizações disponíveis
|
||||
notification.update_selected.success=aplicativo(s) atualizado(s) com sucesso
|
||||
notification.update_selected.failed=Erro ao atualizar
|
||||
notification.install.failed=instalação falhou
|
||||
|
||||
Reference in New Issue
Block a user