fix(purchases): persist filter prefs + translate 4 toasts + explicit popup z-index

Closes the final-audit gaps for full 1:1 + standards compliance:
- Persist the 4 remaining purchase UI prefs (hide-unavailable, hide-downloaded,
  quality-filter, region-notice-seen) per-machine in ui_prefs.json + startup seed,
  so filter selections survive restart and the region notice does not reappear
  (matches Tauri's persisted prefs).
- Translate the 4 controller toast/error strings into es/de/fr/pt (were
  English-only; honors the 5-locale rule). Mexican/neutral Spanish.
- Explicit z:3000/3001 on the format-picker backdrop/popup + filter panel
  (ADR-009 >= 3000; previously relied on declaration order).
cargo check -p qbz-slint exit-0.

cc
This commit is contained in:
vicrodh committed 2026-06-24 18:38:11 -06:00
1 parent 9fbfcb5582
commit ce963c8b9f
7 files changed
+120 -3

No files matched your search

+37 -3
View File
@@ -5164,6 +5164,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
appearance.set_show_purchases(prefs.show_purchases);
appearance.set_nav_tb_purchases(prefs.nav_tb_purchases);
}
// Purchases per-machine filter prefs + region-notice state. Seeded here so
// filter selections survive restart and the region notice does not reappear
// every launch (mirrors the show-purchases seed above; the Slint equivalent
// of Tauri's per-user persisted purchase filters). The region notice is
// shown UNTIL dismissed, so its visibility is the inverse of the "seen" flag.
{
let prefs = crate::ui_prefs::load();
let purchases = window.global::<PurchasesState>();
purchases.set_filter_hide_unavailable(prefs.purchases_hide_unavailable);
purchases.set_filter_hide_downloaded(prefs.purchases_hide_downloaded);
purchases.set_filter_quality(prefs.purchases_quality_filter.clone().into());
purchases.set_show_region_notice(!prefs.purchases_region_notice_seen);
}
window.global::<AppearanceState>().set_immersive_search_action_index(
crate::ui_prefs::immersive_search_action_index(
&crate::ui_prefs::load().immersive_search_action,
@@ -11101,13 +11114,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
});
}
{
// Filter panel setters (each persists in Slice 12; here: state + derive).
// Filter panel setters. State + derive + persist the per-machine pref so
// the selection survives restart (mirrors on_appearance_bool).
let weak = window.as_weak();
window
.global::<PurchasesActions>()
.on_set_filter_hide_unavailable(move |v| {
let Some(w) = weak.upgrade() else { return };
w.global::<PurchasesState>().set_filter_hide_unavailable(v);
let mut prefs = crate::ui_prefs::load();
prefs.purchases_hide_unavailable = v;
crate::ui_prefs::save(&prefs);
purchases::derive_purchases(&w);
});
}
@@ -11115,7 +11132,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let weak = window.as_weak();
window.global::<PurchasesActions>().on_set_filter_quality(move |q| {
let Some(w) = weak.upgrade() else { return };
w.global::<PurchasesState>().set_filter_quality(q);
w.global::<PurchasesState>().set_filter_quality(q.clone());
let mut prefs = crate::ui_prefs::load();
prefs.purchases_quality_filter = q.to_string();
crate::ui_prefs::save(&prefs);
purchases::derive_purchases(&w);
});
}
@@ -11126,6 +11146,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.on_set_filter_hide_downloaded(move |v| {
let Some(w) = weak.upgrade() else { return };
w.global::<PurchasesState>().set_filter_hide_downloaded(v);
let mut prefs = crate::ui_prefs::load();
prefs.purchases_hide_downloaded = v;
crate::ui_prefs::save(&prefs);
purchases::derive_purchases(&w);
});
}
@@ -11137,6 +11160,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
s.set_filter_hide_unavailable(false);
s.set_filter_quality("all".into());
s.set_filter_hide_downloaded(false);
// Persist the reset so cleared filters survive restart.
let mut prefs = crate::ui_prefs::load();
prefs.purchases_hide_unavailable = false;
prefs.purchases_hide_downloaded = false;
prefs.purchases_quality_filter = "all".to_string();
crate::ui_prefs::save(&prefs);
purchases::derive_purchases(&w);
});
}
@@ -11151,11 +11180,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
});
}
{
// Region notice dismiss — persisted in Slice 12; here: hide it.
// Region notice dismiss — hide it AND persist the "seen" flag so it does
// not reappear on the next launch (mirrors Tauri's
// setUserItem('qbz-purchases-region-notice-seen', 'true')).
let weak = window.as_weak();
window.global::<PurchasesActions>().on_dismiss_region_notice(move || {
let Some(w) = weak.upgrade() else { return };
w.global::<PurchasesState>().set_show_region_notice(false);
let mut prefs = crate::ui_prefs::load();
prefs.purchases_region_notice_seen = true;
crate::ui_prefs::save(&prefs);
});
}
{
+30
View File
@@ -256,6 +256,27 @@ pub struct UiPrefs {
/// is disabled in Settings when the title bar is hidden / system-native.
#[serde(default)]
pub nav_tb_purchases: bool,
/// Purchases filter: hide unavailable items. Default OFF (show all). Mirrors
/// Tauri's per-user persisted purchase filter; here it is per-machine like
/// the other Slint Purchases prefs. Re-seeded into
/// `PurchasesState.filter-hide-unavailable` at startup; persisted on toggle.
#[serde(default)]
pub purchases_hide_unavailable: bool,
/// Purchases filter: hide already-downloaded items. Default OFF (show all).
/// Same per-machine persistence as [`Self::purchases_hide_unavailable`].
#[serde(default)]
pub purchases_hide_downloaded: bool,
/// Purchases quality filter: `"all"` | `"hires"` | `"cd"` | `"lossy"`.
/// Default `"all"` (no quality filtering). Mirrors
/// `PurchasesState.filter-quality`.
#[serde(default = "default_purchases_quality_filter")]
pub purchases_quality_filter: String,
/// Whether the user has dismissed the Purchases region notice. Default OFF
/// (notice shown until dismissed, matching Tauri's
/// `getUserItem('qbz-purchases-region-notice-seen') !== 'true'`). Seeds
/// `PurchasesState.show-region-notice` as `!region_notice_seen` at startup.
#[serde(default)]
pub purchases_region_notice_seen: bool,
/// Three-state sidebar: 0 open / 1 mini / 2 closed. Restored at startup.
#[serde(default)]
pub sidebar_state: i32,
@@ -356,6 +377,11 @@ fn default_streaming_quality() -> String {
DEFAULT_STREAMING_QUALITY.to_string()
}
/// Default Purchases quality filter (`"all"` = no filtering).
fn default_purchases_quality_filter() -> String {
"all".to_string()
}
fn default_npb_mode() -> String {
DEFAULT_NPB_MODE.to_string()
}
@@ -409,6 +435,10 @@ impl Default for UiPrefs {
discord_rpc_enabled: false,
show_purchases: false,
nav_tb_purchases: false,
purchases_hide_unavailable: false,
purchases_hide_downloaded: false,
purchases_quality_filter: default_purchases_quality_filter(),
purchases_region_notice_seen: false,
sidebar_state: 0,
nav_in_sidebar: default_nav_in_sidebar(),
volume: default_volume(),
@@ -4049,3 +4049,15 @@ msgstr "Zur Bibliothek hinzugefügt"
msgid "Purchased from Qobuz"
msgstr "Qobuz-Kauf"
msgid "Couldn't load purchases. Check your connection."
msgstr "Einkäufe konnten nicht geladen werden. Überprüfe deine Verbindung."
msgid "This track has no album to download"
msgstr "Dieser Titel hat kein Album zum Herunterladen"
msgid "Failed to start download. Please try again."
msgstr "Download konnte nicht gestartet werden. Bitte versuche es erneut."
msgid "No downloadable formats available"
msgstr "Keine herunterladbaren Formate verfügbar"
@@ -4032,3 +4032,15 @@ msgstr "Agregado a la biblioteca"
msgid "Purchased from Qobuz"
msgstr "Compra de Qobuz"
msgid "Couldn't load purchases. Check your connection."
msgstr "No se pudieron cargar las compras. Revisa tu conexión."
msgid "This track has no album to download"
msgstr "Esta pista no tiene álbum para descargar"
msgid "Failed to start download. Please try again."
msgstr "No se pudo iniciar la descarga. Inténtalo de nuevo."
msgid "No downloadable formats available"
msgstr "No hay formatos disponibles para descargar"
@@ -4048,3 +4048,15 @@ msgstr "Ajouté à la bibliothèque"
msgid "Purchased from Qobuz"
msgstr "Achat Qobuz"
msgid "Couldn't load purchases. Check your connection."
msgstr "Impossible de charger les achats. Vérifiez votre connexion."
msgid "This track has no album to download"
msgstr "Ce titre n'a aucun album à télécharger"
msgid "Failed to start download. Please try again."
msgstr "Échec du démarrage du téléchargement. Veuillez réessayer."
msgid "No downloadable formats available"
msgstr "Aucun format téléchargeable disponible"
@@ -4021,3 +4021,15 @@ msgstr "Adicionado à biblioteca"
msgid "Purchased from Qobuz"
msgstr "Compra do Qobuz"
msgid "Couldn't load purchases. Check your connection."
msgstr "Não foi possível carregar as compras. Verifique sua conexão."
msgid "This track has no album to download"
msgstr "Esta faixa não tem álbum para baixar"
msgid "Failed to start download. Please try again."
msgstr "Falha ao iniciar o download. Tente novamente."
msgid "No downloadable formats available"
msgstr "Nenhum formato disponível para download"
@@ -794,6 +794,9 @@ component SortRow inherits MenuRow {
// Shared filter panel (albums variant adds the Availability section).
component FilterPanel inherits Rectangle {
in property <bool> show-availability: true;
// ADR-009: lift the anchored filter panel above sibling toolbar controls so
// it never renders behind them regardless of declaration order.
z: 3000;
width: 280px;
height: panel.preferred-height;
background: Theme.surface-card;
@@ -1457,6 +1460,7 @@ export component PurchasesView inherits Rectangle {
if PurchasesState.picker-track-id != "": Rectangle {
// Backdrop.
TouchArea {
z: 3000;
width: root.width;
height: root.height;
clicked => { PurchasesActions.close-format-picker(); }
@@ -1485,6 +1489,7 @@ export component PurchasesView inherits Rectangle {
// `dl-slot.absolute-position - <flickable>.absolute-position` (scroll-
// safe) at the call site (line ~600) rather than patching the math here.
Rectangle {
z: 3001;
x: Math.max(8px, (PurchasesState.picker-anchor-x - root.absolute-position.x) - self.width);
y: (PurchasesState.picker-anchor-y - root.absolute-position.y) + 4px;
width: 240px;