Visualizer: gray-mode color slider + mode persists across launches

- New prefs: visualizer_mode (on/dim/off, saved on every click) and
  color_visualizer_gray (None = keep the derived alternateBase look).
- VisualizerWidget takes prefs (optional, so existing call sites/tests
  keep working); restores its mode at startup and validates junk values.
- New "Visualizer (gray mode):" row in the Preferences color sliders;
  theme.default_gray mirrors the widget's 0.88-lightness derivation so
  an untouched slider shows the current appearance.
- TransportBar.refresh_theme() repaints the visualizer so slider drags
  preview live.
This commit is contained in:
2026-07-02 16:52:59 -04:00
parent 08d3058edb
commit a1eb8aec8b
6 changed files with 129 additions and 4 deletions
+11 -1
View File
@@ -70,7 +70,17 @@ def default_gray(key: str) -> int:
current appearance, so showing the slider doesn't imply a change."""
if key in _FIXED_GRAY_DEFAULT:
return _FIXED_GRAY_DEFAULT[key]
color = _base().color(QPalette.ColorGroup.Active, _PALETTE_GRAY_ROLE[key])
if key == "color_visualizer_gray":
# Dim-mode bars derive from alternateBase dropped ~12% in lightness
# (see VisualizerWidget._bar_color); mirror that so the slider shows
# the current appearance.
color = _base().color(QPalette.ColorGroup.Active,
QPalette.ColorRole.AlternateBase)
h, s, l, a = color.getHslF()
color.setHslF(h, s, l * 0.88, a)
else:
color = _base().color(QPalette.ColorGroup.Active,
_PALETTE_GRAY_ROLE[key])
return round(0.299 * color.red() + 0.587 * color.green()
+ 0.114 * color.blue())