feat(slint): wire album header backdrop setting

Persist the existing appearance toggle in ui_prefs and use it to enable or disable the album and artist header blur backdrops.

cx
This commit is contained in:
vicrodh committed 2026-06-16 16:17:36 -06:00
1 parent a274e602ec
commit a4cba30fcf
5 files changed
+31 -13

No files matched your search

+8
View File
@@ -3982,6 +3982,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
window
.global::<ShellState>()
.set_npb_mode(crate::ui_prefs::npb_mode_index(&crate::ui_prefs::load().npb_mode));
window
.global::<AppearanceState>()
.set_album_header_gradient(crate::ui_prefs::load().album_header_gradient);
// Tell the tray settings UI which platform it's on so it can show the
// macOS-only controls ("Menu Bar" header, hide-Dock toggle) and hide the
@@ -4882,6 +4885,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
{
let appearance = window.global::<AppearanceState>();
appearance.on_appearance_bool(|key, value| match key.as_str() {
"album-header-gradient" => {
let mut prefs = crate::ui_prefs::load();
prefs.album_header_gradient = value;
crate::ui_prefs::save(&prefs);
}
"tray-enable" => tray_settings::set_enable_tray(value),
"tray-minimize-to-tray" => tray_settings::set_minimize_to_tray(value),
"tray-close-to-tray" => tray_settings::set_close_to_tray(value),
+12
View File
@@ -37,6 +37,9 @@ pub const DEFAULT_STREAMING_QUALITY: &str = "hires_plus";
/// Default now-playing bar layout key (`New`).
pub const DEFAULT_NPB_MODE: &str = "new";
/// Default album/artist header backdrop setting.
pub const DEFAULT_ALBUM_HEADER_GRADIENT: bool = true;
/// Persisted UI preferences. New fields must default sanely so an older
/// file (missing the field) still deserializes.
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -48,6 +51,9 @@ pub struct UiPrefs {
/// `ShellState.npb-mode` (0 / 1 / 2).
#[serde(default = "default_npb_mode")]
pub npb_mode: String,
/// Whether album/artist detail headers use artwork-derived backdrops.
#[serde(default = "default_album_header_gradient")]
pub album_header_gradient: bool,
}
fn default_streaming_quality() -> String {
@@ -58,11 +64,16 @@ fn default_npb_mode() -> String {
DEFAULT_NPB_MODE.to_string()
}
fn default_album_header_gradient() -> bool {
DEFAULT_ALBUM_HEADER_GRADIENT
}
impl Default for UiPrefs {
fn default() -> Self {
Self {
streaming_quality: default_streaming_quality(),
npb_mode: default_npb_mode(),
album_header_gradient: default_album_header_gradient(),
}
}
}
@@ -156,5 +167,6 @@ mod tests {
fn legacy_json_without_field_deserializes() {
let prefs: UiPrefs = serde_json::from_str("{}").expect("empty object deserializes");
assert_eq!(prefs.streaming_quality, "hires_plus");
assert!(prefs.album_header_gradient);
}
}