Files
qbz/crates/qbz-qt/qml/cards/ArtistCard.qml
T
vicrodh 494596616e feat(qt): port the Blacklist manager for artists and albums
The port had a 67-line settings row showing two counters and a header saying
the Manage chevron was "NOT shipped — this port has no Blacklist Manager view
for it to open". The Slint has 1,114 lines of manager plus the consumer surfaces
that make the feature mean anything.

- src/artist_blacklist.rs is a 1:1 port of the reference's per-user lifecycle,
  including the fail-open asymmetry (is_enabled reads TRUE when there is no
  session, everything else false/empty) and the byte-identical NO_SESSION_ERR.
  src/reco_dismiss_qt.rs carries the reco-dismissal store. Both are bound in
  ALL THREE session-activation paths — the offline one included, because the
  reference records that Tauri never bound it offline and blacklisted artists
  leaked into offline surfaces — and torn down on logout, or the next account
  inherits them.
- The manager view: three tabs (bordered, ADR-008 — no pills), search, sort,
  the enable toggle, the disabled warning banner, the four body branches per
  tab in their load-bearing order, windowed lists, and the clear-all confirm.
  Reached from Settings only, exactly like the Slint; no sidebar entry.
- Every one of the ten store mutations publishes TWICE — its own document and
  publish_settings() — because the Settings counters live in a different
  document and nav_qt::back() re-runs no per-view load. Without it,
  Manage -> unblock -> Back showed pre-mutation counters. The Slint gets this
  free from a shared global.
- The search field is driven imperatively, not by a binding: QbzLineEdit's X
  used to destroy the binding, after which the box went blank while the list
  stayed filtered.
- Consumer surfaces, which is where the feature actually lives: the album card
  and album list row gained "Block this album", the artist card gained the
  3-arg "Not interested", the album header menu gained Block/Unblock swapping
  on state, and the artist page gained the Show/Blacklist flip plus the amber
  hidden banner with its "Show artist" button. album_qt and artist_qt now seed
  isAlbumBlocked / isBlacklisted at document build time — without the seed an
  already-blocked album offered "Block this album" and the first click
  UN-blocked it, the same lie the pin glyph told before isPinned existed.
- search_qt passed &Default::default() for both blacklist snapshots, so nothing
  was filtered anywhere and a greyed row still played. It now passes the real
  snapshots at both call sites.
- The 17 toasts the spec had dropped for want of a toast host are wired: that
  premise stopped being true when toast_qt landed, and a Clear All that failed
  with NO_SESSION_ERR was completely silent. Their msgids are in all eight
  catalogues; the five album-axis ones existed only in es and nl.

Also fixed in passing, pre-existing on this branch and unrelated to the
blacklist: ArtistView's library tab read `libTracks` unqualified from a child
of the object that declares it, which QML resolves against the component root,
not the enclosing object — so the "Tracks" heading threw a ReferenceError and
never rendered. Found by forcing the artist route in the offscreen smoke, which
no earlier gate did.

cc
2026-07-29 21:24:12 -06:00

329 lines
15 KiB
QML

// ArtistCard — THE artist card (discover/ArtistGridCard.slint), shared by
// every surface since phase 21: Home/Editor/ForYou artist rails, the
// Pinned rail, the Library artist grids + All feed, the Search all-tab
// carousels + artists grid + most-popular artist hero. (The Slint mounts
// ArtistGridCard at 200x246 in ALL of these — the POC's old 160x220
// Home/Search cards replicated the legacy ArtistCard the Slint only uses
// on surfaces the POC does not have.)
//
// 200x246: 200px surface-card frame + 190px circle (gradient + user glyph
// until the artwork resolves), hover scrim 0.55 CLIPPED TO THE CIRCLE,
// overlay row at y=113 (follow? / play / more), pin badge top-right of
// the frame, then the meta block (centered name, optional subtitle).
//
// item contract: { id, title, subtitle, following | isFavorite } plus the
// scalar artSource / artworkUrl / isPinned props (the AlbumCard pattern).
// The follow flag arrives under TWO names because the producers spell it
// differently and both mean the same row state: `following` (search_qt
// ArtistRow, derived from fav_cache) and `isFavorite` (home_qt HomeCard /
// library_qt FeedItem — for an artist, "in the library" IS "followed", they
// are the same `favorite/create?artist_ids=` write).
//
// Arms:
// - followMode: "toggle" (default, = ArtistGridCard.slint's own default) |
// "none" — the overlay follow button + the menu Follow row. The Slint
// reference passes "none" from exactly two places: the label page's
// artist carousel (LabelPageView.slint:524) and the Library artist grids
// (FavoritesView.slint:1831/1865). Everything else shows it.
// - followKind: "artist" (default) | "label" — ArtistGridCard.slint's
// `follow-kind`, the kind the follow write is sent as.
// - subtitle: meta switches to 1-line name + muted subtitle (the Slint
// "Similar to…"/search arm); empty = wrap-2 name.
//
// --- Menu inventory vs discover/ArtistGridCard.slint -------------------
// Open artist · Play · Follow/Following (show-follow) · Not interested
// All four are live; "Not interested" rides `hasNotInterestedSeam` (default
// on) and writes the reco-dismissal store through QbzBlacklist.
// ⋯ and a right press on the portrait or the name open the same menu.
import QtQuick
import com.blitzfc.qbz
import "../controls"
import "../theme"
Rectangle {
id: root
property var item: ({})
// Host-resolved artwork path (the AlbumCard artSource pattern).
property string artSource: ""
// Remote cover URL for the pin payload ("" when the host has none).
property string artworkUrl: ""
// Pinned state (AlbumCard pattern: scalar prop, optimistic flip on
// click — the model re-publish re-creates the delegate).
property bool isPinned: false
property string followMode: "toggle"
property string followKind: "artist"
// --- "Not interested" (the reco-scoped dismissal) --------------------
// LIVE since QbzBlacklist landed: `dismissArtist(id, name, imageUrl)`
// writes the reco-dismissal store (NOT the artist blacklist). Kept as a
// property, not inlined, so a host whose `item.id` is not a Qobuz artist
// id can turn it off. Live BACKFILL is out of scope — the card leaves the
// rails on the next publish, not on the click (src/recommendations_qt.rs
// documents the retained-overflow drop).
//
// `hasFollowSeam` is GONE, and the header comment it carried ("There is
// NO artist-follow invokable on the Qt bridge") was simply wrong:
// `library_bridge.rs` declares `library_toggle_favorite(kind, id)`,
// `library_qt::toggle_favorite` routes "artist" (and "label") straight to
// `add_favorite` / `remove_favorite`, and ArtistView's own header button
// has been calling it all along. The constant made the follow affordance
// disappear from EVERY artist card in the app.
property bool hasNotInterestedSeam: true
color: "transparent"
QbzTheme { id: theme }
// ArtistGridCard.slint:89 — `show-follow: follow-mode != "none"`.
readonly property bool showFollow: followMode !== "none"
readonly property bool overlayOn: agArea.containsMouse || pinArea.containsMouse
|| agFollow.hovered || agPlay.hovered || agMore.hovered
implicitWidth: 200
implicitHeight: 246
// --- Follow state (a real QML property, never `item.following`) ------
// Same reason as rows/TrackRow.qml's `favorite`: `item` is a plain JS
// object, so mutating a field on it fires no notifier and re-evaluates no
// binding — and `item: modelData` is a COPY, so the write does not reach
// the model either (both measured under qml6 6.11.1). The seed reads both
// spellings the producers publish (see the header note).
property bool following: root.item.following === true
|| root.item.isFavorite === true
onItemChanged: root.following = Qt.binding(function () {
return root.item.following === true || root.item.isFavorite === true
})
function toggleFollow() {
root.following = !root.following
QbzLibrary.libraryToggleFavorite(root.followKind, root.item.id)
}
Connections {
target: QbzLibrary
// Pin fan-out — the AlbumCard contract, artist key (see AlbumCard.qml:
// the store has no change-notify, so this signal is what keeps every
// OTHER card showing this artist honest without a republish).
function onPinChanged(key, value) {
var aid = (root.item && root.item.id !== undefined) ? root.item.id : ""
if (aid !== "" && key === "artist:" + aid)
root.isPinned = value
}
// Follow fan-out + rollback, the favourite twin of the above. The key
// is `{followKind}:{id}` so a label-follow card settles on its own
// key rather than on an artist one that happens to share the number.
function onLibraryFavoriteChanged(key, value) {
var aid = (root.item && root.item.id !== undefined) ? root.item.id : ""
if (aid !== "" && key === root.followKind + ":" + aid)
root.following = value
}
}
Column {
spacing: 0
Rectangle {
width: 200
height: 200
radius: theme.radiusSm
color: theme.surfaceCard
// 190px round portrait, centered (5px surround = the
// album-tile frame). All overlay content lives inside so it
// clips to the circle.
Rectangle {
x: 5
y: 5
width: 190
height: 190
radius: 95
clip: true
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop { position: 0.0; color: theme.surfaceElevated }
GradientStop { position: 1.0; color: theme.surfaceCard }
}
// Placeholder glyph until the artwork resolves on top.
QbzIcon {
name: "user"
width: 54
height: 54
anchors.centerIn: parent
tintName: "muted"
}
RoundedImage {
anchors.fill: parent
source: root.artSource
radius: 95
}
// Hover scrim (clipped to the circle by the parent's clip).
Rectangle {
anchors.fill: parent
radius: 95
color: "#000000"
opacity: root.overlayOn ? 0.55 : 0.0
Behavior on opacity { NumberAnimation { duration: 150 } }
}
// Card-open + hover detector (before the buttons so they
// win the pointer).
MouseArea {
id: agArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: function (mouse) {
if (mouse.button === Qt.RightButton)
agMenu.openAtCursor(agArea, mouse.x, mouse.y)
else
QbzArtist.openArtist(root.item.id)
}
}
// Hover overlay — follow? / play / more (y=113).
CardOverlayRow {
y: 113
width: parent.width
shown: root.overlayOn
CardOverlayButton {
id: agFollow
visible: root.showFollow
name: root.following ? "check" : "user-plus"
active: root.following
anchors.verticalCenter: parent.verticalCenter
onClicked: root.toggleFollow()
}
CardOverlayButton {
id: agPlay
name: "play-fill"
primary: true
anchors.verticalCenter: parent.verticalCenter
onClicked: QbzPlayer.playArtistCard(root.item.id)
}
CardOverlayButton {
id: agMore
name: "ellipsis"
anchors.verticalCenter: parent.verticalCenter
onClicked: function (mouse) { agMenu.openAtCursor(agMore, mouse.x, mouse.y) }
}
}
CardMenu {
id: agMenu
menuWidth: 196
entries: root.menuModel()
onPicked: function (a) { root.menuAction(a) }
}
}
// Pin badge — top-right of the FRAME (outside the circle clip),
// opacity follows overlay-on (the AlbumCard convention).
Rectangle {
x: parent.width - width - 8
y: 8
width: 26
height: 26
radius: 13
color: pinArea.containsMouse ? "#cc000000" : "#99000000"
opacity: root.overlayOn ? 1.0 : 0.0
Behavior on opacity { NumberAnimation { duration: 150 } }
QbzIcon {
name: root.isPinned ? "pin-filled" : "pin"
width: 14
height: 14
anchors.centerIn: parent
// On a #99000000/#cc000000 scrim — dark under every theme.
tintName: root.isPinned ? "accent" : "white"
}
MouseArea {
id: pinArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
root.isPinned = !root.isPinned
QbzLibrary.togglePin("artist", root.item.id, root.item.title,
root.item.subtitle || "", root.artworkUrl)
}
}
}
}
Item { width: 1; height: 6 }
// Meta: centered name; subtitle arm switches to 1-line + muted row.
Column {
width: 200
height: 40
spacing: 2
Text {
width: parent.width
height: root.item.subtitle ? 20 : 40
text: root.item.title || ""
color: agNameArea.containsMouse ? theme.accent : theme.textPrimary
font.pixelSize: theme.fontBody - 2
font.weight: theme.weightMedium
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: root.item.subtitle ? Text.NoWrap : Text.WordWrap
maximumLineCount: 2
elide: Text.ElideRight
MouseArea {
id: agNameArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: function (mouse) {
if (mouse.button === Qt.RightButton)
agMenu.openAtCursor(agNameArea, mouse.x, mouse.y)
else
QbzArtist.openArtist(root.item.id)
}
}
}
Text {
visible: !!root.item.subtitle
width: parent.width
height: 16
text: root.item.subtitle || ""
color: theme.textMuted
font.pixelSize: theme.fontLink - 1
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
}
// ArtistGridCard.slint's artist-menu, in its order.
function menuModel() {
var t = QbzSession.tr
var r = QbzSession.trRev
var m = [
{ "label": t("Open artist", r), "icon": "user", "action": "open" },
{ "label": t("Play", r), "icon": "play-fill", "action": "play" },
]
if (root.showFollow)
m.push({ "label": root.following ? t("Following", r) : t("Follow", r),
"icon": root.following ? "check" : "user-plus", "action": "follow" })
// Reco-scoped dismissal (NOT the blacklist) — the artist leaves the
// Recommendations rails only.
if (root.hasNotInterestedSeam)
m.push({ "label": t("Not interested", r), "icon": "thumbs-down", "action": "not-interested" })
return m
}
function menuAction(a) {
if (a === "open") QbzArtist.openArtist(root.item.id)
else if (a === "play") QbzPlayer.playArtistCard(root.item.id)
else if (a === "follow") root.toggleFollow()
// THREE args: the store persists (id, name, image_url) and only
// backfills a field that is EMPTY, so a blank first write can never be
// repaired later. `artworkUrl` first because that is the host-
// normalized REMOTE url (some producers spell the key `imageUrl`, e.g.
// LibraryView) — `item.artUrl` is the HomeCard fallback, and never
// `artSource`, which is a local file:// cache path.
else if (a === "not-interested")
QbzBlacklist.dismissArtist(root.item.id,
root.item.name || root.item.title || "",
root.artworkUrl !== "" ? root.artworkUrl : (root.item.artUrl || ""))
}
}