feat(kiosk): live Kiosk<->Desktop toggle in the NPB layout menu

Add a "Kiosk mode" / "Desktop mode" item to both PlayerBarSmall and
PlayerBar view menus (label from the new ShellState.kiosk-profile flag).
It fires media-action("npb-view","","toggle-profile"); Rust flips the
persisted ui_prefs.profile and swaps the shell in place via set_screen
(KioskShell/AppShell share state, so no restart). The toggle keys off the
current screen, not kiosk_profile_active(), so a QBZ_PROFILE env override
doesnt pin it. ShellState.kiosk-profile is seeded at window setup.

cc
This commit is contained in:
vicrodh committed 2026-07-10 21:17:12 -06:00
1 parent dc51c62c7f
commit f1d965b04e
4 files changed
+36

No files matched your search

+7
View File
@@ -790,6 +790,13 @@ export component PlayerBar inherits Rectangle {
root.media-action("npb-view", "", "immersive");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/hard-drive.svg");
label: ShellState.kiosk-profile ? @tr("Desktop mode") : @tr("Kiosk mode");
clicked => {
root.media-action("npb-view", "", "toggle-profile");
}
}
}
}
}
@@ -802,6 +802,13 @@ export component PlayerBarSmall inherits Rectangle {
root.media-action("npb-view", "", "immersive");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/hard-drive.svg");
label: ShellState.kiosk-profile ? @tr("Desktop mode") : @tr("Kiosk mode");
clicked => {
root.media-action("npb-view", "", "toggle-profile");
}
}
}
}
}
+3
View File
@@ -3724,6 +3724,9 @@ export global UiScale {
// Globals are imported directly by the shell components, so toggles
// need no callback plumbing.
export global ShellState {
// Kiosk profile active (2.0.2 frente #3). Seeded from Rust at startup and
// flipped by the NPB "Kiosk/Desktop mode" toggle; drives that toggle's label.
in-out property <bool> kiosk-profile: false;
// --- Reduce motion (weak renderer tiers) -------------------------------
// Seeded from Rust: true on the femtovg-GL / software tiers, where every
// animation frame is a full-window repaint on a weak GPU. When set,
+19
View File
@@ -6700,6 +6700,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
window
.global::<ShellState>()
.set_reduce_motion(kiosk_profile || !use_gpu_renderer);
window.global::<ShellState>().set_kiosk_profile(kiosk_profile);
// Fullscreen-at-boot is a kiosk behavior (no separate flag): the appliance
// owns the whole panel. Routed through slint::Window so realization
// reconciliation keeps it (see WindowControlActions on_toggle_fullscreen at
@@ -9705,6 +9706,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
crate::ui_prefs::save(&prefs);
}
}
// Kiosk <-> Desktop live toggle (2.0.2 frente #3). Based on the
// CURRENT screen, not kiosk_profile_active() — a QBZ_PROFILE env
// override would otherwise pin the reading. Persists the profile
// and swaps the shell in place (KioskShell/AppShell share state).
("npb-view", "toggle-profile") => {
if let Some(w) = weak.upgrade() {
let to_kiosk = w.get_screen() != AppScreen::Kiosk;
let mut prefs = crate::ui_prefs::load();
prefs.profile = if to_kiosk { "kiosk" } else { "desktop" }.to_string();
crate::ui_prefs::save(&prefs);
w.global::<ShellState>().set_kiosk_profile(to_kiosk);
w.set_screen(if to_kiosk {
AppScreen::Kiosk
} else {
AppScreen::Shell
});
}
}
// Large dock: visualizer on/off toggle (the cover's eye button).
// Routed through Rust so the choice persists in ui_prefs; the
// AppShell viz-should-run handler idles the FFT tap when off.