From 75af17d9b23af38595d2a561b95cb90b8fae73f9 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Thu, 18 Nov 2021 22:15:11 +0100 Subject: [PATCH] Undo shortcut creation, because it doesn't work --- src/fime/config.py | 4 ++-- src/fime/data.py | 12 ++++-------- src/fime/main.py | 5 +++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/fime/config.py b/src/fime/config.py index aedebef..0fc9f38 100644 --- a/src/fime/config.py +++ b/src/fime/config.py @@ -19,8 +19,8 @@ def dequotify(string): class Config: def __init__(self): self._configparser = ConfigParser() - config_dir_path = Path(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.ConfigLocation)) - config_path = config_dir_path / "fime" / "fime.conf" + config_dir_path = Path(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.AppConfigLocation)) + config_path = config_dir_path / "fime.conf" if config_path.exists(): print(f'Reading config file "{config_path}"') with open(config_path) as f: diff --git a/src/fime/data.py b/src/fime/data.py index ab9dbc2..4609f8f 100644 --- a/src/fime/data.py +++ b/src/fime/data.py @@ -12,12 +12,6 @@ try: except ImportError: from PySide2 import QtCore -data_dir_path = os.path.join(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.AppDataLocation), - "fime") - -tasks_path = os.path.join(data_dir_path, "tasks.json") - -data_path = os.path.join(data_dir_path, "data_{}.json") save_delay = 3 * 60 max_jira_tasks = 50 @@ -84,6 +78,8 @@ class Tasks: class Data(MutableMapping): def __init__(self): + data_dir_path = QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.AppDataLocation) + self.data_path = os.path.join(data_dir_path, "data_{}.json") if not os.path.exists(data_dir_path): os.mkdir(data_dir_path) self._cache = {} @@ -101,7 +97,7 @@ class Data(MutableMapping): atexit.register(cleanup) def __getitem__(self, key): - dpath = data_path.format(key) + dpath = self.data_path.format(key) if key not in self._cache and os.path.exists(dpath): with open(dpath, "r") as f: self._cache[key] = json.loads(f.read()) @@ -128,7 +124,7 @@ class Data(MutableMapping): for key in self._hot_keys: print(f"... saving dict {key} ...") to_write = self._cache[key] # apparently thread-safe - with open(data_path.format(key), "w+") as f: + with open(self.data_path.format(key), "w+") as f: f.write(json.dumps(to_write)) self._hot_keys = set() self._saving = False diff --git a/src/fime/main.py b/src/fime/main.py index aeff3b2..fc3e123 100755 --- a/src/fime/main.py +++ b/src/fime/main.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - import signal import sys from functools import partial @@ -132,7 +131,7 @@ class App: self.app.quit() def run(self): - timer = QtCore.QTimer() + timer = QtCore.QTimer(None) # interrupt event loop regularly for signal handling timer.timeout.connect(lambda: None) timer.start(500) @@ -161,6 +160,8 @@ class App: def main(): try: + # important for QStandardPath to be correct + QtCore.QCoreApplication.setApplicationName("fime") app = App() app.run() except FimeException as e: