Move source code to src/leek

This makes the package work again
This commit is contained in:
Toast 2025-05-22 22:52:08 +02:00
parent 1a626fddff
commit 6061590270
9 changed files with 16 additions and 10 deletions

View file

@ -1,54 +0,0 @@
from PySide6.QtQml import QmlElement
from PySide6.QtCore import QAbstractListModel, QModelIndex
from mod import Mod, InvalidModError
import os
QML_IMPORT_NAME = "Leek"
QML_IMPORT_MAJOR_VERSION = 1
# TODO: Don't harcode the mods path
GAME_PATH = "/home/toast/.local/share/Steam/steamapps/common/Hatsune Miku Project DIVA Mega Mix Plus/"
# Qt follows C++ naming conventions
# ruff: noqa: N802
@QmlElement
class QModListModel(QAbstractListModel):
def __init__(self, parent=None) -> None:
super().__init__(parent=parent)
mods: list[Mod] = []
with os.scandir(GAME_PATH + "mods/") as dirs:
for dir in dirs:
try:
new_mod: Mod = Mod(dir.path + "/" )
mods.append(new_mod)
except InvalidModError as e:
print(f"Found invalid mod at {dir.path}: {e.message}")
continue
self.mods = mods
def roleNames(self) -> dict[int, bytes]:
return {
0: b"name",
1: b"description",
2: b"enabled"
}
def rowCount(self, parent=QModelIndex()) -> int:
return len(self.mods)
def data(self, index: QModelIndex, role: int) -> None | str | bool:
i: int = index.row()
result: None | str | bool
if not index.isValid():
result = None
elif role == 0:
result = self.mods[i].name
elif role == 1:
result = self.mods[i].description
elif role == 2:
result = self.mods[i].enabled
else:
result = None
return result