Compare commits
4 commits
ca7e1bb2d1
...
4d22e68a9b
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d22e68a9b | |||
| 4d3112e9e8 | |||
| ad4f429cd9 | |||
| 20f459ddad |
3 changed files with 21 additions and 4 deletions
|
|
@ -24,7 +24,7 @@ def main():
|
||||||
os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop"
|
os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop"
|
||||||
|
|
||||||
base_path = os.path.abspath(os.path.dirname(__file__))
|
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)
|
engine.load(url)
|
||||||
|
|
||||||
if len(engine.rootObjects()) == 0:
|
if len(engine.rootObjects()) == 0:
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
import tomlkit
|
import tomlkit
|
||||||
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tomlkit import TOMLDocument
|
from tomlkit import TOMLDocument
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
class Mod:
|
class Mod:
|
||||||
__config: TOMLDocument
|
__config: TOMLDocument
|
||||||
|
|
||||||
|
__has_meta_json: bool
|
||||||
|
__meta: dict[str, Any]
|
||||||
|
|
||||||
__path: Path
|
__path: Path
|
||||||
__name: str
|
__name: str
|
||||||
__description: str
|
__description: str
|
||||||
|
|
@ -53,6 +59,7 @@ class Mod:
|
||||||
|
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
self.__path = path
|
self.__path = path
|
||||||
|
self.__meta = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
config_toml = Path(self.__path, "config.toml")
|
config_toml = Path(self.__path, "config.toml")
|
||||||
|
|
@ -61,11 +68,21 @@ class Mod:
|
||||||
|
|
||||||
if "enabled" not in self.__config:
|
if "enabled" not in self.__config:
|
||||||
raise InvalidModError("config.toml does not contain the enabled key")
|
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:
|
except FileNotFoundError:
|
||||||
raise InvalidModError("config.toml does not exist")
|
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:
|
def __str__(self) -> str:
|
||||||
return f"Mod({self.__path})"
|
return f"Mod({self.__path})"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ Kirigami.ApplicationWindow {
|
||||||
|
|
||||||
Controls.Switch {
|
Controls.Switch {
|
||||||
checked: mod.enabled
|
checked: mod.enabled
|
||||||
text: "Enabled"
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
|
||||||
onClicked: mod.enabled = checked
|
onClicked: mod.enabled = checked
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue