diff --git a/crates/qbz-slint/src/main.rs b/crates/qbz-slint/src/main.rs index 4c1b6c9d8..84e44317e 100644 --- a/crates/qbz-slint/src/main.rs +++ b/crates/qbz-slint/src/main.rs @@ -5154,6 +5154,16 @@ fn main() -> Result<(), Box> { window .global::() .set_intelligent_search(crate::ui_prefs::load().intelligent_search); + // Purchases opt-in nav visibility + title-bar placement (both default OFF). + // Seeded here from the persisted prefs so the sidebar / header entries + // reflect the user's choice on startup (the Slint equivalent of Tauri's + // rehydrate-after-login: ui_prefs is read once the session/window is up). + { + let prefs = crate::ui_prefs::load(); + let appearance = window.global::(); + appearance.set_show_purchases(prefs.show_purchases); + appearance.set_nav_tb_purchases(prefs.nav_tb_purchases); + } window.global::().set_immersive_search_action_index( crate::ui_prefs::immersive_search_action_index( &crate::ui_prefs::load().immersive_search_action, @@ -7218,6 +7228,22 @@ fn main() -> Result<(), Box> { "tray-minimize-to-tray" => tray_settings::set_minimize_to_tray(value), "tray-close-to-tray" => tray_settings::set_close_to_tray(value), "tray-mac-hide-dock" => tray_settings::set_mac_hide_dock(value), + "show-purchases" => { + // Opt-in Purchases nav visibility (default OFF). The bound + // `AppearanceState.show-purchases` property was already flipped + // by the toggle, so the sidebar / header entries update live; + // here we only persist the choice so it survives restart. + let mut prefs = crate::ui_prefs::load(); + prefs.show_purchases = value; + crate::ui_prefs::save(&prefs); + } + "nav-tb-purchases" => { + // Purchases title-bar placement (default OFF). Persist only — + // the live flag is already on `AppearanceState.nav-tb-purchases`. + let mut prefs = crate::ui_prefs::load(); + prefs.nav_tb_purchases = value; + crate::ui_prefs::save(&prefs); + } other => log::debug!("[qbz-slint] unhandled appearance-bool '{other}'"), }); let theme_weak = window.as_weak(); diff --git a/crates/qbz-slint/src/ui_prefs.rs b/crates/qbz-slint/src/ui_prefs.rs index 0b54b013e..ce4ee1412 100644 --- a/crates/qbz-slint/src/ui_prefs.rs +++ b/crates/qbz-slint/src/ui_prefs.rs @@ -244,6 +244,18 @@ pub struct UiPrefs { /// per-machine app preference — your Discord client is per-machine.) #[serde(default)] pub discord_rpc_enabled: bool, + /// Show the opt-in "Purchases" navigation entry (sidebar / header). Default + /// OFF — the whole DRM-free Purchases feature is hidden until the user + /// enables it (mirrors Tauri `showPurchases`, default `false`). Re-seeded + /// into `AppearanceState.show-purchases` at startup; persisted on toggle. + #[serde(default)] + pub show_purchases: bool, + /// Place the Purchases nav entry in the custom title bar instead of the + /// sidebar. Default OFF (mirrors Tauri `purchasesInTitlebar`, default + /// `false`). Only meaningful when the custom title bar is shown; the toggle + /// is disabled in Settings when the title bar is hidden / system-native. + #[serde(default)] + pub nav_tb_purchases: bool, /// Three-state sidebar: 0 open / 1 mini / 2 closed. Restored at startup. #[serde(default)] pub sidebar_state: i32, @@ -395,6 +407,8 @@ impl Default for UiPrefs { intelligent_search: default_intelligent_search(), system_notifications: default_system_notifications(), discord_rpc_enabled: false, + show_purchases: false, + nav_tb_purchases: false, sidebar_state: 0, nav_in_sidebar: default_nav_in_sidebar(), volume: default_volume(), diff --git a/crates/qbz-slint/ui/settings/AppearanceSettings.slint b/crates/qbz-slint/ui/settings/AppearanceSettings.slint index 7242133a6..5012641a3 100644 --- a/crates/qbz-slint/ui/settings/AppearanceSettings.slint +++ b/crates/qbz-slint/ui/settings/AppearanceSettings.slint @@ -607,7 +607,6 @@ export component AppearanceSettings inherits VerticalLayout { } } SettingRow { - unsupported: true; label: @tr("Show Purchases"); description: @tr("Show the Purchases section in the sidebar for browsing and downloading your purchased music"); QbzToggle { @@ -618,6 +617,23 @@ export component AppearanceSettings inherits VerticalLayout { } } } + // Purchases title-bar placement — moves the Purchases nav entry into the + // custom title bar instead of the sidebar (mirrors Tauri `purchasesInTitlebar`, + // default OFF). Disabled when the custom title bar is hidden or the system + // title bar is in use (no custom title bar to place it in). + SettingRow { + label: @tr("Purchases in title bar"); + description: @tr("Place the Purchases entry in the custom title bar instead of the sidebar"); + enabled: !root.tb-locked; + QbzToggle { + checked: AppearanceState.nav-tb-purchases; + enabled: !root.tb-locked; + toggled(v) => { + AppearanceState.nav-tb-purchases = v; + AppearanceState.appearance-bool("nav-tb-purchases", v); + } + } + } Rectangle { height: 12px; } Divider { } diff --git a/crates/qbz-slint/ui/shell/HeaderBar.slint b/crates/qbz-slint/ui/shell/HeaderBar.slint index e77261f93..69486587e 100644 --- a/crates/qbz-slint/ui/shell/HeaderBar.slint +++ b/crates/qbz-slint/ui/shell/HeaderBar.slint @@ -828,7 +828,14 @@ export component HeaderBar inherits Rectangle { } // Purchases — opt-in (default OFF). DIRECT tab (no dropdown), active // for both the list + per-album detail views. HIDDEN while offline. - if AppearanceState.show-purchases && !OfflineState.offline: VerticalLayout { + // Titlebar-placement (§5.8 truth table): the title bar hosts the + // entry iff `S && T && TB` — only when the user enabled "Purchases + // in title bar" (`nav-tb-purchases`) AND the custom title bar is + // actually shown. Otherwise it stays in the sidebar (Sidebar.slint). + if AppearanceState.show-purchases && !OfflineState.offline + && AppearanceState.nav-tb-purchases + && !AppearanceState.hide-title-bar + && !AppearanceState.use-system-title-bar: VerticalLayout { alignment: center; NavTab { icon: @image-url("../assets/icons/shopping-bag.svg"); @@ -908,7 +915,12 @@ export component HeaderBar inherits Rectangle { } } // Purchases — opt-in (default OFF). DIRECT button. HIDDEN offline. - if AppearanceState.show-purchases && !OfflineState.offline: VerticalLayout { + // Titlebar-placement (§5.8 truth table): shown in the header iff + // `S && T && TB` — same gate as the full-nav tab above. + if AppearanceState.show-purchases && !OfflineState.offline + && AppearanceState.nav-tb-purchases + && !AppearanceState.hide-title-bar + && !AppearanceState.use-system-title-bar: VerticalLayout { alignment: center; CompactDirectBtn { icon: @image-url("../assets/icons/shopping-bag.svg"); diff --git a/crates/qbz-slint/ui/shell/Sidebar.slint b/crates/qbz-slint/ui/shell/Sidebar.slint index d2c115150..3402465d6 100644 --- a/crates/qbz-slint/ui/shell/Sidebar.slint +++ b/crates/qbz-slint/ui/shell/Sidebar.slint @@ -757,7 +757,16 @@ export component Sidebar inherits Rectangle { // destination (no tab dropdown). HIDDEN entirely while offline (the // surface needs the Qobuz session). Active for both the list view // and the per-album detail view (§5.3 / §8.6 gating). - if AppearanceState.show-purchases && !OfflineState.offline: SidebarDirectRow { + // Titlebar-placement (§5.8 truth table): the sidebar hosts the entry + // iff `S && !(T && TB)` — when the user enables "Purchases in title + // bar" (`nav-tb-purchases`) AND the custom title bar is actually + // shown, the entry MOVES to the header (HeaderBar.slint) and is + // hidden here. `TB = showTitleBar` = custom titlebar present + // (mirrors AppearanceSettings `tb-locked`, inverted). + if AppearanceState.show-purchases && !OfflineState.offline + && !(AppearanceState.nav-tb-purchases + && !AppearanceState.hide-title-bar + && !AppearanceState.use-system-title-bar): SidebarDirectRow { icon: @image-url("../assets/icons/shopping-bag.svg"); label: @tr("Purchases"); active: NavState.view == ContentView.purchases