From 87cf74764c0bd68fc4eeba84b0b6c2bf5130de45 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Tue, 19 May 2026 00:03:06 -0600 Subject: [PATCH] fix(slint): correct BP marking and widen the output-device list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The BP badge marked every ALSA device; it now marks only the direct hardware PCMs (hw:/front:/iec958:/hdmi:), matching Tauri — sysdefault and plug devices are not bit-perfect. The device list also opens at 480px (right-anchored) so the full card + PCM id name is readable instead of being elided in a 300px control. cc --- crates/qbz-slint/src/settings.rs | 16 ++++++++++++---- crates/qbz-slint/ui/primitives/QbzSelect.slint | 13 +++++++++++-- crates/qbz-slint/ui/settings/AudioSettings.slint | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/crates/qbz-slint/src/settings.rs b/crates/qbz-slint/src/settings.rs index 67fd5b1ff..d812e913d 100644 --- a/crates/qbz-slint/src/settings.rs +++ b/crates/qbz-slint/src/settings.rs @@ -156,12 +156,20 @@ struct DeviceList { bp: Vec, } -/// Whether a device can deliver bit-perfect playback on `backend`. ALSA -/// enumerates real `hw:` cards (always capable); PipeWire reports a -/// hardware flag per node; PulseAudio always mixes, so never capable. +/// Whether a device can deliver bit-perfect playback on `backend`. On +/// ALSA only the direct-hardware PCMs qualify (`hw:` / `front:` and the +/// digital `iec958:` / `hdmi:`) — `sysdefault:`, `plughw:` and friends +/// route through converting plugins. PipeWire reports a hardware flag +/// per node; PulseAudio always mixes, so never capable. fn device_is_bit_perfect(backend: AudioBackendType, device: &qbz_audio::AudioDevice) -> bool { match backend { - AudioBackendType::Alsa => true, + AudioBackendType::Alsa => { + let id = device.id.to_ascii_lowercase(); + id.starts_with("hw:") + || id.starts_with("front:") + || id.starts_with("iec958:") + || id.starts_with("hdmi:") + } AudioBackendType::PipeWire => device.is_hardware, AudioBackendType::Pulse | AudioBackendType::SystemDefault => false, } diff --git a/crates/qbz-slint/ui/primitives/QbzSelect.slint b/crates/qbz-slint/ui/primitives/QbzSelect.slint index d6e2498d4..362ff29d2 100644 --- a/crates/qbz-slint/ui/primitives/QbzSelect.slint +++ b/crates/qbz-slint/ui/primitives/QbzSelect.slint @@ -27,9 +27,16 @@ export component QbzSelect inherits Rectangle { in property <[bool]> badges: []; in property current-index: 0; in property menu-width: 240px; + // Optional: a wider open list than the collapsed control, for long + // option labels (device names). 0px keeps the list at `menu-width`. + in property popup-width: 0px; in property enabled: true; callback selected(int); + // Resolved width of the open list. + private property list-width: + root.popup-width > root.menu-width ? root.popup-width : root.menu-width; + width: root.menu-width; height: 34px; border-radius: Radius.sm; @@ -79,9 +86,11 @@ export component QbzSelect inherits Rectangle { } popup := PopupWindow { - x: 0; + // Right-anchored so a list wider than the control grows leftward + // and stays on-screen. + x: root.menu-width - root.list-width; y: root.height + 4px; - width: root.menu-width; + width: root.list-width; height: root.options.length * 32px + 10px; Rectangle { diff --git a/crates/qbz-slint/ui/settings/AudioSettings.slint b/crates/qbz-slint/ui/settings/AudioSettings.slint index b9cd27207..e1c9bdc26 100644 --- a/crates/qbz-slint/ui/settings/AudioSettings.slint +++ b/crates/qbz-slint/ui/settings/AudioSettings.slint @@ -95,6 +95,9 @@ export component AudioSettings inherits VerticalLayout { description: @tr("The DAC or sound device that receives audio."); QbzSelect { menu-width: 300px; + // Device labels run long; open the list wider so the full + // name (card + ALSA PCM id) is readable. + popup-width: 480px; options: SettingsState.devices; badges: SettingsState.device-bp; current-index: SettingsState.device-index;