impr(ui.theme): add secondary & tertiary colors

This commit is contained in:
2025-11-15 13:11:45 +08:00
parent a2148c7d24
commit 0966a3eb40
2 changed files with 14 additions and 0 deletions

View File

@ -86,6 +86,8 @@ class Material3ThemeImpl(ThemeImpl):
@property
def customPalette(self) -> _TCustomPalette:
primaryHct = _hexToHct(self.themeData["schemes"][self.scheme]["primary"])
secondaryHct = _hexToHct(self.themeData["schemes"][self.scheme]["secondary"])
tertiaryHct = _hexToHct(self.themeData["schemes"][self.scheme]["tertiary"])
successColorItem = self._findExtendedColor("Success")
if successColorItem is None:
@ -97,7 +99,10 @@ class Material3ThemeImpl(ThemeImpl):
)
return {
**ThemeImpl.DEFAULT_CUSTOM_PALETTE,
"primary": _hctToQColor(primaryHct),
"secondary": _hctToQColor(secondaryHct),
"tertiary": _hctToQColor(tertiaryHct),
"success": _hctToQColor(successHarmonizedHct),
"error": QColor.fromString(self.themeData["schemes"][self.scheme]["error"]),
"toolTipBase": self.qPalette.color(QPalette.ColorRole.ToolTipBase),
@ -195,6 +200,8 @@ class Material3DynamicThemeImpl(ThemeImpl):
@property
def customPalette(self) -> _TCustomPalette:
primaryHct = MaterialDynamicColors.primary.get_hct(self.material3Scheme)
secondaryHct = MaterialDynamicColors.secondary.get_hct(self.material3Scheme)
tertiaryHct = MaterialDynamicColors.tertiary.get_hct(self.material3Scheme)
errorHct = MaterialDynamicColors.error.get_hct(self.material3Scheme)
extendedPalettes: dict[str, DynamicColor] = {}
@ -227,7 +234,10 @@ class Material3DynamicThemeImpl(ThemeImpl):
)
return {
**ThemeImpl.DEFAULT_CUSTOM_PALETTE,
"primary": _hctToQColor(primaryHct),
"secondary": _hctToQColor(secondaryHct),
"tertiary": _hctToQColor(tertiaryHct),
"success": _hctToQColor(
extendedPalettes["success"].get_hct(self.material3Scheme)
),

View File

@ -6,6 +6,8 @@ from PySide6.QtGui import QColor, QPalette
class _TCustomPalette(TypedDict):
primary: QColor
secondary: QColor
tertiary: QColor
success: QColor
error: QColor
@ -32,6 +34,8 @@ class ThemeInfo:
class ThemeImpl:
DEFAULT_CUSTOM_PALETTE: _TCustomPalette = {
"primary": QColor.fromString("#616161"),
"secondary": QColor.fromString("#616161"),
"tertiary": QColor.fromString("#616161"),
"success": QColor.fromString("#616161"),
"error": QColor.fromString("#616161"),
"toolTipBase": QColor.fromString("#616161"),