Add Mod() Qt wrapper

This commit is contained in:
Toast 2025-05-28 10:15:38 +02:00
parent ad10a116ac
commit 058a8346bd

39
src/leek/qmod.py Normal file
View file

@ -0,0 +1,39 @@
from pathlib import Path
from PySide6.QtCore import Property, QObject, Signal, Slot
from PySide6.QtQml import QmlElement, QmlUncreatable
from leek.mod import Mod
QML_IMPORT_NAME = "Leek"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
@QmlUncreatable("QMod is intended to be returned by a QModListModel")
class QMod(QObject):
"""
Qt wrapper around the Mod() class
"""
__mod: Mod
def __init__(self, mod_path: Path, parent=None) -> None:
QObject.__init__(self, parent)
try:
self.__mod = Mod(mod_path)
except:
# Pass though all exceptions
raise
@Property(str, constant=True)
def name(self) -> str | None:
return self.__mod.name
@Property(str, constant=True)
def description(self) -> str | None:
return self.__mod.description
@Property(bool, constant=True)
def enabled(self) -> bool:
return self.__mod.enabled