feat(shell): active purchase downloads live in the sidebar, as a ring when compact

The Downloads section leaves the nav flyout. With the sidebar open, the
purchases downloading now sit under the Purchases entry, one row per
album with a thin progress bar, each reopening its detail. With the
sidebar collapsed, and in the compact header nav when it is closed, they
fold into one progress ring whose hover bubble lists every album with
its count and percentage. The ring is a Canvas that repaints only when a
publish moves the value — no timer, per the repaint-pulse rule. The
active set now carries done/total/percent per album.

cc
This commit is contained in:
vicrodh committed 2026-09-02 07:11:03 -06:00
1 parent db1d36537b
commit a5376e9064
4 files changed
+279

No files matched your search

+1
View File
@@ -585,6 +585,7 @@ fn main() {
"qml/controls/QbzToggle.qml",
"qml/controls/QbzToolButton.qml",
"qml/controls/QbzTooltip.qml",
"qml/controls/QbzProgressRing.qml",
// Applied-filters tooltip: the trigger a filter control mounts
// beside itself (it writes the shell channel QbzTooltip reads).
"qml/controls/QbzFilterTip.qml",
@@ -0,0 +1,57 @@
// QbzProgressRing — a determinate ring (0..1) for a compact "something is
// downloading" glyph: the sidebar's mini rail and the header's compact nav,
// where a text row has no room.
//
// It repaints ONLY when `value` changes (one Canvas.requestPaint per publish),
// never on a timer — the repaint-pulse rule (CLAUDE.md, qbz-qt) forbids a
// continuous animation here, and a download publishes at most once per track.
import QtQuick
import "../theme"
Item {
id: root
QbzTheme { id: theme }
/// 0.0 .. 1.0
property real value: 0
/// Ring diameter in px.
property int size: 18
/// Stroke width in px.
property real stroke: 2.5
property color trackColor: theme.borderSubtle
property color barColor: theme.accent
width: size
height: size
onValueChanged: ring.requestPaint()
onBarColorChanged: ring.requestPaint()
onTrackColorChanged: ring.requestPaint()
Canvas {
id: ring
anchors.fill: parent
antialiasing: true
onPaint: {
var ctx = getContext("2d")
ctx.reset()
var cx = width / 2, cy = height / 2
var r = Math.max(1, Math.min(cx, cy) - root.stroke / 2)
ctx.lineWidth = root.stroke
ctx.lineCap = "round"
ctx.strokeStyle = root.trackColor
ctx.beginPath()
ctx.arc(cx, cy, r, 0, Math.PI * 2)
ctx.stroke()
var v = Math.max(0, Math.min(1, root.value))
if (v > 0) {
ctx.strokeStyle = root.barColor
ctx.beginPath()
ctx.arc(cx, cy, r, -Math.PI / 2, -Math.PI / 2 + Math.PI * 2 * v)
ctx.stroke()
}
}
}
}
+66
View File
@@ -205,6 +205,27 @@ Rectangle {
readonly property bool headerCompactOn: QbzShell.sidebarState === 2
|| (!QbzShell.navInSidebar && QbzShell.navHeaderCompact)
// Purchases downloading now (see Sidebar.qml's twin block).
readonly property var activeDownloads: {
try { return JSON.parse(QbzPurchases.activeDownloadsJson || "[]") } catch (e) { return [] }
}
readonly property real activeDownloadsOverall: {
var rows = root.activeDownloads
if (rows.length === 0) return 0
var sum = 0
for (var i = 0; i < rows.length; i++) sum += (rows[i].percent || 0)
return sum / rows.length / 100
}
readonly property string activeDownloadsSummary: {
var rows = root.activeDownloads
var lines = []
for (var i = 0; i < rows.length; i++)
lines.push((rows[i].title || QbzSession.tr("Purchases", QbzSession.trRev))
+ " — " + (rows[i].done || 0) + "/" + (rows[i].total || 0)
+ " · " + (rows[i].percent || 0) + "%")
return lines.join("\n")
}
// Full text tab (HeaderBar.slint NavTab): 30px tall, radius sm, icon 14
// (dropped under 1140px), label 11px — semibold + elevated fill when the
// section is the current view.
@@ -464,6 +485,51 @@ Rectangle {
compact: true
anchors.verticalCenter: parent.verticalCenter
}
// Purchases downloading now, as one ring (the sidebar is closed
// or the nav lives up here, so there is no row to list them in);
// the per-album detail is the hover bubble. Absent while idle.
Item {
visible: root.activeDownloads.length > 0
width: visible ? 30 : 0
height: 30
anchors.verticalCenter: parent.verticalCenter
QbzProgressRing {
anchors.centerIn: parent
size: 18
value: root.activeDownloadsOverall
}
MouseArea {
id: hdrRingArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: QbzShell.navigateTo("purchases")
}
ToolTip {
visible: hdrRingArea.containsMouse
delay: 0
timeout: -1
text: root.activeDownloadsSummary
x: Math.round((parent.width - width) / 2)
y: parent.height + 6
contentItem: Text {
text: root.activeDownloadsSummary
color: theme.textPrimary
font.pixelSize: 11
font.weight: theme.weightMedium
leftPadding: 9
rightPadding: 9
topPadding: 6
bottomPadding: 6
}
background: Rectangle {
color: theme.surfaceElevated
radius: 4
border.width: 1
border.color: theme.borderMuted
}
}
}
// Thin separator + the playlists flyout button — ONLY while the
// sidebar is really closed. In the opt-in always-compact mode the
// sidebar list is still on screen, so the button stays away
+155
View File
@@ -83,6 +83,30 @@ Rectangle {
id: root
property bool mini: QbzShell.sidebarState === 1
// Purchases downloading now — `QbzPurchases.activeDownloadsJson`, parsed
// once per publish (guarded: "[]" on the pre-boot frame).
readonly property var activeDownloads: {
try { return JSON.parse(QbzPurchases.activeDownloadsJson || "[]") } catch (e) { return [] }
}
/// Mean completion across the active albums, 0..1, for the mini ring.
readonly property real activeDownloadsOverall: {
var rows = root.activeDownloads
if (rows.length === 0) return 0
var sum = 0
for (var i = 0; i < rows.length; i++) sum += (rows[i].percent || 0)
return sum / rows.length / 100
}
/// The hover bubble's text: one line per album, "Title — 7/14 · 50%".
readonly property string activeDownloadsSummary: {
var rows = root.activeDownloads
var lines = []
for (var i = 0; i < rows.length; i++)
lines.push((rows[i].title || QbzSession.tr("Purchases", QbzSession.trRev))
+ " — " + (rows[i].done || 0) + "/" + (rows[i].total || 0)
+ " · " + (rows[i].percent || 0) + "%")
return lines.join("\n")
}
// The shell's ONE hover-tooltip overlay (controls/QbzTooltip.qml), fed in
// by AppShell. Null when this component is mounted in isolation, in which
// case the rail simply shows no bubble.
@@ -562,6 +586,137 @@ Rectangle {
|| QbzShell.currentView === "purchase-album"
onActivated: QbzShell.navigateTo("purchases")
}
// Purchases DOWNLOADING right now. A download is process-wide
// and survives leaving its page (purchases_qt's store); this is
// how the user finds it again. Expanded: one row per album with
// a thin progress bar. Mini: one ring for the whole set, with
// the per-album detail in its hover bubble. Absent while idle.
Item {
id: dlBlock
readonly property var rows: root.activeDownloads
visible: root.purchasesVisible && rows.length > 0
width: parent.width
height: !visible ? 0 : (root.mini ? theme.sidebarMiniRow : dlCol.implicitHeight)
Column {
id: dlCol
visible: !root.mini
width: parent.width
spacing: 2
Repeater {
model: root.mini ? [] : dlBlock.rows
delegate: Rectangle {
id: dlRow
required property var modelData
width: parent ? parent.width : 0
height: 34
radius: 6
color: dlArea.containsMouse ? theme.surfaceHover : "transparent"
Column {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 8
anchors.rightMargin: 8
anchors.verticalCenter: parent.verticalCenter
spacing: 4
Row {
width: parent.width
spacing: 6
QbzIcon {
name: "cloud-download"
width: 14
height: 14
anchors.verticalCenter: parent.verticalCenter
tintName: "accent"
}
Text {
width: parent.width - 20 - 34
text: dlRow.modelData.title || QbzSession.tr("Purchases", QbzSession.trRev)
color: theme.textSecondary
font.pixelSize: 12
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
}
Text {
width: 28
text: (dlRow.modelData.percent || 0) + "%"
color: theme.textMuted
font.pixelSize: 11
horizontalAlignment: Text.AlignRight
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle {
width: parent.width
height: 3
radius: 1.5
color: theme.borderSubtle
Rectangle {
width: parent.width * Math.max(0, Math.min(1, (dlRow.modelData.percent || 0) / 100))
height: parent.height
radius: parent.radius
color: theme.accent
}
}
}
MouseArea {
id: dlArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
QbzPurchases.openAlbum(dlRow.modelData.id || "")
QbzShell.navigateTo("purchase-album")
}
}
}
}
}
// Mini: the ring, with the detail on hover.
Item {
visible: root.mini
width: parent.width
height: parent.height
QbzProgressRing {
anchors.centerIn: parent
size: 18
value: root.activeDownloadsOverall
}
MouseArea {
id: ringArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: QbzShell.navigateTo("purchases")
}
ToolTip {
visible: ringArea.containsMouse
delay: 0
timeout: -1
text: root.activeDownloadsSummary
x: parent.width + 8
y: Math.round((parent.height - height) / 2)
contentItem: Text {
text: root.activeDownloadsSummary
color: theme.textPrimary
font.pixelSize: 11
font.weight: theme.weightMedium
leftPadding: 9
rightPadding: 9
topPadding: 6
bottomPadding: 6
}
background: Rectangle {
color: theme.surfaceElevated
radius: 4
border.width: 1
border.color: theme.borderMuted
}
}
}
}
}
// Hairline under the section nav — mounted with the nav block, not