Files
qbz/crates/qbz-slint/ui/primitives/QbzToggle.slint
T
vicrodh 5d78fb0a09 feat(slint): add Settings page with Audio and Playback panels
Introduce the Settings page, reachable from the Discover gear and the
header menu. Two sub-sections backed by the existing UI-agnostic stores.

- Audio panel: backend, output device and sample-rate dropdowns;
  toggles for exclusive mode, DAC passthrough, PipeWire force
  bit-perfect, gapless, normalization and quality fallback
- Playback panel: autoplay mode, show context icon, remember session
  and resume position
- settings.rs controller owns AudioSettingsStore + PlaybackPreferencesStore
  at the shared global path; persists changes and applies audio ones to
  the live Player (reload_settings, plus reinit_device for routing-
  critical changes); a backend switch re-enumerates output devices
- QbzToggle (switch) and QbzSelect (PopupWindow dropdown) primitives,
  SettingRow layout helper, chevron-down icon
- SettingsState global, ContentView::settings, settings-bool /
  settings-select callbacks wired through the shell

cc
2026-05-18 17:08:24 -06:00

39 lines
1.1 KiB
Plaintext

// Switch toggle primitive — the standard on/off control for settings.
//
// The toggle does not flip itself: it emits `toggled(new-value)` and the
// caller updates the bound state. This keeps a single source of truth in
// the SettingsState global.
import { Theme } from "../foundation/semantic-colors.slint";
export component QbzToggle inherits Rectangle {
in property <bool> checked: false;
in property <bool> enabled: true;
callback toggled(bool);
width: 40px;
height: 22px;
border-radius: 11px;
background: root.checked ? Theme.accent : Theme.surface-elevated;
opacity: root.enabled ? 1.0 : 0.4;
Rectangle {
width: 16px;
height: 16px;
border-radius: 8px;
background: Theme.text-primary;
y: 3px;
x: root.checked ? root.width - self.width - 3px : 3px;
animate x { duration: 120ms; easing: ease-out; }
}
TouchArea {
mouse-cursor: root.enabled ? pointer : default;
clicked => {
if (root.enabled) {
root.toggled(!root.checked);
}
}
}
}