Compare commits

...

10 commits

Author SHA1 Message Date
a549e9a99c Add Mod class 2025-05-07 00:17:46 +02:00
796f0aa209 Add dependencies to pyproject, add tomlkit 2025-05-07 00:16:25 +02:00
34cf1da185 Update gitignore 2025-05-07 00:13:44 +02:00
010deddc8e Set desktop file and app name 2025-05-06 20:19:00 +02:00
02621b79aa Flake: replace c++ tooling with python tooling in devshell 2025-05-06 16:41:13 +02:00
34b8610432 Revert "Temporarely disable direnv"
This reverts commit aaa6df32b4.
2025-05-06 16:36:09 +02:00
6a4272502e Add nix package 2025-05-06 16:25:12 +02:00
1575222c9d Rename main.py, fix qml path 2025-05-06 16:22:21 +02:00
786be23b6e Make project importable 2025-05-06 13:11:03 +02:00
792ee5c281 Turn into python project 2025-05-06 13:08:25 +02:00
10 changed files with 159 additions and 17 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

1
.gitignore vendored
View file

@ -8,3 +8,4 @@ result-*
# ---> Python
.venv
__pycache__

1
MANIFEST.in Normal file
View file

@ -0,0 +1 @@
include src/*.qml

View file

@ -11,22 +11,21 @@
{
devShells.x86_64-linux.default = pkgs.mkShell {
name = "leek-devshell";
packages =
let
kdeDeps = with pkgs.kdePackages; [
extra-cmake-modules
qtbase
qtdeclarative
kirigami
ki18n
kcoreaddons
qqc2-desktop-style
];
in
with pkgs; [
clang-tools
cmake
] ++ kdeDeps;
packages = with pkgs; [
ruff
(
python3.withPackages (ps: with ps;[
python-lsp-server
pyside6
tomlkit
]
)
)
];
};
packages.x86_64-linux = rec {
default = leek;
leek = pkgs.callPackage ./package.nix { };
};
};
}

33
package.nix Normal file
View file

@ -0,0 +1,33 @@
{
kdePackages,
python3Packages,
qt6
}: python3Packages.buildPythonApplication rec {
pname = "leek";
version = "0.0.1";
pyproject = true;
src = ./.;
build-system = [
python3Packages.setuptools
];
dependencies = with python3Packages; [
pyside6
tomlkit
];
nativeBuildInputs = [
qt6.wrapQtAppsHook
];
propagatedBuildInputs = [
kdePackages.kirigami
];
makeWrapperArgs = [
"\${qtWrapperArgs[@]}"
];
}

36
pyproject.toml Normal file
View file

@ -0,0 +1,36 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "leek"
version = "0.0.1"
authors = [{name = "Toast"}]
description = "Project diva megamix + mod manager"
license = "MIT"
classifiers = [
"Intended Audience :: End Users/Desktop",
"Topic :: Utilities",
"Programming Language :: Python",
"Operating System :: POSIX :: Linux",
]
dependencies = [
"pyside6",
"tomlkit",
]
[project.readme]
file = "README.md"
content-type = "text/markdown"
[project.scripts]
leek = "leek.leek_app:main"
[tool.setuptools]
packages = ["leek"]
package-dir = {leek = "src"}
include-package-data = true
[tool.setuptools.data-files]
"share/applications" = ["xyz.toast003.leek.desktop"]

68
src/Mod.py Normal file
View file

@ -0,0 +1,68 @@
import tomlkit
class Mod:
@property
def path(self) -> str:
return self.__path
# Mod metadata
@property
def name(self) -> str | None:
if "name" not in self.__config:
return None
return self.__config["name"]
@property
def description(self) -> str | None:
if "description" not in self.__config.keys():
return None
else:
return self.__config["description"]
@property
def author(self) -> str | None:
if "author" not in self.__config:
return None
return self.__config["author"]
@property
def enabled(self) -> str:
return self.__enabled
def __init__(self, path: str) -> None:
self.__path = path
with open(path + "config.toml") as configFile:
self.__config = tomlkit.load(configFile)
if "enabled" not in self.__config:
raise InvalidModError("config.toml does not contain the enabled key")
else:
self.__enabled = self.__config["enabled"]
@enabled.setter
def enabled(self, value: bool) -> None:
if value == self.__enabled:
# Nothing to do
return
with open(self.__path + "config.toml", "w") as configFile:
self.__config["enabled"] = value
tomlkit.dump(self.__config, configFile)
def __str__(self) -> str:
return f"Mod({self.__path})"
class InvalidModError(Exception):
"""
This exception is raised when the Mod class gets given a path of something that's not a valid mod
"""
def __init__(self, message: str) -> None:
super().__init__(message)
self.message = message
def __str__(self) -> str:
return f"{self.message}"

0
src/__init__.py Normal file
View file

1
src/__main__.py Normal file
View file

@ -0,0 +1 @@
from . import leek_app

View file

@ -11,6 +11,8 @@ from PySide6.QtQml import QQmlApplicationEngine
def main():
"""Initializes and manages the application execution"""
app: QGuiApplication = QGuiApplication(sys.argv)
app.desktopFileName = "xyz.xyz.toast003.leek"
app.applicationName = "Leek"
engine = QQmlApplicationEngine()
"""Needed to close the app with Ctrl+C"""
@ -21,7 +23,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}/Main.qml")
engine.load(url)
if len(engine.rootObjects()) == 0: