feat(quick): add theme aliases used by the positioner box and scan progress ports

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014KYuz59BEmcx66GwNT3cmL
This commit is contained in:
Claude committed 2026-10-09 21:52:43 +00:00
1 parent 11a18d3c43
commit 06193ffa30
3 files changed
+26 -3

No files matched your search

+5 -2
View File
@@ -57,8 +57,11 @@ a theme switch.
**Aliases for existing ports.** `QmlTheme` also answers to the token names used on the earlier
branches, so their QML runs unchanged when they switch to this host: `muted`, `faint`, `text`,
`foreground`, `background`, `accent`, `busy`, `ok`, `warn`, `err`, `emergency`, `isDark`,
`busyText`, `okText`, `warnText`, `errText`, `busyTint`, `okTint`, `warnTint`, `errTint`.
New code uses the canonical names.
`busyText`, `okText`, `warnText`, `errText`, `busyTint`, `okTint`, `warnTint`, `errTint`,
`window`, `base`, `button`, `onAccent` and `c` (the raw `bec_qthemes` palette as a map, e.g.
`theme.c.ACCENT_DEFAULT`). New code uses the canonical names. One difference to note: on the
positioner-box branch `accent` meant the selection colour; here it is `ACCENT_DEFAULT`, so use
`primary` where that branch used `accent`.
## Controls
+16 -1
View File
@@ -61,7 +61,8 @@ class QmlTheme(QObject):
The names used by the first ports are kept as aliases (``muted``, ``faint``, ``text``,
``foreground``, ``background``, ``accent``, ``busy``, ``ok``, ``warn``, ``err``,
``emergency``, ``isDark``, ``busyText``, ``okTint`` ...), so their QML runs unchanged.
``emergency``, ``isDark``, ``busyText``, ``okTint``, ``window``, ``base``, ``button``,
``onAccent`` and the raw palette map ``c``), so their QML runs unchanged.
"""
changed = Signal()
@@ -184,6 +185,20 @@ class QmlTheme(QObject):
okTint = _color_property("success_tint")
warnTint = _color_property("warning_tint")
errTint = _color_property("danger_tint")
window = _color_property("bg")
base = _color_property("field")
button = _color_property("card")
onAccent = _color_property("on_primary")
@Property("QVariantMap", notify=changed)
def c(self) -> dict:
"""The raw ``bec_qthemes`` palette as ``{KEY: "#rrggbb"}``, e.g. ``theme.c.ACCENT_DEFAULT``."""
theme = app_theme()
colors = dict(getattr(theme, "colors", None) or {})
return {
key: QColor(value).name() for key, value in colors.items() if QColor(value).isValid()
}
# pylint: enable=invalid-name
del _color_property, _metric_property
+5
View File
@@ -105,12 +105,17 @@ def test_qml_theme_aliases_match_canonical_names(dark_theme):
("emergency", "danger"),
("errText", "dangerText"),
("okTint", "successTint"),
("window", "bg"),
("base", "field"),
("button", "card"),
("onAccent", "onPrimary"),
]
for alias, canonical in pairs:
assert theme.property(alias) == theme.property(canonical), alias
assert theme.property("isDark") is True
assert theme.property("radiusLarge") == 10
assert theme.toneText("warn") == theme.property("warningText")
assert QColor(theme.property("c")["CARD_BG"]) == theme.property("card")
def test_qml_theme_emits_changed_on_theme_switch(qtbot):