Compare commits
6 commits
8a36617298
...
bb858ef261
| Author | SHA1 | Date | |
|---|---|---|---|
| bb858ef261 | |||
| da8749e1a7 | |||
| bfefcd757e | |||
| 56165d0cef | |||
| bd6068d263 | |||
| f07bd10306 |
5 changed files with 63 additions and 11 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
outputs = { nixpkgs, ... }:
|
outputs = { nixpkgs, self, ... }:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
lib = nixpkgs.lib;
|
lib = nixpkgs.lib;
|
||||||
|
|
@ -27,7 +27,9 @@
|
||||||
};
|
};
|
||||||
packages.x86_64-linux = rec {
|
packages.x86_64-linux = rec {
|
||||||
default = leek;
|
default = leek;
|
||||||
leek = pkgs.callPackage ./package.nix { };
|
leek = pkgs.callPackage ./package.nix {
|
||||||
|
gitRev = self.sourceInfo.shortRev or self.sourceInfo.dirtyShortRev;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
package.nix
12
package.nix
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{ kdePackages
|
||||||
kdePackages,
|
, python3Packages
|
||||||
python3Packages,
|
, qt6
|
||||||
qt6
|
, gitRev ? "dirty"
|
||||||
}: python3Packages.buildPythonApplication rec {
|
}: python3Packages.buildPythonApplication rec {
|
||||||
pname = "leek";
|
pname = "leek";
|
||||||
version = "0.0.1";
|
version = gitRev;
|
||||||
pyproject = true;
|
pyproject = true;
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = [
|
||||||
kdePackages.kirigami
|
kdePackages.kirigami
|
||||||
];
|
];
|
||||||
|
|
||||||
makeWrapperArgs = [
|
makeWrapperArgs = [
|
||||||
"\${qtWrapperArgs[@]}"
|
"\${qtWrapperArgs[@]}"
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -18,19 +24,36 @@ class Mod:
|
||||||
# Mod metadata
|
# Mod metadata
|
||||||
@property
|
@property
|
||||||
def name(self) -> str | None:
|
def name(self) -> str | None:
|
||||||
|
if self.__has_meta_json:
|
||||||
|
if "name" in self.__meta:
|
||||||
|
return self.__meta.get("name", str)
|
||||||
if "name" not in self.__config:
|
if "name" not in self.__config:
|
||||||
return None
|
return None
|
||||||
return self.__config.get("name", str)
|
return self.__config.get("name", str)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def description(self) -> str | None:
|
def description(self) -> str | None:
|
||||||
|
if self.__has_meta_json:
|
||||||
|
if "description" in self.__meta:
|
||||||
|
return self.__meta.get("description", str)
|
||||||
if "description" not in self.__config.keys():
|
if "description" not in self.__config.keys():
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return self.__config.get("description", str)
|
return self.__config.get("description", str)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def long_description(self) -> str | None:
|
||||||
|
if "descriptionLong" in self.__meta:
|
||||||
|
return self.__meta.get("descriptionLong", str)
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def author(self) -> str | None:
|
def author(self) -> str | None:
|
||||||
|
# TODO: return list with authors
|
||||||
|
if self.__has_meta_json:
|
||||||
|
if "authors" in self.__meta:
|
||||||
|
authors: list[str] = self.__meta.get("authors", list[str])
|
||||||
|
return ", ".join(authors)
|
||||||
if "author" not in self.__config:
|
if "author" not in self.__config:
|
||||||
return None
|
return None
|
||||||
return self.__config.get("author", str)
|
return self.__config.get("author", str)
|
||||||
|
|
@ -53,6 +76,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 +85,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})"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,16 @@ Kirigami.ApplicationWindow {
|
||||||
}
|
}
|
||||||
Controls.Button {
|
Controls.Button {
|
||||||
text: "Delete"
|
text: "Delete"
|
||||||
|
onClicked: notImplementedDialog.open()
|
||||||
|
Kirigami.Dialog {
|
||||||
|
id: notImplementedDialog
|
||||||
|
title: "Not implemented!"
|
||||||
|
standardButtons: Kirigami.Dialog.Ok
|
||||||
|
padding: Kirigami.Units.largeSpacing
|
||||||
|
Controls.Label {
|
||||||
|
text: "Deleting is not implemented yet"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ QML_IMPORT_NAME = "Leek"
|
||||||
QML_IMPORT_MAJOR_VERSION = 1
|
QML_IMPORT_MAJOR_VERSION = 1
|
||||||
|
|
||||||
|
|
||||||
|
# Qt follows C++ naming conventions
|
||||||
|
# ruff: noqa: N802
|
||||||
@QmlElement
|
@QmlElement
|
||||||
@QmlUncreatable("QMod is intended to be returned by a QModListModel")
|
@QmlUncreatable("QMod is intended to be returned by a QModListModel")
|
||||||
class QMod(QObject):
|
class QMod(QObject):
|
||||||
|
|
@ -34,6 +36,10 @@ class QMod(QObject):
|
||||||
def description(self) -> str | None:
|
def description(self) -> str | None:
|
||||||
return self.__mod.description
|
return self.__mod.description
|
||||||
|
|
||||||
|
@Property(str, constant=True)
|
||||||
|
def longDescription(self) -> str | None:
|
||||||
|
return self.__mod.long_description
|
||||||
|
|
||||||
mod_enabled = Signal(name="enabled")
|
mod_enabled = Signal(name="enabled")
|
||||||
|
|
||||||
@Property(bool, notify=mod_enabled)
|
@Property(bool, notify=mod_enabled)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue