mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 23:14:16 +02:00
fix: notifying tray icon after downgrade
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
from threading import Lock
|
from threading import Lock, Thread
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication, Qt, QSize
|
from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication, Qt, QSize
|
||||||
@@ -80,10 +80,13 @@ class TrayIcon(QSystemTrayIcon):
|
|||||||
if reason == self.Trigger:
|
if reason == self.Trigger:
|
||||||
self.show_manage_window()
|
self.show_manage_window()
|
||||||
|
|
||||||
def verify_updates(self):
|
def verify_updates(self, notify_user: bool = True):
|
||||||
self.notify_updates(self.manager.list_updates())
|
Thread(target=self._verify_updates, args=(notify_user,)).start()
|
||||||
|
|
||||||
def notify_updates(self, updates: List[ApplicationUpdate]):
|
def _verify_updates(self, notify_user: bool):
|
||||||
|
self.notify_updates(self.manager.list_updates(), notify_user=notify_user)
|
||||||
|
|
||||||
|
def notify_updates(self, updates: List[ApplicationUpdate], notify_user: bool = True):
|
||||||
|
|
||||||
self.lock_notify.acquire()
|
self.lock_notify.acquire()
|
||||||
|
|
||||||
@@ -98,7 +101,7 @@ class TrayIcon(QSystemTrayIcon):
|
|||||||
msg = '{}: {}'.format(self.locale_keys['notification.new_updates'], len(updates))
|
msg = '{}: {}'.format(self.locale_keys['notification.new_updates'], len(updates))
|
||||||
self.setToolTip(msg)
|
self.setToolTip(msg)
|
||||||
|
|
||||||
if self.update_notification:
|
if self.update_notification and notify_user:
|
||||||
system.notify_user(msg)
|
system.notify_user(msg)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -329,6 +329,9 @@ class ManageWindow(QWidget):
|
|||||||
system.notify_user('{} ({}) {}'.format(app.model.base_data.name, app.model.get_type(), self.locale_keys['downgraded']))
|
system.notify_user('{} ({}) {}'.format(app.model.base_data.name, app.model.get_type(), self.locale_keys['downgraded']))
|
||||||
|
|
||||||
self.refresh_apps()
|
self.refresh_apps()
|
||||||
|
|
||||||
|
if self.tray_icon:
|
||||||
|
self.tray_icon.verify_updates(notify_user=False)
|
||||||
else:
|
else:
|
||||||
if self._can_notify_user():
|
if self._can_notify_user():
|
||||||
system.notify_user(self.locale_keys['notification.downgrade.failed'])
|
system.notify_user(self.locale_keys['notification.downgrade.failed'])
|
||||||
|
|||||||
Reference in New Issue
Block a user