mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-11-06 20:42:15 +00:00
wip: basic theming support
This commit is contained in:
37
ui/theme/qml.py
Normal file
37
ui/theme/qml.py
Normal file
@ -0,0 +1,37 @@
|
||||
from PySide6.QtCore import Property, QObject, Signal
|
||||
from PySide6.QtGui import QColor
|
||||
|
||||
from .shared import ThemeImpl
|
||||
|
||||
QML_IMPORT_NAME = "internal.ui.theme"
|
||||
QML_IMPORT_MAJOR_VERSION = 1
|
||||
QML_IMPORT_MINOR_VERSION = 0
|
||||
|
||||
|
||||
class ThemeQmlExposer(QObject):
|
||||
themeChanged = Signal()
|
||||
|
||||
def __init__(self, *, themeImpl: ThemeImpl, parent: QObject | None = None):
|
||||
super().__init__(parent)
|
||||
self._themeImpl = themeImpl
|
||||
|
||||
@property
|
||||
def themeImpl(self) -> ThemeImpl:
|
||||
return self._themeImpl
|
||||
|
||||
@themeImpl.setter
|
||||
def themeImpl(self, themeImpl: ThemeImpl):
|
||||
self._themeImpl = themeImpl
|
||||
self.themeChanged.emit()
|
||||
|
||||
@Property(QColor, notify=themeChanged)
|
||||
def primary(self):
|
||||
return self._themeImpl.customPalette["primary"]
|
||||
|
||||
@Property(QColor, notify=themeChanged)
|
||||
def success(self):
|
||||
return self._themeImpl.customPalette["success"]
|
||||
|
||||
@Property(QColor, notify=themeChanged)
|
||||
def error(self):
|
||||
return self._themeImpl.customPalette["error"]
|
||||
Reference in New Issue
Block a user