feat(qbz-slint): wire theme persistence + Rust-driven palette apply
Connect the qbz-theme registry to the running app and persist the choice across restarts (owner hard requirement 2026-06-20). - `src/theme.rs`: Rgba->slint::Color conversion, `to_slint` building the generated `ThemeColors` (55 fields, exact name parity with the Slint struct), `apply_theme` (set_c + set_is_system), and slug<->index<->id mapping with slug as the source of truth. Unit tests cover the roundtrip + fallbacks. - `ui_prefs.rs`: new `theme: String` slug field, `#[serde(default)]` -> `qbz_theme::default_slug()` (OLED). Old profiles without the field restore to OLED. Tests assert the default. - `main.rs`: add the missing `"theme"` arm in `on_appearance_select` (was falling into the debug `other =>` arm) — maps dropdown index to id, persists the slug, hot-switches the palette. Startup restore seeds the dropdown list from the registry, derives the index from the persisted slug, syncs the legacy `ThemeState.mode`, and applies the theme before first paint. - `app.slint`: export `Theme`/`ThemeColors`/`ThemeState` so Rust can drive them. - `AppearanceSettings.slint`/`state.slint`: the theme list is now Rust-seeded; comments updated (index no longer drives colors; slug is source of truth). Headline acceptance: pick a theme, quit, relaunch -> same theme; fresh profile boots into OLED Dark. The 4 existing themes are unchanged (legacy alias values preserved in the registry). cc
This commit is contained in:
8 files changed
+245
-7
No files matched your search
@@ -2537,8 +2537,10 @@ export global SettingsState {
|
||||
// so the UI renders standalone even while unwired.
|
||||
export global AppearanceState {
|
||||
// --- THEME -------------------------------------------------------------
|
||||
// Only the themes that are actually ported/wired. Order is load-bearing:
|
||||
// the index maps 1:1 to ThemeState.mode (0 Dark, 1 OLED, 2 Tokyo, 3 System).
|
||||
// Seeded at startup by Rust from the qbz-theme registry
|
||||
// (theme::dropdown_labels), in registry display order. The list below is a
|
||||
// standalone-preview fallback only; the index is DERIVED from the persisted
|
||||
// theme slug (theme::index_for_id), never assumed.
|
||||
in-out property <[string]> themes: [
|
||||
"Dark", "OLED Black", "Tokyo Night", "System"
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user