fix: notifying tray icon after downgrade

This commit is contained in:
Vinicius Moreira
2019-07-24 16:50:21 -03:00
parent 96e1cabb40
commit ce72e6fac7
2 changed files with 11 additions and 5 deletions

View File

@@ -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:

View File

@@ -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'])