Refactoring

This commit is contained in:
Vinicius Moreira
2019-06-13 12:14:58 -03:00
parent 6d58041f0a
commit bf1175626a
8 changed files with 258 additions and 93 deletions

View File

@@ -1,4 +1,3 @@
import sys
import time
from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication
@@ -38,24 +37,25 @@ class UpdateCheck(QThread):
class TrayIcon(QSystemTrayIcon):
def __init__(self, controller: FlatpakController, check_interval: int = 60, parent=None):
self.icon_default = QIcon(resource.get_path('img/flathub_logo.svg'))
self.controller = controller
self.icon_default = QIcon(resource.get_path('img/flathub_45.svg'))
self.icon_update = QIcon(resource.get_path('img/update_logo.svg'))
QSystemTrayIcon.__init__(self, self.icon_default, parent)
self.menu = QMenu(parent)
self.menu = QMenu(parent)
self.action_manage = self.menu.addAction("Manage applications")
self.action_manage.triggered.connect(self.show_manage_window)
self.action_exit = self.menu.addAction("Exit")
self.action_exit.triggered.connect(lambda: QCoreApplication.exit())
self.setContextMenu(self.menu)
self.controller = controller
self.check_thread = UpdateCheck(check_interval=check_interval, controller=self.controller)
self.check_thread.signal.connect(self.notify_update)
self.check_thread.start()
self.manage_window = ManageWindow(controller=controller, tray_icon=self)
def notify_update(self, updates: int):
self.manage_window = ManageWindow(controller=controller, tray_icon=self)
self.check_thread = UpdateCheck(check_interval=check_interval, controller=self.controller)
self.check_thread.signal.connect(self.notify_updates)
self.check_thread.start()
def notify_updates(self, updates: int):
if updates > 0:
if self.icon() != self.icon_update:
self.setIcon(self.icon_update)