From a6a3869371c14a865c830cc86bb19437dd415dcc Mon Sep 17 00:00:00 2001 From: "dries.k" Date: Fri, 4 Nov 2022 11:38:45 +0100 Subject: [PATCH] change the status widget on theme change --- gotify_tray/gui/MainApplication.py | 6 +++++- gotify_tray/gui/widgets/MainWindow.py | 3 +++ gotify_tray/gui/widgets/StatusWidget.py | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gotify_tray/gui/MainApplication.py b/gotify_tray/gui/MainApplication.py index 2bf59af..0bf2d91 100644 --- a/gotify_tray/gui/MainApplication.py +++ b/gotify_tray/gui/MainApplication.py @@ -341,9 +341,13 @@ class MainApplication(QtWidgets.QApplication): self.refresh_applications() def theme_change_requested_callback(self, theme: str): - # Set the theme, update the main window and message widget icons + # Set the theme set_theme(self, theme) + + # Update the main window icons self.main_window.set_icons() + + # Update the message widget icons for r in range(self.messages_model.rowCount()): message_widget: MessageWidget = self.main_window.listView_messages.indexWidget( self.messages_model.index(r, 0) diff --git a/gotify_tray/gui/widgets/MainWindow.py b/gotify_tray/gui/widgets/MainWindow.py index 683f2a4..78c7c92 100644 --- a/gotify_tray/gui/widgets/MainWindow.py +++ b/gotify_tray/gui/widgets/MainWindow.py @@ -85,6 +85,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): size = settings.value("MainWindow/application/icon/size", type=int) self.listView_applications.setIconSize(QtCore.QSize(size, size)) + + # Refresh the status widget + self.status_widget.refresh() def set_active(self): self.status_widget.set_active() diff --git a/gotify_tray/gui/widgets/StatusWidget.py b/gotify_tray/gui/widgets/StatusWidget.py index 41c9756..b16938a 100644 --- a/gotify_tray/gui/widgets/StatusWidget.py +++ b/gotify_tray/gui/widgets/StatusWidget.py @@ -13,8 +13,10 @@ class StatusWidget(QtWidgets.QLabel): self.setFixedSize(QtCore.QSize(20, 20)) self.setScaledContents(True) self.set_connecting() + self.image = None def set_status(self, image: str): + self.image = image self.setPixmap(QtGui.QPixmap(get_theme_file(image))) def set_active(self): @@ -32,3 +34,8 @@ class StatusWidget(QtWidgets.QLabel): def set_error(self): self.setToolTip("Listener error") self.set_status("status_error.svg") + + def refresh(self): + # refresh on theme change + if self.image: + self.set_status(self.image)