Add basic dark & light theme (#18)

This commit is contained in:
seird
2022-11-02 19:31:56 +01:00
committed by GitHub
parent 7fd412e80b
commit a8a854ce6b
41 changed files with 833 additions and 52 deletions

View File

@@ -18,6 +18,7 @@ from gotify_tray.tasks import (
GetMessagesTask,
ServerConnectionWatchdogTask,
)
from gotify_tray.gui.themes import set_theme
from gotify_tray.utils import get_icon, verify_server
from PyQt6 import QtCore, QtGui, QtWidgets
@@ -60,6 +61,8 @@ def init_logger(logger: logging.Logger):
class MainApplication(QtWidgets.QApplication):
def init_ui(self):
set_theme(self, settings.value("theme", type=str))
self.gotify_client = gotify.GotifyClient(
settings.value("Server/url", type=str),
settings.value("Server/client_token", type=str),
@@ -83,7 +86,7 @@ class MainApplication(QtWidgets.QApplication):
new_message_callback=self.new_message_callback,
opened_callback=self.listener_opened_callback,
closed_callback=self.listener_closed_callback,
error_callback=self.listener_error_callback
error_callback=self.listener_error_callback,
)
self.watchdog = ServerConnectionWatchdogTask(self.gotify_client)
@@ -164,7 +167,7 @@ class MainApplication(QtWidgets.QApplication):
QtCore.QTimer.singleShot(
self.gotify_client.get_wait_time() * 1000, self.gotify_client.reconnect
)
def listener_error_callback(self, exception: Exception):
self.main_window.set_connecting()
self.tray.set_icon_error()
@@ -333,6 +336,7 @@ class MainApplication(QtWidgets.QApplication):
def settings_callback(self):
settings_dialog = SettingsDialog()
settings_dialog.quit_requested.connect(self.quit)
settings_dialog.theme_change_requested.connect(lambda theme: set_theme(self, theme))
accepted = settings_dialog.exec()
if accepted and settings_dialog.settings_changed:
@@ -349,7 +353,7 @@ class MainApplication(QtWidgets.QApplication):
new_message_callback=self.new_message_callback,
opened_callback=self.listener_opened_callback,
closed_callback=self.listener_closed_callback,
error_callback=self.listener_error_callback
error_callback=self.listener_error_callback,
)
def tray_notification_clicked_callback(self):
@@ -417,7 +421,6 @@ def start_gui():
app.setApplicationName(title)
app.setQuitOnLastWindowClosed(False)
app.setWindowIcon(QtGui.QIcon(get_icon("gotify-small")))
app.setStyle("fusion")
init_logger(logger)