From 56e8fada4dd1357b08c92947b16e73858519526b Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Wed, 7 Jan 2026 22:23:29 +0100 Subject: [PATCH] add settings_path to AppState and add models for download logging --- core/utils/config/config.py | 14 +++++++------- core/utils/data/models.py | 15 +++++++++++++++ core/utils/data/state.py | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 core/utils/data/models.py diff --git a/core/utils/config/config.py b/core/utils/config/config.py index 6021c32..4cf6513 100644 --- a/core/utils/config/config.py +++ b/core/utils/config/config.py @@ -10,14 +10,14 @@ def create_config(): "ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}"} if platform.system() == "Windows": - config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming")) + config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming")) else: config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")) - settings_path = os.path.join(config_dir, "SoftwareManager") - os.makedirs(settings_path, exist_ok=True) + state.settings_path = os.path.join(config_dir, "SoftwareManager") + os.makedirs(state.settings_path, exist_ok=True) - with open(os.path.join(settings_path, "config.yml"), 'w') as cf: + with open(os.path.join(state.settings_path, "config.yml"), 'w') as cf: config.write(cf) @@ -26,11 +26,11 @@ def read_config(): config = configparser.ConfigParser() if platform.system() == "Windows": - config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming")) + config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming")) else: config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")) - settings_path = os.path.join(config_dir, "SoftwareManager") - config_file = os.path.join(settings_path, "config.yml") + state.settings_path = os.path.join(config_dir, "SoftwareManager") + config_file = os.path.join(state.settings_path, "config.yml") if not os.path.exists(config_file): create_config() diff --git a/core/utils/data/models.py b/core/utils/data/models.py new file mode 100644 index 0000000..9d273c3 --- /dev/null +++ b/core/utils/data/models.py @@ -0,0 +1,15 @@ +from dataclasses import dataclass +from typing import List + + +@dataclass +class Download: + title: str + url: str + torrent_uri: str + completed: bool + +@dataclass +class DownloadList: + count: int + data: List[Download] \ No newline at end of file diff --git a/core/utils/data/state.py b/core/utils/data/state.py index a614727..f690563 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -24,6 +24,7 @@ class AppState(QObject): self.aria2: Any = None self.aria2p: Any = None self.aria2_threads: int = 4 + self.settings_path: str = None @property def image_path(self) -> str: