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
This commit is contained in:
7 files changed
+449
-17
No files matched your search
@@ -0,0 +1,295 @@
|
||||
//! HiFi Wizard (DAC setup) controller.
|
||||
//!
|
||||
//! Slice 6 (check step): runs the frontend-agnostic audio-stack probes
|
||||
//! (`qbz_audio::health`) on open, maps them to per-distro copy-paste
|
||||
//! remediations the check step renders, and recomputes them when the user
|
||||
//! overrides the distro. Read-only — nothing here writes a system file or
|
||||
//! opens a stream.
|
||||
|
||||
use std::sync::Mutex;
|
||||
|
||||
use qbz_audio::{AudioStackHealth, Distro, InitSystem};
|
||||
use slint::{ComponentHandle, ModelRc, VecModel};
|
||||
|
||||
use crate::{AppWindow, DacWizardState, RemediationRow};
|
||||
|
||||
// Last probe result, so a distro override recomputes commands without
|
||||
// re-shelling on every dropdown change.
|
||||
static LAST_HEALTH: Mutex<Option<AudioStackHealth>> = Mutex::new(None);
|
||||
|
||||
/// Synchronous part of opening the wizard: reset, fill the distro dropdown
|
||||
/// (auto-detected, always overridable), and show a "checking…" state until the
|
||||
/// async probe lands.
|
||||
pub fn open_immediate(window: &AppWindow) {
|
||||
let st = window.global::<DacWizardState>();
|
||||
st.set_open(true);
|
||||
st.set_step(0);
|
||||
st.set_welcome_confirmed(false);
|
||||
|
||||
let distro_opts: Vec<slint::SharedString> =
|
||||
Distro::ALL.iter().map(|d| d.label().into()).collect();
|
||||
st.set_distro_options(ModelRc::new(VecModel::from(distro_opts)));
|
||||
st.set_distro_index(qbz_audio::detect_distro().index() as i32);
|
||||
|
||||
let init_opts: Vec<slint::SharedString> =
|
||||
InitSystem::ALL.iter().map(|i| i.label().into()).collect();
|
||||
st.set_init_options(ModelRc::new(VecModel::from(init_opts)));
|
||||
st.set_init_index(qbz_audio::detect_init().index() as i32);
|
||||
|
||||
let sandbox = qbz_audio::detect_sandbox();
|
||||
st.set_sandboxed(sandbox != qbz_audio::Sandbox::None);
|
||||
st.set_sandbox_name(
|
||||
match sandbox {
|
||||
qbz_audio::Sandbox::Flatpak => "Flatpak",
|
||||
qbz_audio::Sandbox::Snap => "Snap",
|
||||
qbz_audio::Sandbox::None => "",
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
st.set_health_ok(false);
|
||||
st.set_health_summary("Checking your audio stack…".into());
|
||||
st.set_remediations(ModelRc::new(VecModel::from(Vec::<RemediationRow>::new())));
|
||||
}
|
||||
|
||||
/// Apply a completed health probe: cache it and re-render from the current
|
||||
/// distro/init selections.
|
||||
pub fn apply_health(window: &AppWindow, health: AudioStackHealth) {
|
||||
*LAST_HEALTH.lock().unwrap() = Some(health);
|
||||
recompute(window);
|
||||
}
|
||||
|
||||
/// User overrode the distro (package manager) — recompute.
|
||||
pub fn set_distro(window: &AppWindow, index: i32) {
|
||||
window.global::<DacWizardState>().set_distro_index(index);
|
||||
recompute(window);
|
||||
}
|
||||
|
||||
/// User overrode the init system (service commands) — recompute.
|
||||
pub fn set_init(window: &AppWindow, index: i32) {
|
||||
window.global::<DacWizardState>().set_init_index(index);
|
||||
recompute(window);
|
||||
}
|
||||
|
||||
/// Rebuild the remediations from the cached probe + the current distro/init
|
||||
/// dropdown selections (either of which the user can override).
|
||||
fn recompute(window: &AppWindow) {
|
||||
let st = window.global::<DacWizardState>();
|
||||
let health = LAST_HEALTH
|
||||
.lock()
|
||||
.unwrap()
|
||||
.unwrap_or_else(qbz_audio::audio_stack_health);
|
||||
let distro = Distro::ALL
|
||||
.get(st.get_distro_index().max(0) as usize)
|
||||
.copied()
|
||||
.unwrap_or(Distro::Other);
|
||||
let init = InitSystem::ALL
|
||||
.get(st.get_init_index().max(0) as usize)
|
||||
.copied()
|
||||
.unwrap_or(InitSystem::Unknown);
|
||||
|
||||
// In a sandbox the host probes are blind, so don't render a health verdict —
|
||||
// show reference setup commands for the chosen distro/init (Tauri-style,
|
||||
// which never probed either). The UI shows a sandbox info banner instead.
|
||||
let rows = if st.get_sandboxed() {
|
||||
st.set_health_ok(false);
|
||||
st.set_health_summary("".into());
|
||||
reference_commands(distro, init)
|
||||
} else {
|
||||
let r = remediations(health, distro, init);
|
||||
st.set_health_ok(health.is_ready());
|
||||
st.set_health_summary(if health.is_ready() {
|
||||
"Your audio stack is ready for bit-perfect playback.".into()
|
||||
} else {
|
||||
let n = r.len();
|
||||
format!(
|
||||
"{} item{} need attention before bit-perfect playback will work.",
|
||||
n,
|
||||
if n == 1 { "" } else { "s" }
|
||||
)
|
||||
.into()
|
||||
});
|
||||
r
|
||||
};
|
||||
let model: Vec<RemediationRow> = rows
|
||||
.into_iter()
|
||||
.map(|(caption, command)| RemediationRow {
|
||||
caption: caption.into(),
|
||||
command: command.into(),
|
||||
})
|
||||
.collect();
|
||||
st.set_remediations(ModelRc::new(VecModel::from(model)));
|
||||
}
|
||||
|
||||
/// (caption, copy-paste command) per missing probe, for the given distro.
|
||||
///
|
||||
/// Service/restart commands are INIT-SYSTEM aware per distro (OpenRC on Gentoo,
|
||||
/// runit on Void, systemd elsewhere), mirroring the Tauri DistroSelector
|
||||
/// `restartCommands`. Installs and the restart are kept as separate blocks so
|
||||
/// the multi-line Gentoo guidance never gets `&&`-joined.
|
||||
fn remediations(h: AudioStackHealth, d: Distro, init: InitSystem) -> Vec<(String, String)> {
|
||||
// NixOS is declarative: you don't `apt/pacman install` pieces — you enable
|
||||
// the PipeWire module and rebuild. So collapse all the missing pieces into
|
||||
// one config block instead of per-package commands.
|
||||
if d == Distro::NixOS {
|
||||
if h.is_ready() {
|
||||
return Vec::new();
|
||||
}
|
||||
return vec![(
|
||||
"Enable PipeWire in your NixOS configuration".to_string(),
|
||||
NIXOS_PIPEWIRE_BLOCK.to_string(),
|
||||
)];
|
||||
}
|
||||
|
||||
let mut out = Vec::new();
|
||||
let mut needs_restart = false;
|
||||
if !h.has_pw_dump {
|
||||
out.push((
|
||||
"Install the PipeWire tools (pw-dump)".to_string(),
|
||||
install(d, pkg_pw_tools(d)),
|
||||
));
|
||||
needs_restart = true;
|
||||
}
|
||||
if !h.cpal_sees_pipewire {
|
||||
// THE Ubuntu no-list / no-playback bug: the ALSA->PipeWire bridge PCM.
|
||||
out.push((
|
||||
"Install the ALSA bridge so playback can reach PipeWire".to_string(),
|
||||
install(d, "pipewire-alsa"),
|
||||
));
|
||||
needs_restart = true;
|
||||
}
|
||||
if !h.has_pactl {
|
||||
out.push((
|
||||
"Install the Pulse compatibility tools (optional fallback)".to_string(),
|
||||
install(d, pkg_pulse(d)),
|
||||
));
|
||||
needs_restart = true;
|
||||
}
|
||||
if !h.any_devices {
|
||||
out.push((
|
||||
"No sinks detected — reinstall the ALSA UCM profiles, then reboot".to_string(),
|
||||
install_reinstall(d, "alsa-ucm-conf"),
|
||||
));
|
||||
}
|
||||
// WirePlumber down, or we just installed something → (re)start the stack
|
||||
// with the ACTUAL init system running on this machine (not guessed from the
|
||||
// distro — Gentoo+systemd and Gentoo+OpenRC must differ).
|
||||
if !h.wireplumber_active || needs_restart {
|
||||
out.push((
|
||||
"(Re)start the PipeWire audio services".to_string(),
|
||||
restart_cmd(init).to_string(),
|
||||
));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Init-system-aware "(re)start the audio services" command. PipeWire is a
|
||||
/// user-session service, so only systemd has a first-class `--user` restart;
|
||||
/// the others either use their user-service supervisor or a re-login.
|
||||
fn restart_cmd(init: InitSystem) -> &'static str {
|
||||
match init {
|
||||
InitSystem::Systemd => "systemctl --user restart pipewire pipewire-pulse wireplumber",
|
||||
InitSystem::OpenRc => {
|
||||
"# OpenRC: PipeWire runs in your user session, not as an OpenRC service.\n\
|
||||
# Log out and back in to restart it."
|
||||
}
|
||||
InitSystem::Runit => {
|
||||
"sv restart pipewire wireplumber # if set up as runit user services; otherwise log out and back in"
|
||||
}
|
||||
InitSystem::S6 => "# s6: restart via your supervision tree, or log out and back in",
|
||||
InitSystem::Dinit => "dinitctl restart pipewire wireplumber # or log out and back in",
|
||||
InitSystem::Unknown => "# Restart PipeWire via your init system, or log out and back in",
|
||||
}
|
||||
}
|
||||
|
||||
fn pkg_pw_tools(d: Distro) -> &'static str {
|
||||
match d {
|
||||
// Debian-family (incl. antiX) ship pw-* in pipewire-bin.
|
||||
Distro::Debian | Distro::Antix => "pipewire-bin",
|
||||
Distro::Fedora => "pipewire-utils",
|
||||
// Arch (incl. Artix) / openSUSE / Gentoo / Void ship pw-* with pipewire.
|
||||
_ => "pipewire",
|
||||
}
|
||||
}
|
||||
|
||||
fn pkg_pulse(d: Distro) -> &'static str {
|
||||
match d {
|
||||
Distro::Debian | Distro::Antix => "pipewire-pulse pulseaudio-utils",
|
||||
Distro::Fedora => "pipewire-pulseaudio",
|
||||
_ => "pipewire-pulse",
|
||||
}
|
||||
}
|
||||
|
||||
fn install(d: Distro, pkgs: &str) -> String {
|
||||
match d {
|
||||
// Package manager is a property of the distro family, NOT the init.
|
||||
Distro::Debian | Distro::Antix => format!("sudo apt install {pkgs}"),
|
||||
Distro::Fedora => format!("sudo dnf install {pkgs}"),
|
||||
Distro::Arch | Distro::Artix => format!("sudo pacman -S {pkgs}"),
|
||||
Distro::OpenSuse => format!("sudo zypper install {pkgs}"),
|
||||
Distro::Gentoo => format!("sudo emerge {pkgs} # package name may differ on Gentoo"),
|
||||
Distro::Void => format!("sudo xbps-install -S {pkgs}"),
|
||||
// NixOS is special-cased in remediations(); this is an unreached fallback.
|
||||
Distro::NixOS => format!("# NixOS: add to configuration.nix (see the PipeWire block) — {pkgs}"),
|
||||
Distro::Other => format!("Install with your package manager: {pkgs}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn install_reinstall(d: Distro, pkg: &str) -> String {
|
||||
match d {
|
||||
Distro::Debian | Distro::Antix => format!("sudo apt install --reinstall {pkg}"),
|
||||
Distro::Fedora => format!("sudo dnf reinstall {pkg}"),
|
||||
_ => install(d, pkg),
|
||||
}
|
||||
}
|
||||
|
||||
const NIXOS_PIPEWIRE_BLOCK: &str = "# /etc/nixos/configuration.nix:\n\
|
||||
services.pipewire = {\n\
|
||||
\u{20}\u{20}enable = true;\n\
|
||||
\u{20}\u{20}alsa.enable = true;\n\
|
||||
\u{20}\u{20}pulse.enable = true;\n\
|
||||
\u{20}\u{20}wireplumber.enable = true;\n\
|
||||
};\n\
|
||||
# then apply:\n\
|
||||
sudo nixos-rebuild switch";
|
||||
|
||||
/// Full reference setup commands for the chosen distro/init, shown when QBZ
|
||||
/// can't probe the host (sandbox). Mirrors the Tauri DistroSelector, which
|
||||
/// always showed per-distro install + restart commands (no probing).
|
||||
fn reference_commands(d: Distro, init: InitSystem) -> Vec<(String, String)> {
|
||||
if d == Distro::NixOS {
|
||||
return vec![(
|
||||
"Enable PipeWire in your NixOS configuration".to_string(),
|
||||
NIXOS_PIPEWIRE_BLOCK.to_string(),
|
||||
)];
|
||||
}
|
||||
vec![
|
||||
(
|
||||
"Install the PipeWire audio stack".to_string(),
|
||||
install(d, full_stack_pkgs(d)),
|
||||
),
|
||||
(
|
||||
"(Re)start the PipeWire audio services".to_string(),
|
||||
restart_cmd(init).to_string(),
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// The full recommended package set (incl. `pipewire-alsa`, the bit the old
|
||||
/// Tauri list omitted — the cause of the Ubuntu empty-list bug).
|
||||
fn full_stack_pkgs(d: Distro) -> &'static str {
|
||||
match d {
|
||||
Distro::Debian | Distro::Antix => {
|
||||
"pipewire pipewire-pulse pipewire-alsa wireplumber alsa-utils"
|
||||
}
|
||||
Distro::Fedora => "pipewire pipewire-pulseaudio pipewire-alsa wireplumber alsa-utils",
|
||||
Distro::Arch | Distro::Artix => {
|
||||
"pipewire pipewire-pulse pipewire-alsa wireplumber alsa-utils"
|
||||
}
|
||||
Distro::OpenSuse => "pipewire pipewire-pulseaudio pipewire-alsa wireplumber alsa-utils",
|
||||
Distro::Gentoo => "media-video/pipewire media-video/wireplumber media-sound/alsa-utils",
|
||||
Distro::Void => "pipewire wireplumber alsa-utils",
|
||||
Distro::NixOS => "",
|
||||
Distro::Other => "pipewire pipewire-pulse wireplumber alsa-utils",
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ mod favorites;
|
||||
mod favorites_prefs;
|
||||
mod foryou;
|
||||
mod genre_filter;
|
||||
mod dac_wizard;
|
||||
mod home;
|
||||
mod immersive;
|
||||
mod info_modals;
|
||||
@@ -11308,6 +11309,51 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
});
|
||||
}
|
||||
|
||||
// ---- HiFi Wizard (DAC setup) — Slice 6 (check step) ----
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let handle = tokio_rt.handle().clone();
|
||||
window.global::<DacWizardActions>().on_open(move || {
|
||||
let Some(w) = weak.upgrade() else {
|
||||
return;
|
||||
};
|
||||
dac_wizard::open_immediate(&w);
|
||||
// Probe the audio stack off the UI thread; fill the check step when done.
|
||||
let weak2 = w.as_weak();
|
||||
handle.spawn_blocking(move || {
|
||||
let health = qbz_audio::audio_stack_health();
|
||||
let _ = weak2.upgrade_in_event_loop(move |w| {
|
||||
dac_wizard::apply_health(&w, health);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
window
|
||||
.global::<DacWizardActions>()
|
||||
.on_set_distro(move |index| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
dac_wizard::set_distro(&w, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
window.global::<DacWizardActions>().on_set_init(move |index| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
dac_wizard::set_init(&w, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
{
|
||||
window
|
||||
.global::<DacWizardActions>()
|
||||
.on_copy_command(move |cmd| {
|
||||
share::copy_to_clipboard(cmd.to_string());
|
||||
});
|
||||
}
|
||||
|
||||
// ---- Playlist Importer (public playlists) — spec §3.3 ----
|
||||
{
|
||||
// No cancel exists: a running import task continues to completion
|
||||
|
||||
@@ -19,7 +19,7 @@ import { Toast } from "primitives/Toast.slint";
|
||||
import { ShellState } from "state.slint";
|
||||
|
||||
// Re-export the state globals so the Rust layer can populate them.
|
||||
export { HomeState, HomeActions, DiscoverState, DiscoverActions, SectionDescriptor, ConfigRow, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, DuplicateConfirmState, DuplicateConfirmActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions, ImportLogEntry, PlaylistImportState, PlaylistImportActions, DacWizardState, DacWizardActions, DacCandidateRow, InfoCreditRow, InfoCreditPair, AlbumCreditPerformer, AlbumCreditTrack, TrackInfoState, TrackInfoActions, AlbumInfoState, AlbumInfoActions, VisualizerState, ImmersiveState } from "state.slint";
|
||||
export { HomeState, HomeActions, DiscoverState, DiscoverActions, SectionDescriptor, ConfigRow, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, DuplicateConfirmState, DuplicateConfirmActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions, ImportLogEntry, PlaylistImportState, PlaylistImportActions, DacWizardState, DacWizardActions, DacCandidateRow, RemediationRow, InfoCreditRow, InfoCreditPair, AlbumCreditPerformer, AlbumCreditTrack, TrackInfoState, TrackInfoActions, AlbumInfoState, AlbumInfoActions, VisualizerState, ImmersiveState } from "state.slint";
|
||||
|
||||
// Which top-level screen is shown. The app starts on `splash` while it
|
||||
// restores a saved session, then resolves to `shell` or `login`.
|
||||
|
||||
@@ -11,11 +11,14 @@
|
||||
import { Theme } from "../foundation/semantic-colors.slint";
|
||||
import { Typography } from "../foundation/typography.slint";
|
||||
import { Radius } from "../foundation/radius.slint";
|
||||
import { DacWizardState } from "../state.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).
|
||||
@@ -206,9 +209,77 @@ export component DacWizardModal inherits Rectangle {
|
||||
}
|
||||
|
||||
// ── Steps 1..5: placeholders (filled by later slices)
|
||||
if DacWizardState.step == 1: StepPlaceholder {
|
||||
title: @tr("Check Audio Stack");
|
||||
note: @tr("Auto-probes PipeWire / WirePlumber and surfaces only the packages you are missing (Slice 6).");
|
||||
// ── 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?");
|
||||
|
||||
@@ -11,19 +11,24 @@ import { QbzIcon } from "QbzIcon.slint";
|
||||
export component WarningBanner inherits Rectangle {
|
||||
in property <string> title: "";
|
||||
in property <string> body: "";
|
||||
in property <string> variant: "warning";
|
||||
in property <string> variant: "warning"; // info | warning | error | success
|
||||
|
||||
property <color> tone: root.variant == "error" ? #ef4444
|
||||
: (root.variant == "info" ? #3b82f6 : #eab308);
|
||||
: (root.variant == "info" ? #3b82f6
|
||||
: (root.variant == "success" ? #3fae6a : #eab308));
|
||||
property <color> bg: root.variant == "error" ? #ef44441a
|
||||
: (root.variant == "info" ? #3b82f61a : #eab3081a);
|
||||
: (root.variant == "info" ? #3b82f61a
|
||||
: (root.variant == "success" ? #3fae6a1a : #eab3081a));
|
||||
property <color> brd: root.variant == "error" ? #ef44444d
|
||||
: (root.variant == "info" ? #3b82f64d : #eab3084d);
|
||||
: (root.variant == "info" ? #3b82f64d
|
||||
: (root.variant == "success" ? #3fae6a4d : #eab3084d));
|
||||
property <image> glyph: root.variant == "error"
|
||||
? @image-url("../assets/icons/circle-alert.svg")
|
||||
: (root.variant == "info"
|
||||
? @image-url("../assets/icons/info.svg")
|
||||
: @image-url("../assets/icons/triangle-alert.svg"));
|
||||
: (root.variant == "success"
|
||||
? @image-url("../assets/icons/circle-check-big.svg")
|
||||
: @image-url("../assets/icons/triangle-alert.svg")));
|
||||
|
||||
border-radius: 8px;
|
||||
background: root.bg;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { Theme } from "../foundation/semantic-colors.slint";
|
||||
import { Typography } from "../foundation/typography.slint";
|
||||
import { Radius } from "../foundation/radius.slint";
|
||||
import { SettingsState, DacWizardState } from "../state.slint";
|
||||
import { SettingsState, DacWizardActions } from "../state.slint";
|
||||
import { QbzToggle } from "../primitives/QbzToggle.slint";
|
||||
import { QbzSelect } from "../primitives/QbzSelect.slint";
|
||||
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||||
@@ -292,9 +292,7 @@ export component AudioSettings inherits VerticalLayout {
|
||||
wizard-ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
DacWizardState.open = true;
|
||||
DacWizardState.step = 0;
|
||||
DacWizardState.welcome-confirmed = false;
|
||||
DacWizardActions.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3859,6 +3859,12 @@ export global PlaylistImportActions {
|
||||
// auto-detects DACs (pw-dump, Slice 0), generates copy-paste config, and runs
|
||||
// an in-app playback test reading the real negotiated rate (N6, Slice 8b).
|
||||
|
||||
// A "you're missing X" fix for the check step: a caption + a copy-paste command.
|
||||
export struct RemediationRow {
|
||||
caption: string,
|
||||
command: string,
|
||||
}
|
||||
|
||||
// One enumerated sink the user can pick to configure.
|
||||
export struct DacCandidateRow {
|
||||
id: string, // PipeWire node.name (the value the user used to paste)
|
||||
@@ -3878,11 +3884,19 @@ export global DacWizardState {
|
||||
// welcome
|
||||
in-out property <bool> welcome-confirmed: false;
|
||||
|
||||
// check (Slice 6): distro auto-detected, override always visible (Decision 4)
|
||||
// check (Slice 6): distro + init both auto-detected, both overridable
|
||||
// (distro → package manager, init → service commands; they're orthogonal).
|
||||
in-out property <[string]> distro-options: [];
|
||||
in-out property <int> distro-index: 0;
|
||||
in-out property <[string]> init-options: [];
|
||||
in-out property <int> init-index: 0;
|
||||
in-out property <bool> health-ok: false;
|
||||
in-out property <string> health-summary: "";
|
||||
in-out property <[RemediationRow]> remediations: [];
|
||||
// In a Flatpak/Snap sandbox QBZ can't inspect the host stack, so it shows
|
||||
// reference setup commands + an info notice instead of a health verdict.
|
||||
in-out property <bool> sandboxed: false;
|
||||
in-out property <string> sandbox-name: "";
|
||||
|
||||
// select-dacs (Slice 7)
|
||||
in-out property <[DacCandidateRow]> candidates: [];
|
||||
@@ -3898,8 +3912,11 @@ export global DacWizardState {
|
||||
}
|
||||
|
||||
export global DacWizardActions {
|
||||
// Wired in Rust from Slice 6 onward (crate::dac_wizard); navigation
|
||||
// (open/close/next/back) is handled inline in the modal via state mutation.
|
||||
// Wired in Rust (crate::dac_wizard); plain step nav (back/close) stays
|
||||
// inline in the modal via state mutation.
|
||||
callback open(); // open + detect distro/init + run health probe
|
||||
callback set-distro(int); // recompute remediations for the chosen distro
|
||||
callback set-init(int); // recompute service commands for the chosen init
|
||||
callback copy-command(string); // → crate::share::copy_to_clipboard
|
||||
callback run-detect(); // enumerate sinks → candidates (Slice 7)
|
||||
callback query-caps(string); // probe one DAC's rates (Slice 7)
|
||||
|
||||
Reference in new issue
Block a user