From 20f459ddada95a6acb9c03e11b383cb7f10b97cf Mon Sep 17 00:00:00 2001 From: Toast Date: Thu, 29 May 2025 12:24:14 +0200 Subject: [PATCH 1/4] Main: center and remove text on switch --- src/leek/Main.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/leek/Main.qml b/src/leek/Main.qml index b592fe7..576034c 100644 --- a/src/leek/Main.qml +++ b/src/leek/Main.qml @@ -77,7 +77,7 @@ Kirigami.ApplicationWindow { Controls.Switch { checked: mod.enabled - text: "Enabled" + Layout.alignment: Qt.AlignCenter onClicked: mod.enabled = checked } From ad4f429cd972ef4c7b347b07e620d61055f3fecf Mon Sep 17 00:00:00 2001 From: Toast Date: Thu, 29 May 2025 12:27:50 +0200 Subject: [PATCH 2/4] Move qml files to their own folder --- src/leek/leek_app.py | 2 +- src/leek/{ => qml}/Main.qml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/leek/{ => qml}/Main.qml (100%) diff --git a/src/leek/leek_app.py b/src/leek/leek_app.py index 9b59cfe..5a93db9 100644 --- a/src/leek/leek_app.py +++ b/src/leek/leek_app.py @@ -24,7 +24,7 @@ def main(): os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop" base_path = os.path.abspath(os.path.dirname(__file__)) - url = QUrl(f"file://{base_path}/Main.qml") + url = QUrl(f"file://{base_path}/qml/Main.qml") engine.load(url) if len(engine.rootObjects()) == 0: diff --git a/src/leek/Main.qml b/src/leek/qml/Main.qml similarity index 100% rename from src/leek/Main.qml rename to src/leek/qml/Main.qml From 4d3112e9e8eae96791769ec427df5b23db3fad62 Mon Sep 17 00:00:00 2001 From: Toast Date: Thu, 29 May 2025 12:43:55 +0200 Subject: [PATCH 3/4] Mod: remove unneded else statement --- src/leek/mod.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/leek/mod.py b/src/leek/mod.py index 73d7db0..ca06c2a 100644 --- a/src/leek/mod.py +++ b/src/leek/mod.py @@ -61,8 +61,7 @@ class Mod: if "enabled" not in self.__config: raise InvalidModError("config.toml does not contain the enabled key") - else: - self.__enabled = self.__config.get("enabled", bool) + self.__enabled = self.__config.get("enabled", bool) except FileNotFoundError: raise InvalidModError("config.toml does not exist") From 4d22e68a9b8dd24e601968d7c94d58ff6f9bf002 Mon Sep 17 00:00:00 2001 From: Toast Date: Thu, 29 May 2025 17:21:54 +0200 Subject: [PATCH 4/4] Mod: parse meta.json if it exists --- src/leek/mod.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/leek/mod.py b/src/leek/mod.py index ca06c2a..84d0ddc 100644 --- a/src/leek/mod.py +++ b/src/leek/mod.py @@ -1,10 +1,16 @@ import tomlkit +import json from pathlib import Path from tomlkit import TOMLDocument +from typing import Any class Mod: __config: TOMLDocument + + __has_meta_json: bool + __meta: dict[str, Any] + __path: Path __name: str __description: str @@ -53,6 +59,7 @@ class Mod: def __init__(self, path: Path) -> None: self.__path = path + self.__meta = {} try: config_toml = Path(self.__path, "config.toml") @@ -65,6 +72,17 @@ class Mod: except FileNotFoundError: raise InvalidModError("config.toml does not exist") + meta_json: Path = Path(self.__path, "meta.json") + if meta_json.exists(): + self.__has_meta_json = True + try: + with meta_json.open() as file: + self.__meta = json.load(file) + except json.JSONDecodeError as e: + print("Failed to parse meta.json!: ", e.msg) + else: + self.__has_meta_json = False + def __str__(self) -> str: return f"Mod({self.__path})"