fix(qt): light the playing row for a downloaded track, in every track list
The now-playing affordance — the accent pill on the row's left edge and the eq bars in the number cell — never appeared for an offline row on the very view it was played from. `TrackRow` asked one question, QbzPlayer.npTrackId === item.id and for a `qobuz_download` row the two sides come from different id spaces: the queue id is the QOBUZ CATALOG id (the offline tier is keyed on it) while every Local Library list draws the row with its `library.db` id. They never matched, so the row sat dark while its own audio played. The reference has a second published id for exactly this and the port never carried it over: `NowPlayingState.local-track-id` (playback.rs:1978-1986). This adds its twin, `QbzPlayer.npLocalTrackId`, and makes the row match either. Published for Offline rows ONLY, and that restriction is the safety of it: `source_item_id_hint` is a shared slot carrying a Plex ALBUM key and a media server's own item id for those sources, so publishing it unconditionally would hand a list a number from another id space and light the wrong row. It stays empty elsewhere, which makes the second test inert there. Scope checked by driving the window rather than reasoned about: the pill and the play glyph land on the right row for local user files, Plex, Jellyfin and Subsonic both before and after this change — offline was the only source whose id diverged. The other three surfaces that ask the same question need no alias: the queue panel and the kiosk album carry queue ids, and the purchases list carries catalog ids. qbz-qt 431/431, 4 QML audits green. cc
This commit is contained in:
3 files changed
+48
-1
No files matched your search
@@ -419,7 +419,20 @@ Rectangle {
|
||||
readonly property bool hovered: trArea.containsMouse || favArea.containsMouse
|
||||
|| moreArea.containsMouse || playArea.containsMouse
|
||||
|| chevUp.hovered || chevDown.hovered
|
||||
readonly property bool isActive: QbzPlayer.npTrackId === (item.id || "")
|
||||
// THIS row is the now-playing one. Two ids are compared, not one, and the
|
||||
// second is not redundancy: an OFFLINE row's queue id is the QOBUZ CATALOG
|
||||
// id (the offline tier is keyed on it) while every Local Library list
|
||||
// draws that row with its `library.db` id, so the first test alone can
|
||||
// never match a downloaded track on the very view it was played from — the
|
||||
// pill and the eq bars stayed dark there. `npLocalTrackId` is published
|
||||
// for Offline rows ONLY (playback_qt::refresh_now_playing says why), so
|
||||
// the second test is inert for every other source and cannot light a row
|
||||
// by colliding with an id from another space. Mirrors the reference's
|
||||
// TrackRow.slint:116-118 / TrackPlayCell.slint:85-87.
|
||||
readonly property bool isActive: (item.id || "") !== ""
|
||||
&& (QbzPlayer.npTrackId === (item.id || "")
|
||||
|| (QbzPlayer.npLocalTrackId !== ""
|
||||
&& QbzPlayer.npLocalTrackId === (item.id || "")))
|
||||
|
||||
// The animated now-playing indicator pref (AppearanceState
|
||||
// .play-indicator-animation; the toggle lives in AppearanceSettings).
|
||||
|
||||
@@ -2377,6 +2377,7 @@ pub(crate) async fn refresh_now_playing(runtime: &Arc<AppRuntime<LoggingAdapter>
|
||||
crate::now_playing::clear_track();
|
||||
crate::player_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_np_track_id(QString::from(""));
|
||||
b.as_mut().set_np_local_track_id(QString::from(""));
|
||||
});
|
||||
crate::lyrics_qt::publish_idle();
|
||||
// Tray tooltip: the no-track arm. 1:1 with the reference, where
|
||||
@@ -2403,8 +2404,27 @@ pub(crate) async fn refresh_now_playing(runtime: &Arc<AppRuntime<LoggingAdapter>
|
||||
None => track.title.clone(),
|
||||
};
|
||||
let track_id_str = track.id.to_string();
|
||||
// Active-row ALIAS for an offline row (Slint playback.rs:1978-1986). Its
|
||||
// queue id is the Qobuz catalog id — that is what the offline tier is
|
||||
// keyed on — but every Local Library list draws the row with its
|
||||
// `library.db` id, so `np_track_id` alone never matched the row the user
|
||||
// just played and the playing affordance stayed dark there.
|
||||
//
|
||||
// Restricted to Offline on purpose, and the restriction is the whole
|
||||
// safety of it: `source_item_id_hint` is a shared slot that carries a
|
||||
// Plex ALBUM key and a media server's own item id for those sources
|
||||
// (`local_queue_track`). Publishing it unconditionally would hand a row
|
||||
// list a number from another id space and light the wrong row.
|
||||
let local_track_id_str =
|
||||
if qbz_source::RawRef::from_queue_track(&track).badge == qbz_source::SourceBadge::Offline {
|
||||
track.source_item_id_hint.clone().unwrap_or_default()
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
crate::player_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_np_track_id(QString::from(track_id_str.as_str()));
|
||||
b.as_mut()
|
||||
.set_np_local_track_id(QString::from(local_track_id_str.as_str()));
|
||||
});
|
||||
log::info!(
|
||||
"[qbz-qt] now playing: '{title}' — {} ({}s)",
|
||||
|
||||
@@ -118,6 +118,18 @@ pub mod qbz_player {
|
||||
#[qproperty(bool, np_remote_volume_locked)]
|
||||
// Now-playing track id (playing-row indicator in track lists).
|
||||
#[qproperty(QString, np_track_id)]
|
||||
// The SAME row's `library.db` id, for OFFLINE rows only, and it is an
|
||||
// alias rather than a second identity: a `qobuz_download` row's queue
|
||||
// id is the QOBUZ CATALOG id (the offline tier is keyed on it), while
|
||||
// every Local Library list draws that row with its library row id. So
|
||||
// `np_track_id` alone never matched a downloaded track's row and the
|
||||
// playing affordance stayed dark on the one view the track was played
|
||||
// from. Empty for every other source — ports Slint's
|
||||
// `NowPlayingState.local-track-id` (playback.rs:1978-1986), including
|
||||
// its restriction: the hint that feeds it carries an ALBUM key for a
|
||||
// Plex row and a server item id for a media-server row, so trusting it
|
||||
// for anything but Offline would light the wrong row.
|
||||
#[qproperty(QString, np_local_track_id)]
|
||||
#[qproperty(QString, np_album)]
|
||||
#[qproperty(QString, np_album_id)]
|
||||
#[qproperty(QString, np_artist_id)]
|
||||
@@ -288,6 +300,7 @@ pub struct QbzPlayerRust {
|
||||
np_cast_protocol: QString,
|
||||
np_remote_volume_locked: bool,
|
||||
np_track_id: QString,
|
||||
np_local_track_id: QString,
|
||||
np_album: QString,
|
||||
np_album_id: QString,
|
||||
np_artist_id: QString,
|
||||
@@ -343,6 +356,7 @@ impl Default for QbzPlayerRust {
|
||||
np_cast_protocol: QString::default(),
|
||||
np_remote_volume_locked: false,
|
||||
np_track_id: QString::default(),
|
||||
np_local_track_id: QString::default(),
|
||||
np_album: QString::default(),
|
||||
np_album_id: QString::default(),
|
||||
np_artist_id: QString::default(),
|
||||
|
||||
Reference in new issue
Block a user