From ce72e6fac7add1c4ed9ae44abb5a7cba8a55db35 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 24 Jul 2019 16:50:21 -0300 Subject: [PATCH] fix: notifying tray icon after downgrade --- fpakman/view/qt/systray.py | 13 ++++++++----- fpakman/view/qt/window.py | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fpakman/view/qt/systray.py b/fpakman/view/qt/systray.py index 3b59bbb2..598f768e 100755 --- a/fpakman/view/qt/systray.py +++ b/fpakman/view/qt/systray.py @@ -1,5 +1,5 @@ import time -from threading import Lock +from threading import Lock, Thread from typing import List from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication, Qt, QSize @@ -80,10 +80,13 @@ class TrayIcon(QSystemTrayIcon): if reason == self.Trigger: self.show_manage_window() - def verify_updates(self): - self.notify_updates(self.manager.list_updates()) + def verify_updates(self, notify_user: bool = True): + 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() @@ -98,7 +101,7 @@ class TrayIcon(QSystemTrayIcon): msg = '{}: {}'.format(self.locale_keys['notification.new_updates'], len(updates)) self.setToolTip(msg) - if self.update_notification: + if self.update_notification and notify_user: system.notify_user(msg) else: diff --git a/fpakman/view/qt/window.py b/fpakman/view/qt/window.py index 054d5a2c..1186624b 100755 --- a/fpakman/view/qt/window.py +++ b/fpakman/view/qt/window.py @@ -329,6 +329,9 @@ class ManageWindow(QWidget): system.notify_user('{} ({}) {}'.format(app.model.base_data.name, app.model.get_type(), self.locale_keys['downgraded'])) self.refresh_apps() + + if self.tray_icon: + self.tray_icon.verify_updates(notify_user=False) else: if self._can_notify_user(): system.notify_user(self.locale_keys['notification.downgrade.failed'])