From bce0d68442e84be7ab545c6fa8324355a2bc7056 Mon Sep 17 00:00:00 2001 From: Ansho Rei Date: Wed, 4 Nov 2026 22:09:32 +0100 Subject: [PATCH] feat: show a track's own cover on its album page row A track whose cover is a different picture from the album's now shows that cover in its row instead of the track number. Pictures are compared decoded, since Navidrome gives every track its own cover id even when it is the album's image. The number column is as wide as the cover, so rows with and without one line up. --- CHANGELOG.md | 6 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- .../me.anshorei.Fettleshed.Remus.metainfo.xml | 1 + src/app.rs | 37 ++++++++++++++++++- ui/app.slint | 4 +- 6 files changed, 47 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d682df..576cd96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ One section per version, newest first. +## v0.8.7 (2026-11-04) + +### Features + +- On an album page, a track whose cover is a different picture from the album's shows its cover instead of its track number. Only servers that give tracks their own art, such as Navidrome, can show this; Nextcloud Music gives every track the album's cover. + ## v0.8.6 (2026-11-04) ### Bug fixes diff --git a/Cargo.lock b/Cargo.lock index eeae572..cf45643 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4385,7 +4385,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "remus" -version = "0.8.6" +version = "0.8.7" dependencies = [ "anyhow", "directories", diff --git a/Cargo.toml b/Cargo.toml index f50b7c9..ab66ecb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "remus" -version = "0.8.6" +version = "0.8.7" edition = "2024" license = "MIT" diff --git a/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml b/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml index b506292..32e71c4 100644 --- a/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml +++ b/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml @@ -20,6 +20,7 @@ + diff --git a/src/app.rs b/src/app.rs index f92f0b3..a7fbc51 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1664,6 +1664,33 @@ impl App { self.items_range = (lo, hi); } + /// The album's cover id, on an album page. + fn album_cover_id(&self) -> Option { + let page = self.current_page()?; + if !page.list || !matches!(page.source, Source::Album(_)) { + return None; + } + page.header.as_ref()?.cover.clone() + } + + /// Whether a track's cover is a different picture from its album's, so its + /// row shows the cover instead of the track number. Compared by picture: + /// Navidrome gives every track its own cover id even when it is the album's + /// image. False until both are decoded at this size; the load of either + /// redraws the row. + fn own_picture(&mut self, track: Option<&str>, album: &str, px: u32) -> bool { + let Some(track) = track.filter(|t| *t != album) else { + return false; + }; + // Starts the album cover's load at row size, which the header does not. + self.cover(album, px); + let print = |app: &mut App, id: &str| app.covers.prints.get(&(id.to_string(), px)).copied(); + match (print(self, track), print(self, album)) { + (Some(t), Some(a)) => t != a, + _ => false, + } + } + fn playing_id(&self) -> Option<&str> { self.current.and_then(|i| self.queue.get(i)).map(|s| s.id.as_str()) } @@ -1675,7 +1702,11 @@ impl App { Target::Song(i) => page.songs.get(i).map(|s| s.id.as_str()) == self.playing_id(), _ => false, }; + let album_cover = self.album_cover_id(); let cover = entry.cover.as_deref().and_then(|id| self.cover(id, px)); + let show_art = entry.show_art + || matches!(entry.target, Target::Song(_)) + && album_cover.is_some_and(|album| self.own_picture(entry.cover.as_deref(), &album, px)); let level = match entry.target { Target::Setting(Setting::CoverBackdrop) => Some(self.settings.cover_backdrop as f32 / 100.0), _ => None, @@ -1691,7 +1722,7 @@ impl App { has_cover: cover.is_some(), cover: cover.unwrap_or_default(), round: entry.round, - show_art: entry.show_art, + show_art, playing, slider: level.is_some(), level: level.unwrap_or_default(), @@ -1926,9 +1957,11 @@ impl App { // Refresh whatever shows this cover. let (lo, hi) = self.items_range; + // Every track row of an album compares its picture with the album's. + let album = self.album_cover_id().as_deref() == Some(id); let rows: Vec = match self.current_page() { Some(p) => (lo..hi.min(p.entries.len())) - .filter(|&i| p.entries[i].cover.as_deref() == Some(id)) + .filter(|&i| album || p.entries[i].cover.as_deref() == Some(id)) .collect(), None => Vec::new(), }; diff --git a/ui/app.slint b/ui/app.slint index 5a5e223..e95c3a2 100644 --- a/ui/app.slint +++ b/ui/app.slint @@ -213,8 +213,10 @@ component Row inherits Rectangle { round: root.item.round; } } + // As wide as the art, so a row with a cover and a row with a number + // line up, as on an album where some tracks have their own cover. if !root.item.show-art: Text { - width: 34px * Theme.s; + width: 46px * Theme.s; text: root.item.playing ? "▶" : root.item.number; font-size: 15px * Theme.s; color: root.item.playing ? Theme.highlight : Theme.faint;