feat(qbz-qt): phase 4 — live playback, queue, and transport via QbzCore
Album-card click plays the album: get_album -> QueueTrack vec -> set_queue -> play_track_resolved (tier walk stays in the core). 1 Hz poll publishes position/meta/quality into the NowPlaying model; end-of- track edge auto-advances with meta refresh (traced live: 24-bit/48kHz CMAF stream, position advancing, track 2/3 transitions). Transport invokables rewired to real core calls; queue panel shows NOW PLAYING + numbered UP NEXT from get_queue_state. Public QbzCore API proved sufficient — protected audio/player crates untouched. Named gaps: no mute API, no playback event stream, auto-advance/prefetch semantics remain frontend glue (~150 lines every UI must port). km
This commit is contained in:
7 files changed
+890
-85
No files matched your search
@@ -1,15 +1,18 @@
|
||||
// Right-side Queue panel — QML port of
|
||||
// crates/qbz-ui/ui/shell/QueueSidebar.slint.
|
||||
//
|
||||
// Header with the two tabs ("Queue" / "History"), the NOW PLAYING card
|
||||
// area, the UP NEXT list region, and the EMPTY states (the queue is empty
|
||||
// until phase 4 — QbzBridge.queueModel is an empty QVariantList).
|
||||
// Header with the two tabs ("Queue" / "History"), the NOW PLAYING card,
|
||||
// the UP NEXT list, and the empty states. Phase 4: the Queue tab renders
|
||||
// the REAL queue (QbzBridge.queueModel — one JSON-encoded row per QVariant,
|
||||
// see the nesting POC-NOTE in playback_qt.rs `publish_queue`).
|
||||
//
|
||||
// POC-NOTE: the footer (count line + clear / save-as-playlist / infinite /
|
||||
// sleep-timer actions + inline queue search) is omitted — in the Slint
|
||||
// panel it only mounts when the queue is non-empty, which is never until
|
||||
// phase 4. Drag-reorder, pagination, the now-playing favorite toggle and
|
||||
// the sleep-timer popover are likewise phase-4 scope.
|
||||
// POC-NOTEs:
|
||||
// - The footer (count line + clear / save-as-playlist / infinite /
|
||||
// sleep-timer actions + inline queue search) is omitted — phase 4 brings
|
||||
// no queue mutations beyond play/next/previous.
|
||||
// - The History tab stays empty (no local play-history store in the POC).
|
||||
// - Row context menus, drag-reorder, pagination and the now-playing
|
||||
// favorite toggle are out of scope.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
@@ -21,7 +24,17 @@ Rectangle {
|
||||
|
||||
// Queue (0) / History (1) — Slint QueueState.tab.
|
||||
property int tab: 0
|
||||
readonly property bool queueEmpty: QbzBridge.queueModel.length === 0
|
||||
// Parsed queue rows: [{id, title, artist, duration, artPath, current}].
|
||||
readonly property var rows: {
|
||||
var out = []
|
||||
for (var i = 0; i < QbzBridge.queueModel.length; i++) {
|
||||
try { out.push(JSON.parse(QbzBridge.queueModel[i])) } catch (e) {}
|
||||
}
|
||||
return out
|
||||
}
|
||||
readonly property var currentRow: rows.length > 0 && rows[0].current ? rows[0] : null
|
||||
readonly property var upcomingRows: currentRow ? rows.slice(1) : rows
|
||||
readonly property bool queueEmpty: rows.length === 0
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
@@ -47,6 +60,87 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
// One queue row (QueueRow.slint): index or thumbnail, title, artist,
|
||||
// duration.
|
||||
component QueueRow: Rectangle {
|
||||
property var row: ({})
|
||||
property int rowIndex: 0
|
||||
property bool showNumber: true
|
||||
|
||||
height: 44
|
||||
radius: theme.radiusSm
|
||||
color: qrArea.containsMouse ? theme.surfaceHover
|
||||
: (rowIndex % 2 === 1 ? "#592a2a2a" : "transparent")
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: theme.spacingSm
|
||||
anchors.rightMargin: theme.spacingXs
|
||||
anchors.topMargin: 4
|
||||
anchors.bottomMargin: 4
|
||||
spacing: 9
|
||||
|
||||
Text {
|
||||
visible: showNumber
|
||||
width: 22
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: rowIndex + 1
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 12
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
Rectangle {
|
||||
visible: !showNumber
|
||||
width: 34
|
||||
height: 34
|
||||
radius: 4
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: theme.surfaceElevated
|
||||
clip: true
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: row.artPath
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
}
|
||||
}
|
||||
Column {
|
||||
width: parent.width - (showNumber ? 22 : 34) - 9 * 2 - durationText.implicitWidth
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
Text {
|
||||
width: parent.width
|
||||
text: row.title
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: 12
|
||||
font.weight: theme.weightMedium
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
text: row.artist
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 10
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: durationText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: row.duration
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: qrArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
// POC-NOTE: click-to-play / context menu out of scope.
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
@@ -121,58 +215,128 @@ Rectangle {
|
||||
height: parent.height - 45
|
||||
|
||||
// ===== Queue tab =====
|
||||
Column {
|
||||
Flickable {
|
||||
visible: root.tab === 0
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
spacing: 12
|
||||
clip: true
|
||||
contentWidth: width
|
||||
contentHeight: queueBody.implicitHeight
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
// NOW PLAYING section — mounts only with a current track.
|
||||
Text {
|
||||
visible: !root.queueEmpty
|
||||
text: QbzBridge.tr("NOW PLAYING")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
font.weight: theme.weightSemibold
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
// UP NEXT section — mounts only with upcoming tracks.
|
||||
Text {
|
||||
visible: !root.queueEmpty
|
||||
text: QbzBridge.tr("UP NEXT")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
font.weight: theme.weightSemibold
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
Repeater {
|
||||
model: QbzBridge.queueModel
|
||||
// Phase 4 renders real rows (44px QueueRow); unreachable
|
||||
// while the model is empty.
|
||||
delegate: Item {}
|
||||
}
|
||||
|
||||
// Empty state — no current track and no upcoming.
|
||||
Column {
|
||||
visible: root.queueEmpty
|
||||
id: queueBody
|
||||
width: parent.width
|
||||
topPadding: 48 - 10
|
||||
spacing: 6
|
||||
Text {
|
||||
width: parent.width
|
||||
text: QbzBridge.tr("Your queue is empty")
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontBody
|
||||
font.weight: theme.weightMedium
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
padding: 10
|
||||
spacing: 12
|
||||
|
||||
// NOW PLAYING section.
|
||||
Column {
|
||||
visible: root.currentRow !== null
|
||||
width: parent.width - 20
|
||||
spacing: 10
|
||||
Text {
|
||||
text: QbzBridge.tr("NOW PLAYING")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
font.weight: theme.weightSemibold
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
// Highlighted current-track card.
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 44
|
||||
radius: theme.radiusSm
|
||||
color: theme.surfaceElevated
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 6
|
||||
anchors.rightMargin: 6
|
||||
anchors.topMargin: 4
|
||||
anchors.bottomMargin: 4
|
||||
spacing: 9
|
||||
Rectangle {
|
||||
width: 34
|
||||
height: 34
|
||||
radius: 4
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: theme.surfaceCard
|
||||
clip: true
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: root.currentRow ? root.currentRow.artPath : ""
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
}
|
||||
}
|
||||
Column {
|
||||
width: parent.width - 34 - 9
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
Text {
|
||||
width: parent.width
|
||||
text: root.currentRow ? root.currentRow.title : ""
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: 12
|
||||
font.weight: theme.weightMedium
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
text: root.currentRow ? root.currentRow.artist : ""
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 10
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
text: QbzBridge.tr("Play an album or track to get started")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 12
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
|
||||
// UP NEXT section.
|
||||
Column {
|
||||
visible: root.upcomingRows.length > 0
|
||||
width: parent.width - 20
|
||||
spacing: 8
|
||||
Text {
|
||||
text: QbzBridge.tr("UP NEXT")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
font.weight: theme.weightSemibold
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
Repeater {
|
||||
model: root.upcomingRows
|
||||
delegate: QueueRow {
|
||||
width: parent ? parent.width : 0
|
||||
row: modelData
|
||||
rowIndex: index
|
||||
showNumber: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Empty state — no current track and no upcoming.
|
||||
Column {
|
||||
visible: root.queueEmpty
|
||||
width: parent.width - 20
|
||||
topPadding: 48 - 10
|
||||
spacing: 6
|
||||
Text {
|
||||
width: parent.width
|
||||
text: QbzBridge.tr("Your queue is empty")
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontBody
|
||||
font.weight: theme.weightMedium
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
text: QbzBridge.tr("Play an album or track to get started")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 12
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +355,8 @@ Rectangle {
|
||||
font.weight: theme.weightSemibold
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
// POC-NOTE: history is always empty until phase 4.
|
||||
// POC-NOTE: history is always empty until the local
|
||||
// play-history store is wired.
|
||||
Text {
|
||||
width: parent.width
|
||||
topPadding: 48 - 10
|
||||
|
||||
Reference in new issue
Block a user