mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 17:54:14 +02:00
Refactoring
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user