Files
qbz/crates/qbz-slint/ui/primitives/DacWizardModal.slint
T
vicrodh 9c5febdaa8 feat(slint): HiFi wizard check step — stack health, distro/init override, sandbox (Slice 6)
Wires the check step on top of the Slice-0/2/6 backend: a health verdict
(success/warning WarningBanner — new `success` variant), a per-missing-piece
CommandBlock with copy, and TWO overridable dropdowns — distro (package
manager) and init system (service commands), which are orthogonal so a Gentoo
box on systemd vs OpenRC gets the right restart command.

New `src/dac_wizard.rs` controller: open() runs the probe off-thread
(spawn_blocking → upgrade_in_event_loop), caches it, and recompute() rebuilds
remediations from the cached probe + the current distro/init selections.
Init-aware restart_cmd (systemd/OpenRC/runit/s6/dinit). NixOS special-cased to
a declarative configuration.nix block.

Sandbox honesty: in Flatpak/Snap the host probes are blind, so the check step
shows an info banner + reference setup commands (full stack incl. pipewire-alsa
+ restart) for the chosen distro/init instead of a false health verdict.

main.rs wires on_open/on_set_distro/on_set_init/on_copy_command; the Audio
settings trigger calls DacWizardActions.open().

cc
2026-06-15 21:04:23 -06:00

345 lines
16 KiB
Plaintext

// HiFi Wizard (DAC setup) — Slint shell. Slice 5: the 6-step modal skeleton
// (scrim + card + stepper + footer nav). Navigation is handled inline by
// mutating DacWizardState (open/close/next/back need no Rust). Step bodies are
// filled by later slices: welcome (here) · check (S6) · select-dacs (S7) ·
// review (S10) · test (S9) · done (S10). The wizard stays READ-ONLY — it never
// writes a system audio file.
//
// Modal recipe mirrors PlaylistImportModal: overlay Rectangle (not a window
// grab), so playback keeps running underneath while the test step plays.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { DacWizardState, DacWizardActions } from "../state.slint";
import { QbzIcon } from "QbzIcon.slint";
import { QbzPrimaryButton } from "QbzPrimaryButton.slint";
import { SecondaryButton } from "SecondaryButton.slint";
import { QbzCheckbox } from "QbzCheckbox.slint";
import { QbzSelect } from "QbzSelect.slint";
import { CommandBlock } from "CommandBlock.slint";
import { WarningBanner } from "WarningBanner.slint";
// Temporary titled placeholder for steps not yet built. Removed as each step
// lands (Slices 6/7/9/10).
component StepPlaceholder inherits VerticalLayout {
in property <string> title;
in property <string> note;
spacing: 10px;
Text {
text: root.title;
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
wrap: word-wrap;
}
Text {
text: root.note;
color: Theme.text-muted;
font-size: Typography.body;
wrap: word-wrap;
}
}
export component DacWizardModal inherits Rectangle {
visible: DacWizardState.open;
// Step labels for the header rail (index = DacWizardState.step).
property <[string]> steps: [
@tr("Welcome"),
@tr("Check"),
@tr("DACs"),
@tr("Configure"),
@tr("Test"),
@tr("Done"),
];
if DacWizardState.open: Rectangle {
background: #000000bf;
// Scrim — click outside closes.
TouchArea {
mouse-cursor: default;
clicked => {
DacWizardState.open = false;
}
}
card := Rectangle {
width: Math.min(root.width - 80px, 620px);
height: Math.min(Math.max(500px, body.preferred-height + 210px), root.height * 0.9);
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.lg;
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
// Swallow clicks so they never reach the scrim.
TouchArea { }
VerticalLayout {
padding: 0px;
spacing: 0px;
// Header: wand icon + title + close-x.
HorizontalLayout {
padding-left: 24px;
padding-right: 24px;
padding-top: 20px;
padding-bottom: 20px;
spacing: 10px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/circle-check-big.svg");
width: 24px;
height: 24px;
tint: #3fae6a;
}
}
Text {
text: @tr("HiFi Wizard — DAC Setup");
color: Theme.text-primary;
font-size: Typography.section;
font-weight: Typography.semibold;
horizontal-stretch: 1;
vertical-alignment: center;
}
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: pointer;
clicked => {
DacWizardState.open = false;
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
Rectangle { height: 1px; background: Theme.border-subtle; }
// Stepper rail — dots + labels, colored by progress.
HorizontalLayout {
padding-left: 24px;
padding-right: 24px;
padding-top: 14px;
padding-bottom: 14px;
spacing: 6px;
for label[idx] in root.steps: HorizontalLayout {
spacing: 6px;
horizontal-stretch: 1;
VerticalLayout {
alignment: center;
Rectangle {
width: 10px;
height: 10px;
border-radius: 5px;
background: idx <= DacWizardState.step ? #3fae6a : Theme.border-muted;
}
}
Text {
text: label;
color: idx == DacWizardState.step ? Theme.text-primary
: (idx < DacWizardState.step ? Theme.text-secondary : Theme.text-muted);
font-size: Typography.legal;
font-weight: idx == DacWizardState.step ? Typography.semibold : Typography.regular;
vertical-alignment: center;
overflow: elide;
horizontal-stretch: 1;
}
}
}
Rectangle { height: 1px; background: Theme.border-subtle; }
// Body — scrolls when a step outgrows the card.
Flickable {
vertical-stretch: 1;
viewport-width: self.width;
viewport-height: body.preferred-height;
body := VerticalLayout {
padding: 24px;
spacing: 16px;
alignment: start;
// ── Step 0: welcome ──────────────────────────────
if DacWizardState.step == 0: VerticalLayout {
spacing: 14px;
Text {
text: @tr("Guided DAC Setup");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
}
Text {
text: @tr("This wizard helps you configure your DAC for bit-perfect playback on Linux. QBZ never changes your system automatically — it auto-detects your DACs, shows you the exact commands and config to copy, and lets you test playback right here.");
color: Theme.text-secondary;
font-size: Typography.body;
wrap: word-wrap;
}
Text {
text: @tr("You are responsible for your own backups. This is a helper, not a system recovery tool.");
color: Theme.text-muted;
font-size: Typography.legal;
wrap: word-wrap;
}
HorizontalLayout {
spacing: 10px;
alignment: start;
// QbzCheckbox self-flips `checked` and emits
// toggled(); the two-way bind syncs the state, so
// no toggled handler (it would double-flip).
QbzCheckbox {
checked <=> DacWizardState.welcome-confirmed;
}
Text {
text: @tr("I understand and accept these terms");
color: Theme.text-secondary;
font-size: Typography.body;
vertical-alignment: center;
}
}
}
// ── Steps 1..5: placeholders (filled by later slices)
// ── Step 1: check audio stack ────────────────────
if DacWizardState.step == 1: VerticalLayout {
spacing: 14px;
Text {
text: @tr("Check Audio Stack");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
}
// Sandboxed (Flatpak/Snap): can't probe the host —
// show an info notice + reference commands instead.
if DacWizardState.sandboxed: WarningBanner {
variant: "info";
title: @tr("Sandboxed — host check unavailable");
body: @tr("QBZ is packaged as Flatpak/Snap and can't inspect your host audio stack. If playback already works, you're set. Pick your distribution and init system below for the right setup commands.");
}
if !DacWizardState.sandboxed && DacWizardState.health-ok: WarningBanner {
variant: "success";
title: @tr("Audio stack ready");
body: DacWizardState.health-summary;
}
if !DacWizardState.sandboxed && !DacWizardState.health-ok: WarningBanner {
variant: "warning";
title: @tr("Some packages are missing");
body: DacWizardState.health-summary;
}
// Distro — auto-detected, always overridable (Decision 4).
VerticalLayout {
spacing: 8px;
Text {
text: @tr("Your distribution");
color: Theme.text-secondary;
font-size: Typography.legal;
font-weight: Typography.medium;
}
QbzSelect {
options: DacWizardState.distro-options;
current-index: DacWizardState.distro-index;
menu-width: 360px;
selected(i) => {
DacWizardActions.set-distro(i);
}
}
}
// Init system — auto-detected at runtime; override to
// generate service commands for another machine.
VerticalLayout {
spacing: 8px;
Text {
text: @tr("Init system (service commands)");
color: Theme.text-secondary;
font-size: Typography.legal;
font-weight: Typography.medium;
}
QbzSelect {
options: DacWizardState.init-options;
current-index: DacWizardState.init-index;
menu-width: 240px;
selected(i) => {
DacWizardActions.set-init(i);
}
}
}
// One copy-paste fix per missing piece (empty when ready).
for r in DacWizardState.remediations: CommandBlock {
caption: r.caption;
command: r.command;
copy => {
DacWizardActions.copy-command(r.command);
}
}
}
if DacWizardState.step == 2: StepPlaceholder {
title: @tr("Which DACs do you want to configure?");
note: @tr("Auto-detected sink list with checkboxes — no manual node.name paste (Slice 7).");
}
if DacWizardState.step == 3: StepPlaceholder {
title: @tr("Review & Apply");
note: @tr("Backup, per-DAC sample rates, and the copy-paste config files (Slice 10).");
}
if DacWizardState.step == 4: StepPlaceholder {
title: @tr("Test Playback");
note: @tr("Plays tracks at 16/44.1, 24/44.1, 24/96 and 24/192 and reads the DAC's real negotiated rate (Slice 9).");
}
if DacWizardState.step == 5: StepPlaceholder {
title: @tr("All set");
note: @tr("Summary and the config paths you created (Slice 10).");
}
}
}
Rectangle { height: 1px; background: Theme.border-subtle; }
// Footer: Back · Close · primary (Start/Next/Finish).
HorizontalLayout {
padding-left: 24px;
padding-right: 24px;
padding-top: 16px;
padding-bottom: 20px;
spacing: 12px;
// Back — hidden on the first step.
if DacWizardState.step > 0: SecondaryButton {
label: @tr("Back");
clicked => {
DacWizardState.step -= 1;
}
}
Rectangle { horizontal-stretch: 1; }
SecondaryButton {
label: @tr("Close");
clicked => {
DacWizardState.open = false;
}
}
QbzPrimaryButton {
height: 34px;
label: DacWizardState.step == 0 ? @tr("Start")
: (DacWizardState.step == 5 ? @tr("Finish") : @tr("Next"));
// Step 0 gated on the accept checkbox; later gates added per slice.
enabled: DacWizardState.step == 0 ? DacWizardState.welcome-confirmed : true;
clicked => {
if (DacWizardState.step == 5) {
DacWizardState.open = false;
} else {
DacWizardState.step += 1;
}
}
}
}
}
}
}
}