feat(qt): the Wallpaper background's blur is the user's to set

The Wallpaper background blurred the desktop behind the window by a fixed
0.75. Its options box in Settings > Appearance now has a Wallpaper blur
slider, shown for that mode only, from 0 % to 100 %: Qt's documented range
for MultiEffect.blur, 0.0 (no blur) to 1.0 (full blur), at the field's
blurMax of 64. The default stays 0.75, the look the mode shipped with.

Dragging moves the live background through QbzShell.wallpaperBlur; the
value is written to ui_prefs once, on release (the slider's `released`),
as a two-decimal number, and clamped to Qt's range on read. The Wallpaper,
blurred mode keeps its fixed atmosphere look.

The label and description are in all eight catalogs.

cc
This commit is contained in:
vicrodh committed 2026-09-14 13:08:37 -06:00
1 parent 7ca6c9fa80
commit cca779924d
12 files changed
+157 -1

No files matched your search

@@ -293,6 +293,35 @@ Column {
}
}
}
// Wallpaper mode only: how blurred the X-ray view of the desktop is.
// Qt's own range for MultiEffect.blur, 0.0-1.0, shown as 0-100 %; the
// default is the 0.75 the mode shipped with (settings_qt.rs). The drag
// moves the live background; the value is stored on release.
SettingRow { kioskHost: root.kioskHost;
visible: root.backgroundIndex === 3
label: QbzSession.tr("Wallpaper blur", QbzSession.trRev)
description: QbzSession.tr("How much the wallpaper behind the window is blurred: 0% keeps it sharp, 100% is the strongest blur.", QbzSession.trRev)
Row {
spacing: 12
QbzSlider { kioskHost: root.kioskHost;
id: wallpaperBlurSlider
anchors.verticalCenter: parent.verticalCenter
minimum: 0
maximum: 100
value: Math.round(QbzShell.wallpaperBlur * 100)
onChanged: function (v) { QbzShell.wallpaperBlur = v / 100 }
onReleased: function (v) { QbzBridge.settingsSlider("wallpaper-blur", v) }
}
Text {
anchors.verticalCenter: parent.verticalCenter
width: 40
horizontalAlignment: Text.AlignRight
text: wallpaperBlurSlider.value + "%"
color: theme.textSecondary
font.pixelSize: root.kioskHost ? theme.fontBody * 1.2 : theme.fontBody
}
}
}
}
SettingsSpacer { }
+3 -1
View File
@@ -140,7 +140,9 @@ Rectangle {
visible: root.wallpaperModeOn
source: root.wallpaperModeOn ? QbzShell.wallpaperUrl : ""
hostWindow: root.hostWindow
blur: 0.75
// The user's choice (Settings > Appearance, 0-100 % of Qt's 0.0-1.0),
// live while that slider drags; 0.75 by default.
blur: QbzShell.wallpaperBlur
dim: theme.isDark ? QbzShell.ambientDim : 0.0
}
Rectangle {
+55
View File
@@ -665,6 +665,30 @@ pub fn app_background_mode() -> i32 {
.unwrap_or(0) as i32
}
/// The Wallpaper mode's blur, in MultiEffect's own units: Qt documents
/// `blur` from 0.0 (no blur) to 1.0 (full blur), reached at the field's
/// `blurMax` of 64 (shell/WallpaperField.qml). 0.75 is the look the mode
/// shipped with and stays the default; Settings > Appearance edits it as
/// 0-100 %.
pub const WALLPAPER_BLUR_DEFAULT: f32 = 0.75;
pub fn wallpaper_blur() -> f32 {
clamp_wallpaper_blur(pref_f32("wallpaper_blur", WALLPAPER_BLUR_DEFAULT))
}
/// Qt's range, whatever a hand-edited ui_prefs.json holds; NaN is the default.
fn clamp_wallpaper_blur(value: f32) -> f32 {
if value.is_nan() {
return WALLPAPER_BLUR_DEFAULT;
}
value.clamp(0.0, 1.0)
}
/// The Settings slider's 0-100 % step as the stored Qt value.
fn wallpaper_blur_from_percent(percent: i32) -> f32 {
percent.clamp(0, 100) as f32 / 100.0
}
/// Live-tuning knobs (Slint AppearanceState defaults; the QBZ_BG_* envs are
/// the same dev knobs the Slint seeds at startup).
pub fn ambient_dim() -> f32 {
@@ -4434,6 +4458,15 @@ pub async fn settings_select(runtime: &Arc<AppRuntime<LoggingAdapter>>, key: &st
}
pub async fn settings_slider(runtime: &Arc<AppRuntime<LoggingAdapter>>, key: &str, value: i32) {
if key == "wallpaper-blur" {
// Persisted on the slider's release; the drag itself already moved
// QbzShell.wallpaperBlur for the live preview.
let blur = wallpaper_blur_from_percent(value);
// Written from the whole percent as f64: an f32 widened on the way to
// JSON would store 0.62 as 0.6200000047683716.
save_pref("wallpaper_blur", serde_json::json!(f64::from(value.clamp(0, 100)) / 100.0));
crate::shell_bridge::ui(move |mut b| b.as_mut().set_wallpaper_blur(blur));
}
if key == "buffer-seconds" {
let seconds = value.clamp(1, 10) as u8;
match with_audio(|s| s.set_stream_buffer_seconds(seconds)) {
@@ -4907,6 +4940,28 @@ mod local_tab_order_tests {
}
}
#[cfg(test)]
mod wallpaper_blur_tests {
use super::*;
#[test]
fn the_slider_percent_maps_onto_qts_blur_range() {
assert_eq!(wallpaper_blur_from_percent(0), 0.0);
assert_eq!(wallpaper_blur_from_percent(75), 0.75);
assert_eq!(wallpaper_blur_from_percent(100), 1.0);
assert_eq!(wallpaper_blur_from_percent(-20), 0.0);
assert_eq!(wallpaper_blur_from_percent(250), 1.0);
}
#[test]
fn a_hand_edited_value_is_held_to_qts_range() {
assert_eq!(clamp_wallpaper_blur(1.7), 1.0);
assert_eq!(clamp_wallpaper_blur(-0.2), 0.0);
assert_eq!(clamp_wallpaper_blur(0.4), 0.4);
assert_eq!(clamp_wallpaper_blur(f32::NAN), WALLPAPER_BLUR_DEFAULT);
}
}
#[cfg(test)]
mod theme_fieldset_doc_tests {
use super::*;
+6
View File
@@ -346,6 +346,10 @@ pub mod qbz_shell {
#[qproperty(QString, ambient_accent)]
// Look knobs (Slint AppearanceState defaults; QBZ_BG_* env seed).
#[qproperty(f32, ambient_dim)]
/// The Wallpaper mode's blur, MultiEffect units 0.0-1.0
/// (settings_qt::wallpaper_blur). Settings writes it while the slider
/// drags, for a live preview, and persists it on release.
#[qproperty(f32, wallpaper_blur)]
/// Debug knob QBZ_BG_SCALE — RETIRED 2026-08-13: the ambient field
/// renders inline now (no offscreen target to scale), and the knob
/// measured as a non-lever anyway. Kept to avoid bridge churn.
@@ -923,6 +927,7 @@ pub struct QbzShellRust {
ambient_secondary: QString,
ambient_accent: QString,
ambient_dim: f32,
wallpaper_blur: f32,
ambient_scale: f32,
viz_tick_ms: i32,
pane_layer: bool,
@@ -1043,6 +1048,7 @@ impl Default for QbzShellRust {
ambient_secondary: QString::from("#9632ff"),
ambient_accent: QString::from("#3fd9c8"),
ambient_dim: crate::settings_qt::ambient_dim(),
wallpaper_blur: crate::settings_qt::wallpaper_blur(),
ambient_scale: crate::settings_qt::ambient_scale(),
viz_tick_ms: crate::settings_qt::viz_tick_ms(),
pane_layer: crate::settings_qt::pane_layer(),