From 922cd87fe01fefeb3905d3794bee8540691206ef Mon Sep 17 00:00:00 2001 From: Faerbit Date: Wed, 17 Nov 2021 21:17:53 +0100 Subject: [PATCH] Add fallback light icon --- src/fime/config.py | 5 +++ src/fime/icons/__init__.py | 53 ++++++++++++++++++++++-- src/fime/icons/appointment-new-light.svg | 18 ++++++++ src/fime/icons/resources.qrc | 1 + src/fime/import_task.py | 6 ++- src/fime/main.py | 10 ++++- src/fime/task_completer.py | 4 +- src/fime/util.py | 3 +- 8 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 src/fime/icons/appointment-new-light.svg diff --git a/src/fime/config.py b/src/fime/config.py index 534c725..aedebef 100644 --- a/src/fime/config.py +++ b/src/fime/config.py @@ -22,6 +22,7 @@ class Config: config_dir_path = Path(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.ConfigLocation)) config_path = config_dir_path / "fime" / "fime.conf" if config_path.exists(): + print(f'Reading config file "{config_path}"') with open(config_path) as f: config_text = f.read() config_text = "[DEFAULT]\n" + config_text @@ -39,3 +40,7 @@ class Config: def jira_token(self): return dequotify(self._configparser["DEFAULT"]["jira_token"]) + @property + def tray_theme(self): + val = dequotify(self._configparser.get("DEFAULT", "tray_theme", fallback="dark")) + return val if val in ["light", "dark"] else "dark" diff --git a/src/fime/icons/__init__.py b/src/fime/icons/__init__.py index 2116539..84ad714 100644 --- a/src/fime/icons/__init__.py +++ b/src/fime/icons/__init__.py @@ -176,6 +176,46 @@ ty:1;stroke:none\ s=\x22ColorScheme-T\ ext\x22/>\x0a \x0a\x0a\ +\x00\x00\x02`\ +<\ +svg xmlns=\x22http:\ +//www.w3.org/200\ +0/svg\x22 viewBox=\x22\ +0 0 32 32\x22>\x0a \x0a \x0a \ + .ColorScheme-T\ +ext {\x0a co\ +lor:#dcd9d6;\x0a \ + }\x0a \x0a \x0a \ +\x0a\x0a\ \x00\x00\x01L\ <\ svg viewBox=\x220 0\ @@ -282,6 +322,11 @@ qt_resource_name = b"\ \x09\xc6\x14\xa7\ \x00l\ \x00i\x00s\x00t\x00-\x00a\x00d\x00d\x00.\x00s\x00v\x00g\ +\x00\x19\ +\x0b9\x06g\ +\x00a\ +\x00p\x00p\x00o\x00i\x00n\x00t\x00m\x00e\x00n\x00t\x00-\x00n\x00e\x00w\x00-\x00l\ +\x00i\x00g\x00h\x00t\x00.\x00s\x00v\x00g\ \x00\x0b\ \x0c+\x12G\ \x00g\ @@ -299,9 +344,9 @@ qt_resource_name = b"\ qt_resource_struct = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x08\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x09\x00\x00\x00\x02\ \x00\x00\x00\x00\x00\x00\x00\x00\ -\x00\x00\x01\x04\x00\x00\x00\x00\x00\x01\x00\x00\x0c\x85\ +\x00\x00\x01<\x00\x00\x00\x00\x00\x01\x00\x00\x0e\xe9\ \x00\x00\x01}.b\xfd-\ \x00\x00\x00\x10\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ \x00\x00\x01}.a\xe4+\ @@ -309,11 +354,13 @@ qt_resource_struct = b"\ \x00\x00\x01}.\x1a\xb9\xf9\ \x00\x00\x00\x88\x00\x00\x00\x00\x00\x01\x00\x00\x06\x95\ \x00\x00\x01}.b $\ -\x00\x00\x00\xe4\x00\x00\x00\x00\x00\x01\x00\x00\x0b\x1e\ +\x00\x00\x01\x1c\x00\x00\x00\x00\x00\x01\x00\x00\x0d\x82\ \x00\x00\x01}.a\xce_\ \x00\x00\x00\xaa\x00\x00\x00\x00\x00\x01\x00\x00\x07\xe4\ \x00\x00\x01}.b\xe1.\ \x00\x00\x00\xc8\x00\x00\x00\x00\x00\x01\x00\x00\x09\xce\ +\x00\x00\x01}/\x83\xea~\ +\x00\x00\x01\x00\x00\x00\x00\x00\x00\x01\x00\x00\x0c2\ \x00\x00\x01}.b\x05\xfc\ \x00\x00\x00d\x00\x00\x00\x00\x00\x01\x00\x00\x05E\ \x00\x00\x01}.b1)\ diff --git a/src/fime/icons/appointment-new-light.svg b/src/fime/icons/appointment-new-light.svg new file mode 100644 index 0000000..4ef9eb3 --- /dev/null +++ b/src/fime/icons/appointment-new-light.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/src/fime/icons/resources.qrc b/src/fime/icons/resources.qrc index a202299..412805d 100644 --- a/src/fime/icons/resources.qrc +++ b/src/fime/icons/resources.qrc @@ -2,6 +2,7 @@ appointment-new.svg + appointment-new-light.svg arrow-left.svg arrow-right.svg dialog-cancel.svg diff --git a/src/fime/import_task.py b/src/fime/import_task.py index 61c9cd7..1276876 100644 --- a/src/fime/import_task.py +++ b/src/fime/import_task.py @@ -1,3 +1,5 @@ +from fime.config import Config + try: from PySide6 import QtGui, QtWidgets except ImportError: @@ -8,12 +10,12 @@ from fime.util import get_icon class ImportTask(QtWidgets.QDialog): - def __init__(self, parent, *args, **kwargs): + def __init__(self, config: Config, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.setWindowTitle("New Tasks") self.line_edit = QtWidgets.QLineEdit() - completer = TaskCompleter() + completer = TaskCompleter(config) self.line_edit.setCompleter(completer) self.line_edit.textChanged.connect(completer.update_picker) diff --git a/src/fime/main.py b/src/fime/main.py index 899ac34..aeff3b2 100755 --- a/src/fime/main.py +++ b/src/fime/main.py @@ -4,6 +4,8 @@ import signal import sys from functools import partial +from fime.config import Config + try: from PySide6 import QtCore, QtWidgets PYSIDE_6 = True @@ -31,11 +33,15 @@ class App: self.log = Log(data) self._active_task = self.log.last_log() or "Nothing" - icon = get_icon("appointment-new") + self.config = Config() + if self.config.tray_theme == "light": + icon = get_icon("appointment-new-light") + else: + icon = get_icon("appointment-new") self.menu = QtWidgets.QMenu(None) - self.import_task = ImportTask(None) + self.import_task = ImportTask(self.config, None) self.import_task.accepted.connect(self.new_task_imported) self.taskEdit = TaskEdit(None) diff --git a/src/fime/task_completer.py b/src/fime/task_completer.py index a1831d9..0a233a9 100644 --- a/src/fime/task_completer.py +++ b/src/fime/task_completer.py @@ -15,12 +15,12 @@ from fime.config import Config class TaskCompleter(QtWidgets.QCompleter): - def __init__(self, parent=None, *args, **kwargs): + def __init__(self, config: Config, parent=None, *args, **kwargs): super().__init__([], parent, *args, **kwargs) self.setFilterMode(QtCore.Qt.MatchFlag.MatchContains) self.setCaseSensitivity(QtCore.Qt.CaseInsensitive) self.session = FuturesSession() - self.config = Config() + self.config = config self.picker_url = os.path.join(self.config.jira_url, "rest/api/2/issue/picker") self.search_url = os.path.join(self.config.jira_url, "rest/api/2/search") self.text = "" diff --git a/src/fime/util.py b/src/fime/util.py index a26a95c..02bc07d 100644 --- a/src/fime/util.py +++ b/src/fime/util.py @@ -13,5 +13,6 @@ def get_screen_height(qobject): def get_icon(icon_name): + theme_name = icon_name.replace("-light", "") # respect system theme fallback = QtGui.QIcon(f":/icons/{icon_name}").pixmap(256, 256) - return QtGui.QIcon.fromTheme(icon_name, fallback) + return QtGui.QIcon.fromTheme(theme_name, fallback)