fix(qt): fade on tab switches, playlist recents artwork, per-rail sizes, wheel
Four defects from the smoke of 26ceeab82.
TAB SWITCHES DID NOT FADE. The page fade hangs off the router's Loader
`source`, and a tab switch inside a view never touches it — so Discover's four
tabs, Library's and Local Library's cut hard while a route change faded, which
is the same event from where the user sits. `activeTab` is the one name every
tabbed view uses for this (the nav-flyout Binding already routes through it),
so one Connections in the router covers all of them; `ignoreUnknownSignals`
leaves the untabbed views alone. No watchdog and no opacity assignment there: a
tab body is built synchronously in the same turn, so `restart()` alone — which
sets the page to `from` — is the whole transition. The `running` guard keeps a
tab stamped right after a route change from restarting that route's fade.
RECENTLY PLAYED PLAYLISTS DREW PLACEHOLDERS. The rail published only
`artwork_url`, taken from the detail page's `cover_url` — and that field is
empty for every playlist WITHOUT a graphic of its own, which is most of them
and is exactly why the detail page falls back to a collage. A local playlist has
no Qobuz graphic at all, so it could never resolve one. The meta store now keeps
the member covers and an own-image flag beside the url, and the card gets both
arms it already knows how to draw: contain-fitted single graphic, or the mosaic.
All of it rides `art_url` and lets `attach_cached` fill the path —
`artwork_qt::cached_path` already classifies http, Plex and on-disk paths, so a
custom cover and a local file resolve through the same pass as a Qobuz url.
ITEMS PER CAROUSEL WAS ONE NUMBER FOR THE WHOLE PAGE. Tauri's was per rail
(`HomeSettingsModal.svelte`), and the global was a simplification that lost the
point of the feature: a 25-wide "New Releases" beside a 10-wide "Recently
Played" is why anyone opens it. Storage is now a row per section — absent means
the default, and setting a rail back to the default DELETES its row, so the
file only carries what was actually changed. The select moves into each row of
the configurator, and the cut moves into `order_by_prefs`, keyed by the PREF id:
`mostStreamed` resolves to a per-tab variant candidate, so the section's own id
is not always the id the user configured, and that loop is the only place both
are in hand.
OPEN OVERLAYS LET THE WHEEL THROUGH. A MouseArea consumes presses and NOT wheel
events, so with the configurator open the pointer still scrolled the page
underneath — over the panel it moved the panel's own list and the page behind it
at once. These overlays are plain Items rather than Popups, so nothing grabs for
them and each has to stop the wheel at its own surface: the configurator, the
genre popup, the playlist-category popup and the Local Library funnel.
Release build clean, offscreen smoke green, 421/421 and 215/215.
cc
This commit is contained in:
13 files changed
+291
-185
No files matched your search
@@ -441,6 +441,12 @@ pub fn reconcile_list(persisted: Option<&Vec<Value>>, fallback: &[SectionPref])
|
|||||||
/// (`home_qt::order_by_prefs` pushed every item through), so any other default
|
/// (`home_qt::order_by_prefs` pushed every item through), so any other default
|
||||||
/// would shrink the Discover page of every user who upgrades without ever
|
/// would shrink the Discover page of every user who upgrades without ever
|
||||||
/// asking them.
|
/// asking them.
|
||||||
|
///
|
||||||
|
/// The size is PER RAIL, which is what Tauri offered
|
||||||
|
/// (`HomeSettingsModal.svelte` over `homeSettingsStore.ts`) — a single global
|
||||||
|
/// number was this port's simplification and it lost the point of the feature:
|
||||||
|
/// a 25-wide "New Releases" and a 10-wide "Recently Played" are the reason
|
||||||
|
/// anyone touches it.
|
||||||
pub const RAIL_SIZE_PRESETS: [i64; 5] = [10, 15, 20, 25, 0];
|
pub const RAIL_SIZE_PRESETS: [i64; 5] = [10, 15, 20, 25, 0];
|
||||||
|
|
||||||
/// The default rail size — `0`, i.e. today's uncapped behaviour.
|
/// The default rail size — `0`, i.e. today's uncapped behaviour.
|
||||||
@@ -493,18 +499,15 @@ impl DiscoverPrefsStore {
|
|||||||
// already set above, so two binaries on one file is the existing
|
// already set above, so two binaries on one file is the existing
|
||||||
// design, not something this adds.
|
// design, not something this adds.
|
||||||
conn.execute_batch(
|
conn.execute_batch(
|
||||||
"CREATE TABLE IF NOT EXISTS discover_rail_size (
|
"CREATE TABLE IF NOT EXISTS discover_rail_sizes (
|
||||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
section_id TEXT PRIMARY KEY,
|
||||||
rail_size INTEGER NOT NULL
|
rail_size INTEGER NOT NULL
|
||||||
);",
|
);",
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("Failed to create discover rail size table: {}", e))?;
|
.map_err(|e| format!("Failed to create discover rail size table: {}", e))?;
|
||||||
|
// No seed row: ABSENT means the default, which is uncapped. Writing a
|
||||||
conn.execute(
|
// row per section at open would put twenty rows in the file to say
|
||||||
"INSERT OR IGNORE INTO discover_rail_size (id, rail_size) VALUES (1, ?1)",
|
// "unchanged", and would then have to be kept in step with the enum.
|
||||||
params![DEFAULT_RAIL_SIZE],
|
|
||||||
)
|
|
||||||
.map_err(|e| format!("Failed to initialize discover rail size: {}", e))?;
|
|
||||||
|
|
||||||
Ok(Self { conn })
|
Ok(Self { conn })
|
||||||
}
|
}
|
||||||
@@ -538,36 +541,52 @@ impl DiscoverPrefsStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How many items each Discover rail may show. `0` = no cap.
|
/// How many items each Discover rail may show, by section id. `0` = no
|
||||||
|
/// cap, and a section ABSENT from the map is uncapped too.
|
||||||
///
|
///
|
||||||
/// Never an error to the caller: a missing row, an old file without the
|
/// Never an error to the caller: a missing table (an older file) or a value
|
||||||
/// table, or a value outside the presets all fall back to the default.
|
/// outside the presets yields an empty map / drops that row.
|
||||||
pub fn load_rail_size(&self) -> i64 {
|
pub fn load_rail_sizes(&self) -> std::collections::HashMap<String, i64> {
|
||||||
self.conn
|
let out = (|| -> Option<std::collections::HashMap<String, i64>> {
|
||||||
.query_row(
|
let mut stmt = self
|
||||||
"SELECT rail_size FROM discover_rail_size WHERE id = 1",
|
.conn
|
||||||
[],
|
.prepare("SELECT section_id, rail_size FROM discover_rail_sizes")
|
||||||
|row| row.get::<_, i64>(0),
|
.ok()?;
|
||||||
|
let rows = stmt
|
||||||
|
.query_map([], |row| {
|
||||||
|
Ok((row.get::<_, String>(0)?, row.get::<_, i64>(1)?))
|
||||||
|
})
|
||||||
|
.ok()?;
|
||||||
|
Some(
|
||||||
|
rows.flatten()
|
||||||
|
.filter(|(_, n)| RAIL_SIZE_PRESETS.contains(n))
|
||||||
|
.collect(),
|
||||||
)
|
)
|
||||||
.ok()
|
})();
|
||||||
.filter(|n| RAIL_SIZE_PRESETS.contains(n))
|
out.unwrap_or_default()
|
||||||
.unwrap_or(DEFAULT_RAIL_SIZE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Persist the rail size (upsert row 1). Values outside the presets are
|
/// Persist ONE rail's size. Values outside the presets are rejected rather
|
||||||
/// rejected rather than stored, so `load_rail_size` and the UI's index can
|
/// than stored, so what loads back and the UI's index can never disagree.
|
||||||
/// never disagree about what is selected.
|
/// The DEFAULT deletes the row instead of storing it — the file then only
|
||||||
pub fn save_rail_size(&self, n: i64) -> Result<(), String> {
|
/// carries the rails the user actually changed.
|
||||||
|
pub fn save_rail_size(&self, section_id: &str, n: i64) -> Result<(), String> {
|
||||||
if !RAIL_SIZE_PRESETS.contains(&n) {
|
if !RAIL_SIZE_PRESETS.contains(&n) {
|
||||||
return Err(format!("rail size {n} is not one of {RAIL_SIZE_PRESETS:?}"));
|
return Err(format!("rail size {n} is not one of {RAIL_SIZE_PRESETS:?}"));
|
||||||
}
|
}
|
||||||
self.conn
|
let sql = if n == DEFAULT_RAIL_SIZE {
|
||||||
.execute(
|
self.conn.execute(
|
||||||
"INSERT INTO discover_rail_size (id, rail_size) VALUES (1, ?1)
|
"DELETE FROM discover_rail_sizes WHERE section_id = ?1",
|
||||||
ON CONFLICT(id) DO UPDATE SET rail_size = excluded.rail_size",
|
params![section_id],
|
||||||
params![n],
|
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("Failed to save discover rail size: {}", e))?;
|
} else {
|
||||||
|
self.conn.execute(
|
||||||
|
"INSERT INTO discover_rail_sizes (section_id, rail_size) VALUES (?1, ?2)
|
||||||
|
ON CONFLICT(section_id) DO UPDATE SET rail_size = excluded.rail_size",
|
||||||
|
params![section_id, n],
|
||||||
|
)
|
||||||
|
};
|
||||||
|
sql.map_err(|e| format!("Failed to save discover rail size: {}", e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ fn init_schema(conn: &Connection) -> rusqlite::Result<()> {
|
|||||||
artwork_url TEXT NOT NULL DEFAULT '',
|
artwork_url TEXT NOT NULL DEFAULT '',
|
||||||
track_count INTEGER NOT NULL DEFAULT 0,
|
track_count INTEGER NOT NULL DEFAULT 0,
|
||||||
source TEXT NOT NULL DEFAULT '',
|
source TEXT NOT NULL DEFAULT '',
|
||||||
|
-- Up to four MEMBER covers, as a JSON array, for the card's mosaic
|
||||||
|
-- arm. Most playlists have no graphic of their own, so without
|
||||||
|
-- these the rail draws placeholders: the detail page falls back to
|
||||||
|
-- a collage for exactly the same reason.
|
||||||
|
covers TEXT NOT NULL DEFAULT '[]',
|
||||||
|
-- The playlist HAS a single graphic of its own (or a custom cover),
|
||||||
|
-- which the card contain-fits instead of building a mosaic.
|
||||||
|
own_image INTEGER NOT NULL DEFAULT 0,
|
||||||
updated_at INTEGER NOT NULL
|
updated_at INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
"#,
|
"#,
|
||||||
@@ -113,6 +121,13 @@ pub struct PlaylistPlayMeta<'a> {
|
|||||||
/// `"qobuz"` | `"local"` — where the playlist itself lives, NOT where its
|
/// `"qobuz"` | `"local"` — where the playlist itself lives, NOT where its
|
||||||
/// audio comes from (a Qobuz playlist can hold local rows).
|
/// audio comes from (a Qobuz playlist can hold local rows).
|
||||||
pub source: &'a str,
|
pub source: &'a str,
|
||||||
|
/// Member covers for the mosaic (up to four). Remote urls for a Qobuz
|
||||||
|
/// playlist, local file paths for a local one — the artwork cache resolves
|
||||||
|
/// both, so the card does not care which it got.
|
||||||
|
pub covers: &'a [String],
|
||||||
|
/// True when [`Self::artwork_url`] is the playlist's OWN single graphic
|
||||||
|
/// (or a custom cover) rather than a stand-in member cover.
|
||||||
|
pub own_image: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One playlist row for the rail / a View-all page.
|
/// One playlist row for the rail / a View-all page.
|
||||||
@@ -125,6 +140,8 @@ pub struct PlaylistPlayRow {
|
|||||||
pub artwork_url: String,
|
pub artwork_url: String,
|
||||||
pub track_count: u32,
|
pub track_count: u32,
|
||||||
pub source: String,
|
pub source: String,
|
||||||
|
pub covers: Vec<String>,
|
||||||
|
pub own_image: bool,
|
||||||
pub plays: u32,
|
pub plays: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,8 +157,8 @@ fn upsert_meta_on(conn: &Connection, m: &PlaylistPlayMeta, now: i64) {
|
|||||||
r#"
|
r#"
|
||||||
INSERT INTO playlist_meta
|
INSERT INTO playlist_meta
|
||||||
(playlist_id, title, owner, owner_id, artwork_url,
|
(playlist_id, title, owner, owner_id, artwork_url,
|
||||||
track_count, source, updated_at)
|
track_count, source, covers, own_image, updated_at)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
ON CONFLICT(playlist_id) DO UPDATE SET
|
ON CONFLICT(playlist_id) DO UPDATE SET
|
||||||
title = excluded.title,
|
title = excluded.title,
|
||||||
owner = excluded.owner,
|
owner = excluded.owner,
|
||||||
@@ -149,6 +166,8 @@ fn upsert_meta_on(conn: &Connection, m: &PlaylistPlayMeta, now: i64) {
|
|||||||
artwork_url = excluded.artwork_url,
|
artwork_url = excluded.artwork_url,
|
||||||
track_count = excluded.track_count,
|
track_count = excluded.track_count,
|
||||||
source = excluded.source,
|
source = excluded.source,
|
||||||
|
covers = excluded.covers,
|
||||||
|
own_image = excluded.own_image,
|
||||||
updated_at = excluded.updated_at
|
updated_at = excluded.updated_at
|
||||||
"#,
|
"#,
|
||||||
params![
|
params![
|
||||||
@@ -159,6 +178,8 @@ fn upsert_meta_on(conn: &Connection, m: &PlaylistPlayMeta, now: i64) {
|
|||||||
m.artwork_url,
|
m.artwork_url,
|
||||||
m.track_count,
|
m.track_count,
|
||||||
m.source,
|
m.source,
|
||||||
|
serde_json::to_string(m.covers).unwrap_or_else(|_| "[]".to_string()),
|
||||||
|
m.own_image as i32,
|
||||||
now
|
now
|
||||||
],
|
],
|
||||||
) {
|
) {
|
||||||
@@ -215,7 +236,7 @@ fn query_on(conn: &Connection, order: &str, limit: Option<u32>) -> Vec<PlaylistP
|
|||||||
let sql = format!(
|
let sql = format!(
|
||||||
r#"
|
r#"
|
||||||
SELECT m.playlist_id, m.title, m.owner, m.owner_id, m.artwork_url,
|
SELECT m.playlist_id, m.title, m.owner, m.owner_id, m.artwork_url,
|
||||||
m.track_count, m.source, p.plays
|
m.track_count, m.source, m.covers, m.own_image, p.plays
|
||||||
FROM playlist_meta m
|
FROM playlist_meta m
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT playlist_id, COUNT(*) AS plays, MAX(occurred_at) AS last_at
|
SELECT playlist_id, COUNT(*) AS plays, MAX(occurred_at) AS last_at
|
||||||
@@ -239,7 +260,10 @@ fn query_on(conn: &Connection, order: &str, limit: Option<u32>) -> Vec<PlaylistP
|
|||||||
artwork_url: row.get(4)?,
|
artwork_url: row.get(4)?,
|
||||||
track_count: row.get::<_, i64>(5)? as u32,
|
track_count: row.get::<_, i64>(5)? as u32,
|
||||||
source: row.get(6)?,
|
source: row.get(6)?,
|
||||||
plays: row.get::<_, i64>(7)? as u32,
|
covers: serde_json::from_str(&row.get::<_, String>(7)?)
|
||||||
|
.unwrap_or_default(),
|
||||||
|
own_image: row.get::<_, i64>(8)? != 0,
|
||||||
|
plays: row.get::<_, i64>(9)? as u32,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.ok()?;
|
.ok()?;
|
||||||
@@ -302,6 +326,8 @@ mod tests {
|
|||||||
artwork_url: "http://art",
|
artwork_url: "http://art",
|
||||||
track_count: 12,
|
track_count: 12,
|
||||||
source: "qobuz",
|
source: "qobuz",
|
||||||
|
covers: &[],
|
||||||
|
own_image: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,14 @@ Item {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: root.close()
|
onClicked: root.close()
|
||||||
|
// Eat the WHEEL as well as the click. A MouseArea consumes presses
|
||||||
|
// but lets wheel events fall straight through, so with this open
|
||||||
|
// the pointer still scrolled the page underneath — and over the
|
||||||
|
// panel it moved the panel's own list AND the page behind it at the
|
||||||
|
// same time. These overlays are plain Items, not Popups, so there
|
||||||
|
// is no modal grab doing it for them: each has to stop the wheel at
|
||||||
|
// its own surface.
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +114,13 @@ Item {
|
|||||||
border.color: theme.borderSubtle
|
border.color: theme.borderSubtle
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
// Swallow clicks so they never reach the scrim.
|
// Swallow clicks so they never reach the scrim — and the wheel, so a
|
||||||
MouseArea { anchors.fill: parent }
|
// scroll that starts outside the section list (the title, the banner,
|
||||||
|
// the footer) does not reach the page behind the modal.
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
// NOT `body`: WarningBanner below has a `body` PROPERTY, and an
|
// NOT `body`: WarningBanner below has a `body` PROPERTY, and an
|
||||||
@@ -176,68 +189,19 @@ Item {
|
|||||||
font.weight: theme.weightMedium
|
font.weight: theme.weightMedium
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Items per carousel ---------------------------------------
|
|
||||||
// Recovered from Tauri (`HomeSettingsModal.svelte`), which let the
|
|
||||||
// user cap how many items each carousel showed. It never reached
|
|
||||||
// Slint — the discovery-v2 modal Slint was ported from only ever
|
|
||||||
// modelled {id, enabled} — so Qt inherited the absence.
|
|
||||||
//
|
|
||||||
// GLOBAL, so it reads its own bridge property rather than the
|
|
||||||
// per-tab document: `root.mine` gates the rows below on the tab
|
|
||||||
// payload having landed, and this control must be usable before
|
|
||||||
// that.
|
|
||||||
Item {
|
|
||||||
visible: root.tab !== "recommendations"
|
|
||||||
width: parent.width
|
|
||||||
height: 34
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: sizeLabel
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
text: QbzSession.tr("Items per carousel", QbzSession.trRev)
|
|
||||||
color: theme.textMuted
|
|
||||||
font.pixelSize: theme.fontBody
|
|
||||||
}
|
|
||||||
QbzSelect {
|
|
||||||
anchors.left: sizeLabel.right
|
|
||||||
anchors.leftMargin: 8
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
sm: true
|
|
||||||
menuWidth: 140
|
|
||||||
// Option ORDER is the contract with RAIL_SIZE_PRESETS in
|
|
||||||
// qbz-app/src/settings/discover_prefs.rs — the bridge
|
|
||||||
// publishes an index, not a count, so reordering these
|
|
||||||
// silently changes what every stored value means. "All" is
|
|
||||||
// the stored 0 and the default: it is what this page did
|
|
||||||
// before the setting existed.
|
|
||||||
options: [
|
|
||||||
"10",
|
|
||||||
"15",
|
|
||||||
"20",
|
|
||||||
"25",
|
|
||||||
QbzSession.tr("All", QbzSession.trRev),
|
|
||||||
]
|
|
||||||
currentIndex: QbzHome.discoverRailSizeIndex
|
|
||||||
onSelected: function (i) { QbzHome.discoverSetRailSize(i) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Section list ---------------------------------------------
|
// --- Section list ---------------------------------------------
|
||||||
// Explicit, content-derived height capped to what is left of the
|
// Explicit, content-derived height capped to what is left of the
|
||||||
// panel; the Flickable scrolls past that.
|
// panel; the Flickable scrolls past that.
|
||||||
//
|
//
|
||||||
// The subtrahend is the FIXED-CHROME BUDGET (title + banner + count
|
// The subtrahend is the FIXED-CHROME BUDGET (title + banner + count
|
||||||
// + the size row + footer + margins), and it is load-bearing: the
|
// + footer + margins), and it is load-bearing: the panel clips
|
||||||
// panel clips (`clip: true` above), so a row added over this list
|
// (`clip: true` above), so a row added over this list without
|
||||||
// without raising the number does not overflow visibly — the last
|
// raising the number does not overflow visibly — the last sections
|
||||||
// sections and the Reset footer simply stop existing. It went
|
// and the Reset footer simply stop existing.
|
||||||
// 260 -> 308 with the size row: 34 of row plus the column's 14 of
|
|
||||||
// spacing.
|
|
||||||
Item {
|
Item {
|
||||||
visible: root.tab !== "recommendations"
|
visible: root.tab !== "recommendations"
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: Math.max(0, Math.min(listCol.height, root.height * 0.78 - 308))
|
height: Math.max(0, Math.min(listCol.height, root.height * 0.78 - 260))
|
||||||
clip: true
|
clip: true
|
||||||
Flickable {
|
Flickable {
|
||||||
id: listFlick
|
id: listFlick
|
||||||
@@ -284,7 +248,7 @@ Item {
|
|||||||
onToggled: QbzBridge.discoverToggleSection(root.tab, cfgRow.modelData.id)
|
onToggled: QbzBridge.discoverToggleSection(root.tab, cfgRow.modelData.id)
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
width: parent.width - 18 - 28 - 28 - 3 * 12
|
width: parent.width - 18 - 82 - 28 - 28 - 4 * 12
|
||||||
height: parent.height
|
height: parent.height
|
||||||
text: cfgRow.modelData.label
|
text: cfgRow.modelData.label
|
||||||
color: cfgRow.modelData.enabled ? theme.textPrimary : theme.textMuted
|
color: cfgRow.modelData.enabled ? theme.textPrimary : theme.textMuted
|
||||||
@@ -293,6 +257,41 @@ Item {
|
|||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
|
// How many items THIS rail shows. Per rail
|
||||||
|
// and not one number for the page: that is
|
||||||
|
// the shape Tauri had
|
||||||
|
// (`HomeSettingsModal.svelte`), and it is
|
||||||
|
// the point of the feature — a 25-wide
|
||||||
|
// "New Releases" next to a 10-wide
|
||||||
|
// "Recently Played" is why anyone opens
|
||||||
|
// this.
|
||||||
|
//
|
||||||
|
// Option ORDER is the contract with
|
||||||
|
// RAIL_SIZE_PRESETS in
|
||||||
|
// qbz-app/src/settings/discover_prefs.rs:
|
||||||
|
// the bridge carries an index, not a count,
|
||||||
|
// so reordering these silently changes what
|
||||||
|
// every stored value means. "All" is the
|
||||||
|
// stored 0 and the default — what this page
|
||||||
|
// did before the setting existed.
|
||||||
|
QbzSelect {
|
||||||
|
width: 82
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
sm: true
|
||||||
|
menuWidth: 110
|
||||||
|
enabled: cfgRow.modelData.enabled
|
||||||
|
options: [
|
||||||
|
"10",
|
||||||
|
"15",
|
||||||
|
"20",
|
||||||
|
"25",
|
||||||
|
QbzSession.tr("All", QbzSession.trRev),
|
||||||
|
]
|
||||||
|
currentIndex: cfgRow.modelData.sizeIndex || 0
|
||||||
|
onSelected: function (i) {
|
||||||
|
QbzHome.discoverSetRailSize(root.tab, cfgRow.modelData.id, i)
|
||||||
|
}
|
||||||
|
}
|
||||||
ReorderButton {
|
ReorderButton {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
glyph: "chevron-up"
|
glyph: "chevron-up"
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ Item {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: root.close()
|
onClicked: root.close()
|
||||||
|
// Same wheel rule as the configurator modal: a MouseArea eats the
|
||||||
|
// press and not the wheel, so without this the page kept scrolling
|
||||||
|
// under an open popup.
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -112,7 +116,10 @@ Item {
|
|||||||
|
|
||||||
// Swallow clicks that land on the card's own chrome so the backdrop
|
// Swallow clicks that land on the card's own chrome so the backdrop
|
||||||
// does not close it. Declared FIRST: the content below stays on top.
|
// does not close it. Declared FIRST: the content below stays on top.
|
||||||
MouseArea { anchors.fill: parent }
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: col
|
id: col
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ Item {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: root.close()
|
onClicked: root.close()
|
||||||
|
// A MouseArea eats presses, NOT wheel events. Without this the page
|
||||||
|
// behind an open popup kept scrolling under the pointer.
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -93,8 +96,12 @@ Item {
|
|||||||
border.color: theme.borderMuted
|
border.color: theme.borderMuted
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
// Swallow clicks so the backdrop does not close the card.
|
// Swallow clicks so the backdrop does not close the card, and the
|
||||||
MouseArea { anchors.fill: parent }
|
// wheel so a scroll over the footer does not reach the page.
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
|
}
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: listFlick
|
id: listFlick
|
||||||
|
|||||||
@@ -223,6 +223,33 @@ Item {
|
|||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TABS FADE TOO. A tab switch inside a view (Discover's four, Library's,
|
||||||
|
// Local Library's) never touches the Loader's `source`, so none of the
|
||||||
|
// machinery above fires — the page changed under the user with a hard cut
|
||||||
|
// while a route change faded. Same transition, same duration, for what is
|
||||||
|
// the same thing from where the user sits.
|
||||||
|
//
|
||||||
|
// `activeTab` is the ONE name every tabbed view uses for this (the Binding
|
||||||
|
// further down already routes the nav flyout through it), so watching it
|
||||||
|
// here covers all of them from one place instead of a copy per view.
|
||||||
|
// `ignoreUnknownSignals` is what lets the untabbed views mount unharmed:
|
||||||
|
// without it a Connections whose target has no such signal is an error.
|
||||||
|
//
|
||||||
|
// No watchdog and no opacity assignment: a tab body is built synchronously
|
||||||
|
// inside the view, in this same turn, so by the time a frame renders there
|
||||||
|
// is something to reveal — `restart()` alone sets the page to `from` (0)
|
||||||
|
// and animates it back. The `running` guard keeps a tab that is stamped
|
||||||
|
// right after a route change from restarting the fade that route already
|
||||||
|
// started.
|
||||||
|
Connections {
|
||||||
|
target: viewLoader.item
|
||||||
|
ignoreUnknownSignals: true
|
||||||
|
function onActiveTabChanged() {
|
||||||
|
if (!QbzShell.reduceMotion && !fadeIn.running)
|
||||||
|
fadeIn.restart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: viewLoader
|
id: viewLoader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ Item {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: root.view.filterOpen = false
|
onClicked: root.view.filterOpen = false
|
||||||
|
// A MouseArea eats presses, NOT wheel events — the grid behind this
|
||||||
|
// card kept scrolling with it open.
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -38,8 +41,12 @@ Item {
|
|||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: theme.borderSubtle
|
border.color: theme.borderSubtle
|
||||||
|
|
||||||
// Swallow clicks so the backdrop does not close the card.
|
// Swallow clicks so the backdrop does not close the card, and the
|
||||||
MouseArea { anchors.fill: parent }
|
// wheel so it does not reach the grid.
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onWheel: function (wheel) { wheel.accepted = true }
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: col
|
id: col
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ struct RowDoc {
|
|||||||
id: String,
|
id: String,
|
||||||
label: String,
|
label: String,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
|
/// The rail's item cap as an index into `RAIL_SIZE_PRESETS` — the contract
|
||||||
|
/// with the per-row select's option order in `DiscoverConfigModal.qml`.
|
||||||
|
#[serde(rename = "sizeIndex")]
|
||||||
|
size_index: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@@ -104,18 +108,14 @@ pub(crate) fn store() -> Option<DiscoverPrefsStore> {
|
|||||||
// shared one, and a per-rail knob would put twenty spinners in a modal whose
|
// shared one, and a per-rail knob would put twenty spinners in a modal whose
|
||||||
// job is to be glanced at.
|
// job is to be glanced at.
|
||||||
|
|
||||||
/// The stored cap, `0` = uncapped. Falls back to the default with no store
|
/// Every rail's stored cap, by section id. Absent = uncapped.
|
||||||
/// (nobody logged in yet), which is also the uncapped value — so the page
|
pub(crate) fn rail_sizes() -> std::collections::HashMap<String, i64> {
|
||||||
/// behaves exactly as it did before this setting existed until someone
|
store().map(|s| s.load_rail_sizes()).unwrap_or_default()
|
||||||
/// deliberately changes it.
|
|
||||||
pub(crate) fn rail_size() -> i64 {
|
|
||||||
store().map(|s| s.load_rail_size()).unwrap_or(DEFAULT_RAIL_SIZE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stored size -> select index. The index IS the contract with the option
|
/// One section's size as the select's INDEX into `RAIL_SIZE_PRESETS`.
|
||||||
/// order in `DiscoverConfigModal.qml`; see `RAIL_SIZE_PRESETS`.
|
fn rail_size_index_of(sizes: &std::collections::HashMap<String, i64>, id: &str) -> i32 {
|
||||||
pub(crate) fn rail_size_index() -> i32 {
|
let n = sizes.get(id).copied().unwrap_or(DEFAULT_RAIL_SIZE);
|
||||||
let n = rail_size();
|
|
||||||
RAIL_SIZE_PRESETS
|
RAIL_SIZE_PRESETS
|
||||||
.iter()
|
.iter()
|
||||||
.position(|&p| p == n)
|
.position(|&p| p == n)
|
||||||
@@ -127,40 +127,32 @@ pub(crate) fn rail_size_index() -> i32 {
|
|||||||
}) as i32
|
}) as i32
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configurator select -> persist -> re-render the tabs -> republish the
|
/// Configurator select -> persist -> re-render the tabs -> republish the rows
|
||||||
/// RESOLVED index.
|
/// (which carry the RESOLVED index back, so a failed write snaps the select
|
||||||
///
|
/// to what is actually stored rather than to what was clicked).
|
||||||
/// Resolved, not the index that came in — the same honesty the reco cache
|
|
||||||
/// window buys with the same line: if the write fails (no per-user store), the
|
|
||||||
/// select snaps back to what is actually stored instead of displaying a size
|
|
||||||
/// nobody saved.
|
|
||||||
///
|
///
|
||||||
/// `republish_cached()` and not a reload: the cut happens at assembly time over
|
/// `republish_cached()` and not a reload: the cut happens at assembly time over
|
||||||
/// the candidates already in memory, so a new size lands on the next frame with
|
/// the candidates already in memory, so a new size lands on the next frame with
|
||||||
/// no network round trip — exactly like a section toggle.
|
/// no network round trip — exactly like a section toggle.
|
||||||
pub(crate) fn set_rail_size_index(index: i32) {
|
pub(crate) fn set_rail_size_index(tab_key: &str, id: &str, index: i32) {
|
||||||
|
if DiscoverySectionId::from_str(id).is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let idx = index.clamp(0, RAIL_SIZE_PRESETS.len() as i32 - 1) as usize;
|
let idx = index.clamp(0, RAIL_SIZE_PRESETS.len() as i32 - 1) as usize;
|
||||||
let size = RAIL_SIZE_PRESETS[idx];
|
let size = RAIL_SIZE_PRESETS[idx];
|
||||||
let Some(store) = store() else {
|
let Some(store) = store() else {
|
||||||
log::warn!("[qbz-qt] discover rail size: no per-user prefs store (not logged in?)");
|
log::warn!("[qbz-qt] discover rail size: no per-user prefs store (not logged in?)");
|
||||||
publish_rail_size_index();
|
publish(tab_key);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if let Err(e) = store.save_rail_size(size) {
|
if let Err(e) = store.save_rail_size(id, size) {
|
||||||
log::warn!("[qbz-qt] discover rail size: save failed: {e}");
|
log::warn!("[qbz-qt] discover rail size: save failed: {e}");
|
||||||
publish_rail_size_index();
|
publish(tab_key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log::info!("[qbz-qt] discover rail size set to {size} (0 = all)");
|
log::info!("[qbz-qt] discover rail {id} size set to {size} (0 = all)");
|
||||||
crate::home_qt::republish_cached();
|
crate::home_qt::republish_cached();
|
||||||
publish_rail_size_index();
|
publish(tab_key);
|
||||||
}
|
|
||||||
|
|
||||||
/// Push the stored size onto the bridge as its select index. Called at boot
|
|
||||||
/// (so the select opens on the right entry the FIRST time) and after a write.
|
|
||||||
pub(crate) fn publish_rail_size_index() {
|
|
||||||
let index = rail_size_index();
|
|
||||||
crate::home_bridge::ui(move |mut b| b.as_mut().set_discover_rail_size_index(index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The tab's ordered pref ids, narrowed to what this port renders.
|
/// The tab's ordered pref ids, narrowed to what this port renders.
|
||||||
@@ -188,6 +180,8 @@ pub(crate) fn rows_json(tab_key: &str) -> String {
|
|||||||
};
|
};
|
||||||
let prefs = crate::home_qt::load_prefs();
|
let prefs = crate::home_qt::load_prefs();
|
||||||
let visible = visible_ids(&prefs, tab);
|
let visible = visible_ids(&prefs, tab);
|
||||||
|
// ONE store read for the whole tab, not one per row.
|
||||||
|
let sizes = rail_sizes();
|
||||||
let rows: Vec<RowDoc> = prefs
|
let rows: Vec<RowDoc> = prefs
|
||||||
.tab(tab)
|
.tab(tab)
|
||||||
.iter()
|
.iter()
|
||||||
@@ -196,6 +190,7 @@ pub(crate) fn rows_json(tab_key: &str) -> String {
|
|||||||
id: p.id.as_str().to_string(),
|
id: p.id.as_str().to_string(),
|
||||||
label: qbz_i18n::t(label_for(p.id)),
|
label: qbz_i18n::t(label_for(p.id)),
|
||||||
enabled: p.enabled,
|
enabled: p.enabled,
|
||||||
|
size_index: rail_size_index_of(&sizes, p.id.as_str()),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let total = rows.len() as i32;
|
let total = rows.len() as i32;
|
||||||
|
|||||||
@@ -86,21 +86,6 @@ pub mod qbz_home {
|
|||||||
/// lets it open on the stored entry without QML owning the mapping.
|
/// lets it open on the stored entry without QML owning the mapping.
|
||||||
/// Seeded at boot from the shared per-user discover prefs.
|
/// Seeded at boot from the shared per-user discover prefs.
|
||||||
#[qproperty(i32, reco_cache_ttl_index)]
|
#[qproperty(i32, reco_cache_ttl_index)]
|
||||||
/// Configurator > "Items per carousel", as the select's INDEX into
|
|
||||||
/// `discover_prefs::RAIL_SIZE_PRESETS` rather than the count, for the
|
|
||||||
/// same reason as the window above: the control is a fixed option list
|
|
||||||
/// and QML must not own the mapping. GLOBAL (not per tab), which is why
|
|
||||||
/// it rides its own property instead of the per-tab config document —
|
|
||||||
/// the modal has to be able to read it before the tab payload lands.
|
|
||||||
#[qproperty(i32, discover_rail_size_index)]
|
|
||||||
/// The Qobuz-Playlists rail's category filter, as ONE small document:
|
|
||||||
/// `{ tags: [{slug, name}], selected: ["slug", ...] }`.
|
|
||||||
///
|
|
||||||
/// Its own property rather than a field on `homeSectionsJson`, and this
|
|
||||||
/// is the load-bearing part: republishing the sections document
|
|
||||||
/// destroys and rebuilds every rail's QQmlDelegateModel and resets
|
|
||||||
/// their horizontal scroll (see the note at the top of this file). A
|
|
||||||
/// toggle has to be able to move ~40 bytes without doing that.
|
|
||||||
#[qproperty(QString, playlist_tags_json)]
|
#[qproperty(QString, playlist_tags_json)]
|
||||||
// --- "View all" full-list pages (src/browse_qt.rs) ----------------
|
// --- "View all" full-list pages (src/browse_qt.rs) ----------------
|
||||||
#[qproperty(QString, discover_browse_json)]
|
#[qproperty(QString, discover_browse_json)]
|
||||||
@@ -150,12 +135,12 @@ pub mod qbz_home {
|
|||||||
/// a window nobody stored.
|
/// a window nobody stored.
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn reco_set_cache_ttl_index(self: Pin<&mut QbzHome>, index: i32);
|
fn reco_set_cache_ttl_index(self: Pin<&mut QbzHome>, index: i32);
|
||||||
/// Configurator > "Items per carousel": an index into
|
/// Configurator > one rail's "items" select: an index into
|
||||||
/// `RAIL_SIZE_PRESETS` (last entry = no cap). Persists to its own table
|
/// `RAIL_SIZE_PRESETS` (last entry = no cap), PER SECTION. Persists to
|
||||||
/// in the shared per-user discover prefs file and republishes the
|
/// its own table in the shared per-user discover prefs file and
|
||||||
/// RESOLVED index.
|
/// republishes the tab's rows with the RESOLVED index.
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn discover_set_rail_size(self: Pin<&mut QbzHome>, index: i32);
|
fn discover_set_rail_size(self: Pin<&mut QbzHome>, tab: QString, id: QString, index: i32);
|
||||||
/// Toggle one Qobuz-Playlists category tag by slug. Client-side over
|
/// Toggle one Qobuz-Playlists category tag by slug. Client-side over
|
||||||
/// the cached cards; an empty selection shows everything.
|
/// the cached cards; an empty selection shows everything.
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
@@ -371,7 +356,6 @@ pub struct QbzHomeRust {
|
|||||||
reco_weekly_json: QString,
|
reco_weekly_json: QString,
|
||||||
reco_loading: bool,
|
reco_loading: bool,
|
||||||
reco_cache_ttl_index: i32,
|
reco_cache_ttl_index: i32,
|
||||||
discover_rail_size_index: i32,
|
|
||||||
playlist_tags_json: QString,
|
playlist_tags_json: QString,
|
||||||
discover_browse_json: QString,
|
discover_browse_json: QString,
|
||||||
discover_browse_loading: bool,
|
discover_browse_loading: bool,
|
||||||
@@ -411,10 +395,6 @@ impl Default for QbzHomeRust {
|
|||||||
// by `recommendations_qt::publish_cache_ttl_index()` at boot, once
|
// by `recommendations_qt::publish_cache_ttl_index()` at boot, once
|
||||||
// the per-user directory is known.
|
// the per-user directory is known.
|
||||||
reco_cache_ttl_index: 2,
|
reco_cache_ttl_index: 2,
|
||||||
// The uncapped preset's index; the real value is pushed by
|
|
||||||
// `discover_config_qt::publish_rail_size_index()` at boot, once the
|
|
||||||
// per-user directory is known.
|
|
||||||
discover_rail_size_index: 4,
|
|
||||||
// "{}" so the view's JSON.parse never throws on the first frame.
|
// "{}" so the view's JSON.parse never throws on the first frame.
|
||||||
playlist_tags_json: QString::from("{}"),
|
playlist_tags_json: QString::from("{}"),
|
||||||
reco_loading: false,
|
reco_loading: false,
|
||||||
@@ -490,8 +470,8 @@ impl qbz_home::QbzHome {
|
|||||||
crate::recommendations_qt::set_cache_ttl_index(index);
|
crate::recommendations_qt::set_cache_ttl_index(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn discover_set_rail_size(self: Pin<&mut Self>, index: i32) {
|
pub fn discover_set_rail_size(self: Pin<&mut Self>, tab: QString, id: QString, index: i32) {
|
||||||
crate::discover_config_qt::set_rail_size_index(index);
|
crate::discover_config_qt::set_rail_size_index(&tab.to_string(), &id.to_string(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_playlist_tag(self: Pin<&mut Self>, slug: QString) {
|
pub fn toggle_playlist_tag(self: Pin<&mut Self>, slug: QString) {
|
||||||
|
|||||||
@@ -120,6 +120,18 @@ pub struct HomeCard {
|
|||||||
pub item_kind: String,
|
pub item_kind: String,
|
||||||
/// Playlist rows: the UPPERCASE first-tag category subtag.
|
/// Playlist rows: the UPPERCASE first-tag category subtag.
|
||||||
pub category: String,
|
pub category: String,
|
||||||
|
/// Playlist rows: up to four MEMBER covers for the card's mosaic arm, when
|
||||||
|
/// the playlist has no single graphic of its own. Most do not — which is
|
||||||
|
/// why the detail page falls back to a collage — so without these a rail
|
||||||
|
/// fed from local history draws placeholders. Remote urls or local file
|
||||||
|
/// paths; `artwork_qt::cached_path` resolves both.
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub covers: Vec<String>,
|
||||||
|
/// Playlist rows: the artwork IS the playlist's own graphic (or a custom
|
||||||
|
/// cover), so the card contain-fits it instead of building a mosaic. Those
|
||||||
|
/// images are landscape and cropping butchers them.
|
||||||
|
#[serde(default, rename = "playlistOwnImage", skip_serializing_if = "std::ops::Not::not")]
|
||||||
|
pub playlist_own_image: bool,
|
||||||
/// Playlist rows: ALL of the playlist's tag SLUGS — the material the
|
/// Playlist rows: ALL of the playlist's tag SLUGS — the material the
|
||||||
/// client-side category filter matches against (home.rs
|
/// client-side category filter matches against (home.rs
|
||||||
/// `PlaylistCardData.tags`). Distinct from `category`, which is one tag's
|
/// `PlaylistCardData.tags`). Distinct from `category`, which is one tag's
|
||||||
@@ -676,6 +688,9 @@ fn order_by_prefs(
|
|||||||
tab: qbz_app::settings::discover_prefs::DiscoveryTab,
|
tab: qbz_app::settings::discover_prefs::DiscoveryTab,
|
||||||
most_streamed_variant: &str,
|
most_streamed_variant: &str,
|
||||||
include_tail: bool,
|
include_tail: bool,
|
||||||
|
// Per-rail item cap, by PREF id, `0`/absent = uncapped. Read once per
|
||||||
|
// assemble and passed in, not looked up per rail.
|
||||||
|
sizes: &std::collections::HashMap<String, i64>,
|
||||||
) -> Vec<HomeSection> {
|
) -> Vec<HomeSection> {
|
||||||
use qbz_app::settings::discover_prefs::DiscoveryTab;
|
use qbz_app::settings::discover_prefs::DiscoveryTab;
|
||||||
let tab_prefs = prefs.tab(tab);
|
let tab_prefs = prefs.tab(tab);
|
||||||
@@ -690,7 +705,22 @@ fn order_by_prefs(
|
|||||||
pref.id.as_str()
|
pref.id.as_str()
|
||||||
};
|
};
|
||||||
if let Some(section) = candidates.iter().find(|s| s.id == key) {
|
if let Some(section) = candidates.iter().find(|s| s.id == key) {
|
||||||
gated.push(section.clone());
|
let mut section = section.clone();
|
||||||
|
// Keyed by the PREF id and applied HERE, not over the assembled
|
||||||
|
// lists: `mostStreamed` resolves to a per-tab variant candidate
|
||||||
|
// (`mostStreamed#album`), so the section's own id is not always the
|
||||||
|
// id the user configured. This is the only place both are in hand.
|
||||||
|
//
|
||||||
|
// The cut lives at assembly time and not where the candidates are
|
||||||
|
// built, so changing a number re-renders from the cache on the next
|
||||||
|
// frame — exactly like a section toggle — instead of forcing a
|
||||||
|
// round trip to /discover/index.
|
||||||
|
if let Some(&cap) = sizes.get(pref.id.as_str()) {
|
||||||
|
if cap > 0 {
|
||||||
|
section.items.truncate(cap as usize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gated.push(section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if include_tail {
|
if include_tail {
|
||||||
@@ -820,39 +850,23 @@ fn assemble(
|
|||||||
prefs: &qbz_app::settings::discover_prefs::DiscoverPrefs,
|
prefs: &qbz_app::settings::discover_prefs::DiscoverPrefs,
|
||||||
) -> DiscoverSections {
|
) -> DiscoverSections {
|
||||||
use qbz_app::settings::discover_prefs::DiscoveryTab;
|
use qbz_app::settings::discover_prefs::DiscoveryTab;
|
||||||
let home = order_by_prefs(candidates, prefs, DiscoveryTab::Home, "mostStreamed", true);
|
// "Items per carousel" — PER RAIL (the Tauri shape; a single global number
|
||||||
let editor = order_by_prefs(candidates, prefs, DiscoveryTab::EditorPicks, "mostStreamed#album", false);
|
// was this port's simplification and it lost the point of the feature). One
|
||||||
|
// store read for all three tabs.
|
||||||
|
let sizes = crate::discover_config_qt::rail_sizes();
|
||||||
|
let home = order_by_prefs(candidates, prefs, DiscoveryTab::Home, "mostStreamed", true, &sizes);
|
||||||
|
let editor = order_by_prefs(candidates, prefs, DiscoveryTab::EditorPicks, "mostStreamed#album", false, &sizes);
|
||||||
// For You: the local-history arms (recentPlaceholder) self-hide on
|
// For You: the local-history arms (recentPlaceholder) self-hide on
|
||||||
// empty data in Slint — drop them here (local store out of scope).
|
// empty data in Slint — drop them here (local store out of scope).
|
||||||
let for_you: Vec<HomeSection> = order_by_prefs(candidates, prefs, DiscoveryTab::ForYou, "mostStreamed", false)
|
let for_you: Vec<HomeSection> = order_by_prefs(candidates, prefs, DiscoveryTab::ForYou, "mostStreamed", false, &sizes)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|s| s.kind != "recentPlaceholder")
|
.filter(|s| s.kind != "recentPlaceholder")
|
||||||
.collect();
|
.collect();
|
||||||
// "Items per carousel" (the Discover configurator). ONE read per assemble,
|
DiscoverSections {
|
||||||
// applied here rather than where the candidates are built — the point of
|
|
||||||
// putting it at assembly time is that changing the number re-renders from
|
|
||||||
// the cache on the next frame, exactly like a section toggle, instead of
|
|
||||||
// forcing a round trip to /discover/index every time somebody nudges it.
|
|
||||||
//
|
|
||||||
// `0` = uncapped, which is the default and is what this page did before the
|
|
||||||
// setting existed. It reaches the rails that go through `assemble`, i.e.
|
|
||||||
// every rail the configurator can list; Pinned, Radio Stations and Qobuz
|
|
||||||
// Mixes ride their own bridge documents and are untouched.
|
|
||||||
let mut out = DiscoverSections {
|
|
||||||
home,
|
home,
|
||||||
editor,
|
editor,
|
||||||
for_you,
|
for_you,
|
||||||
};
|
|
||||||
let cap = crate::discover_config_qt::rail_size();
|
|
||||||
if cap > 0 {
|
|
||||||
let cap = cap as usize;
|
|
||||||
for list in [&mut out.home, &mut out.editor, &mut out.for_you] {
|
|
||||||
for section in list.iter_mut() {
|
|
||||||
section.items.truncate(cap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The SET of section ids the POC can actually RENDER for a tab — the
|
/// The SET of section ids the POC can actually RENDER for a tab — the
|
||||||
@@ -1569,10 +1583,23 @@ pub(crate) fn map_recent_playlist(
|
|||||||
id: p.playlist_id,
|
id: p.playlist_id,
|
||||||
title: p.title,
|
title: p.title,
|
||||||
artist: p.owner,
|
artist: p.owner,
|
||||||
// A local playlist's cover is already a file on disk; a Qobuz one is a
|
// TWO ARMS, exactly like the card: a single graphic of its own gets
|
||||||
// URL the artwork cache resolves like every other rail.
|
// contain-fitted, everything else builds a mosaic out of member covers.
|
||||||
art_path: if local { p.artwork_url.clone() } else { String::new() },
|
// The first cut published only `artwork_url` — and for a Qobuz playlist
|
||||||
art_url: if local { String::new() } else { p.artwork_url },
|
// that field is the DETAIL page's cover, which is empty whenever the
|
||||||
|
// playlist has no graphic of its own (most of them), so the rail drew
|
||||||
|
// placeholders. A local playlist has no Qobuz graphic at all and needs
|
||||||
|
// the mosaic by definition.
|
||||||
|
//
|
||||||
|
// Everything goes in `art_url` and `attach_cached` fills `art_path` —
|
||||||
|
// `artwork_qt::cached_path` already classifies http, Plex and
|
||||||
|
// ALREADY-ON-DISK paths, so a custom cover or a local file resolves
|
||||||
|
// through the same pass as a Qobuz url. That is the convention the
|
||||||
|
// recently-played ALBUM rail beside this one uses; splitting the two by
|
||||||
|
// hand here would just be a second, worse copy of `classify`.
|
||||||
|
playlist_own_image: p.own_image,
|
||||||
|
covers: p.covers,
|
||||||
|
art_url: p.artwork_url,
|
||||||
..HomeCard::default()
|
..HomeCard::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -969,7 +969,12 @@ pub async fn load(runtime: &Runtime, playlist_id: &str) -> bool {
|
|||||||
title: &doc.name,
|
title: &doc.name,
|
||||||
owner: "",
|
owner: "",
|
||||||
owner_id: "",
|
owner_id: "",
|
||||||
artwork_url: doc.covers.first().map(String::as_str).unwrap_or(""),
|
// A local playlist never has a Qobuz graphic, so unless the user
|
||||||
|
// set a cover it is the MOSAIC that carries the card — the same
|
||||||
|
// shape this page's own header takes.
|
||||||
|
artwork_url: &doc.cover_path,
|
||||||
|
own_image: doc.has_custom_cover,
|
||||||
|
covers: &doc.covers,
|
||||||
track_count: doc.track_count.max(0) as u32,
|
track_count: doc.track_count.max(0) as u32,
|
||||||
source: "local",
|
source: "local",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -660,7 +660,6 @@ fn on_session_entered() {
|
|||||||
// default is just the store's default (48 h) and would silently misreport
|
// default is just the store's default (48 h) and would silently misreport
|
||||||
// a user who chose something else until they changed it again.
|
// a user who chose something else until they changed it again.
|
||||||
recommendations_qt::publish_cache_ttl_index();
|
recommendations_qt::publish_cache_ttl_index();
|
||||||
discover_config_qt::publish_rail_size_index();
|
|
||||||
|
|
||||||
// Restore the persisted player volume so audio starts at the SAVED level
|
// Restore the persisted player volume so audio starts at the SAVED level
|
||||||
// (1:1 with qbz/src/main.rs:220-227). Without it every launch started at
|
// (1:1 with qbz/src/main.rs:220-227). Without it every launch started at
|
||||||
|
|||||||
@@ -1166,7 +1166,15 @@ pub async fn load(runtime: &Arc<AppRuntime<LoggingAdapter>>, playlist_id: u64) -
|
|||||||
title: &doc.name,
|
title: &doc.name,
|
||||||
owner: &doc.owner,
|
owner: &doc.owner,
|
||||||
owner_id: &doc.owner_id.to_string(),
|
owner_id: &doc.owner_id.to_string(),
|
||||||
|
// The playlist's OWN graphic when it has one (or the user's
|
||||||
|
// custom cover); the mosaic covers otherwise. Publishing only the
|
||||||
|
// first field is what left the recents rail blank: `cover_url` is
|
||||||
|
// empty for every playlist without a graphic of its own, which is
|
||||||
|
// most of them, and is precisely why this page falls back to a
|
||||||
|
// collage.
|
||||||
artwork_url: &doc.cover_url,
|
artwork_url: &doc.cover_url,
|
||||||
|
own_image: !doc.cover_url.is_empty(),
|
||||||
|
covers: &doc.covers,
|
||||||
track_count: doc.track_count.max(0) as u32,
|
track_count: doc.track_count.max(0) as u32,
|
||||||
source: "qobuz",
|
source: "qobuz",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user