Add Mod() Qt wrapper
This commit is contained in:
parent
ad10a116ac
commit
058a8346bd
1 changed files with 39 additions and 0 deletions
39
src/leek/qmod.py
Normal file
39
src/leek/qmod.py
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue