feat(qt): immersive player bar and search cortinilla (B5)
km
This commit is contained in:
9 files changed
+1830
-57
No files matched your search
@@ -151,6 +151,8 @@ fn main() {
|
|||||||
"qml/immersive/EqualizerBars.qml",
|
"qml/immersive/EqualizerBars.qml",
|
||||||
"qml/immersive/ImmersiveAtmosphere.qml",
|
"qml/immersive/ImmersiveAtmosphere.qml",
|
||||||
"qml/immersive/ImmersiveHeader.qml",
|
"qml/immersive/ImmersiveHeader.qml",
|
||||||
|
"qml/immersive/ImmersivePlayerBar.qml",
|
||||||
|
"qml/immersive/ImmersiveSearchCortinilla.qml",
|
||||||
"qml/immersive/ImmersiveSongCard.qml",
|
"qml/immersive/ImmersiveSongCard.qml",
|
||||||
"qml/immersive/ImmersiveTrackMeta.qml",
|
"qml/immersive/ImmersiveTrackMeta.qml",
|
||||||
"qml/immersive/ImmersiveView.qml",
|
"qml/immersive/ImmersiveView.qml",
|
||||||
@@ -159,7 +161,9 @@ fn main() {
|
|||||||
"qml/immersive/SpectrumPanel.qml",
|
"qml/immersive/SpectrumPanel.qml",
|
||||||
"qml/immersive/StaticPanel.qml",
|
"qml/immersive/StaticPanel.qml",
|
||||||
"qml/immersive/SuggestionsPanel.qml",
|
"qml/immersive/SuggestionsPanel.qml",
|
||||||
|
"qml/immersive/TinyBar.qml",
|
||||||
"qml/immersive/TrackInfoPanel.qml",
|
"qml/immersive/TrackInfoPanel.qml",
|
||||||
|
"qml/immersive/VolumeBar.qml",
|
||||||
"qml/immersive/WaveBedPanel.qml",
|
"qml/immersive/WaveBedPanel.qml",
|
||||||
"qml/theme/QbzIcon.qml",
|
"qml/theme/QbzIcon.qml",
|
||||||
"qml/theme/QbzScrollBar.qml",
|
"qml/theme/QbzScrollBar.qml",
|
||||||
|
|||||||
@@ -0,0 +1,351 @@
|
|||||||
|
// ImmersivePlayerBar — the immersive compact player (contract
|
||||||
|
// 2026-08-02-immersive-port §5.7; ImmersiveView.slint:240-458). Mounted by
|
||||||
|
// ImmersiveView as layer 5, centered, y = height-90-24, fading with the
|
||||||
|
// auto-hide chrome (the host drives the opacity binding; this component
|
||||||
|
// knows nothing about the hide timer).
|
||||||
|
//
|
||||||
|
// Bar: width min(viewport-32, 600) x 90, radius 16, #00000080, border
|
||||||
|
// #ffffff2e, shadow 32/#00000066/8 (:257-265). Composition 1:1:
|
||||||
|
// LEFT ghosts (x=24/56/88/120, y=22): favorite / shuffle / repeat / ∞
|
||||||
|
// CENTER: elapsed · prev · play-disc-48 · next · remaining (11px #ffffffbf)
|
||||||
|
// RIGHT: volume ghost (width-156) · VolumeBar 64 (width-112) · ⋯ (width-42)
|
||||||
|
// TinyBar seek at y=71, width-32 — changed(v) -> seek(min(v, npSeekableMax))
|
||||||
|
//
|
||||||
|
// GhostButton / NavButton / PlayDisc are hand-rolled here (NOT QbzIconButton):
|
||||||
|
// the Slint immersive chrome paints FIXED white-alpha glyphs/fills on the
|
||||||
|
// dark overlay under EVERY theme (#ffffffa6 idle etc.), and QbzIconButton's
|
||||||
|
// theme-following tints + fills would go dark on light themes. The header's
|
||||||
|
// capsule glyphs (ImmersiveHeader.qml) made the same call. All colors are
|
||||||
|
// Slint RRGGBBAA converted to Qt #AARRGGBB.
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Effects
|
||||||
|
import com.blitzfc.qbz
|
||||||
|
import "../controls"
|
||||||
|
import "../theme"
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// The host viewport width (the overlay root's width) — drives the
|
||||||
|
// min(viewport-32, 600) bar width without a parent-binding loop.
|
||||||
|
property real viewportWidth: 720
|
||||||
|
// The Slint bar wakes the auto-hide chrome when the ⋯ menu opens
|
||||||
|
// (:372-374); the host owns the hide timer.
|
||||||
|
signal wakeRequested()
|
||||||
|
|
||||||
|
implicitWidth: bar.width
|
||||||
|
implicitHeight: bar.height
|
||||||
|
|
||||||
|
// Volume lock, both halves, VERBATIM (contract §5.8 / trap 8;
|
||||||
|
// PlayerBar.qml:84-94): npVolumeLocked carries the ALSA-Direct hw
|
||||||
|
// derivation INSIDE it, and that local bit-perfect lock is LIFTED when a
|
||||||
|
// peer owns playback (the `&& !npIsRemote` term) so the user CAN adjust
|
||||||
|
// the remote renderer; npRemoteVolumeLocked is the sink-pushed "peer
|
||||||
|
// disallows remote volume" half.
|
||||||
|
readonly property bool volLocked:
|
||||||
|
(QbzPlayer.npVolumeLocked && !QbzPlayer.npIsRemote)
|
||||||
|
|| QbzPlayer.npRemoteVolumeLocked
|
||||||
|
|
||||||
|
// The now-playing favorite + ephemeral flags ride the queue document's
|
||||||
|
// `current` row (Slint: QueueState.now-playing-favorite /
|
||||||
|
// NowPlayingState.is-ephemeral; the PlayerBar.qml npFavorite + the
|
||||||
|
// QueuePanel.qml currentEphemeral precedents).
|
||||||
|
readonly property var queueDoc: {
|
||||||
|
try {
|
||||||
|
return JSON.parse(QbzQueue.queueJson)
|
||||||
|
} catch (e) {
|
||||||
|
return ({})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readonly property bool npFavorite: !!(queueDoc.current && queueDoc.current.isFavorite)
|
||||||
|
readonly property bool npEphemeral: !!(queueDoc.current && queueDoc.current.isEphemeral === true)
|
||||||
|
|
||||||
|
function fmt(secs) {
|
||||||
|
var m = Math.floor(secs / 60)
|
||||||
|
var s = Math.floor(secs % 60)
|
||||||
|
return m + ":" + (s < 10 ? "0" : "") + s
|
||||||
|
}
|
||||||
|
|
||||||
|
// Software-renderer detection (the ImmersiveView _noShaders idiom) —
|
||||||
|
// the two drop shadows are MultiEffect blurs; no shaders -> plain
|
||||||
|
// offset rects.
|
||||||
|
readonly property bool _noShaders: GraphicsInfo.api === GraphicsInfo.Software
|
||||||
|
|| GraphicsInfo.api === GraphicsInfo.Null
|
||||||
|
|
||||||
|
// --- Bar shadow: 32 / #00000066 / offset-y 8 (:262-265) --------------
|
||||||
|
Rectangle {
|
||||||
|
x: 0
|
||||||
|
y: 8
|
||||||
|
width: bar.width
|
||||||
|
height: bar.height
|
||||||
|
radius: 16
|
||||||
|
color: "#66000000"
|
||||||
|
layer.enabled: !root._noShaders
|
||||||
|
layer.effect: MultiEffect {
|
||||||
|
blurEnabled: true
|
||||||
|
blurMax: 64
|
||||||
|
blur: 0.5 // 32/64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: bar
|
||||||
|
width: Math.min(root.viewportWidth - 32, 600)
|
||||||
|
height: 90
|
||||||
|
radius: 16
|
||||||
|
color: "#80000000"
|
||||||
|
border.width: 1
|
||||||
|
border.color: "#2effffff"
|
||||||
|
|
||||||
|
// --- Inline chrome controls (see the file header for why these are
|
||||||
|
// NOT QbzIconButton) ----------------------------------------------
|
||||||
|
|
||||||
|
// GhostButton (:27-56): 28px circle, transparent idle, #ffffff40
|
||||||
|
// fill while ACTIVE, glyph 12px white / white-65% (opacity on the
|
||||||
|
// glyph — there is no 65%-white tint bake).
|
||||||
|
component GhostBtn: Rectangle {
|
||||||
|
property string icon: ""
|
||||||
|
property bool active: false
|
||||||
|
property bool btnEnabled: true
|
||||||
|
signal clicked()
|
||||||
|
|
||||||
|
width: 28
|
||||||
|
height: 28
|
||||||
|
radius: 14
|
||||||
|
opacity: btnEnabled ? 1.0 : 0.4
|
||||||
|
color: active ? "#40ffffff" : "transparent"
|
||||||
|
QbzIcon {
|
||||||
|
name: parent.icon
|
||||||
|
width: 12
|
||||||
|
height: 12
|
||||||
|
anchors.centerIn: parent
|
||||||
|
tintName: "white"
|
||||||
|
opacity: (parent.active || ghostArea.containsMouse) ? 1.0 : 0.65
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: ghostArea
|
||||||
|
anchors.fill: parent
|
||||||
|
enabled: parent.btnEnabled
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: parent.btnEnabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
|
onClicked: if (parent.btnEnabled) parent.clicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NavButton (:58-81): 28px circle, fill #ffffff26 -> #ffffff40 on
|
||||||
|
// hover, glyph 14px white.
|
||||||
|
component NavBtn: Rectangle {
|
||||||
|
property string icon: ""
|
||||||
|
signal clicked()
|
||||||
|
|
||||||
|
width: 28
|
||||||
|
height: 28
|
||||||
|
radius: 14
|
||||||
|
color: navArea.containsMouse ? "#40ffffff" : "#26ffffff"
|
||||||
|
QbzIcon {
|
||||||
|
name: parent.icon
|
||||||
|
width: 14
|
||||||
|
height: 14
|
||||||
|
anchors.centerIn: parent
|
||||||
|
tintName: "white"
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: navArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: parent.clicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- LEFT utility group (x=24/56/88/120, y=22; :268-300) ---------
|
||||||
|
GhostBtn {
|
||||||
|
x: 24
|
||||||
|
y: 22
|
||||||
|
icon: root.npFavorite ? "heart-filled" : "heart"
|
||||||
|
active: root.npFavorite
|
||||||
|
// Gated npHasTrack && !ephemeral (FavToggle.qml:47-48 precedent;
|
||||||
|
// an ephemeral play must leave nothing behind).
|
||||||
|
btnEnabled: QbzPlayer.npHasTrack && !root.npEphemeral
|
||||||
|
onClicked: QbzQueue.queueToggleFavorite("track", QbzPlayer.npTrackId)
|
||||||
|
}
|
||||||
|
GhostBtn {
|
||||||
|
x: 56
|
||||||
|
y: 22
|
||||||
|
icon: "shuffle"
|
||||||
|
active: QbzPlayer.npShuffle
|
||||||
|
onClicked: QbzPlayer.toggleShuffle()
|
||||||
|
}
|
||||||
|
GhostBtn {
|
||||||
|
x: 88
|
||||||
|
y: 22
|
||||||
|
icon: "repeat"
|
||||||
|
active: QbzPlayer.npRepeatMode !== 0
|
||||||
|
onClicked: QbzPlayer.cycleRepeat()
|
||||||
|
}
|
||||||
|
GhostBtn {
|
||||||
|
x: 120
|
||||||
|
y: 22
|
||||||
|
icon: "infinity"
|
||||||
|
active: root.queueDoc.infinitePlay === true
|
||||||
|
onClicked: QbzQueue.queueToggleInfinitePlay()
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- CENTER playback group (:303-336): positioned from the play
|
||||||
|
// disc so play is exactly centered ------------------------------
|
||||||
|
Text {
|
||||||
|
x: bar.width / 2 - 108
|
||||||
|
y: 31
|
||||||
|
width: 42
|
||||||
|
text: root.fmt(QbzPlayer.npElapsedSecs)
|
||||||
|
color: "#bfffffff"
|
||||||
|
font.pixelSize: 11
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
}
|
||||||
|
NavBtn {
|
||||||
|
x: bar.width / 2 - 64
|
||||||
|
y: 22
|
||||||
|
icon: "skip-back"
|
||||||
|
onClicked: QbzPlayer.previous()
|
||||||
|
}
|
||||||
|
// PlayDisc (:83-108): 48px white disc, hover #ffffffe6, glyph 20px
|
||||||
|
// black (play nudged +1px right), shadow 12/#0000004d/4.
|
||||||
|
Item {
|
||||||
|
x: bar.width / 2 - 24
|
||||||
|
y: 12
|
||||||
|
width: 48
|
||||||
|
height: 48
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
y: 4
|
||||||
|
radius: 24
|
||||||
|
color: "#4d000000"
|
||||||
|
layer.enabled: !root._noShaders
|
||||||
|
layer.effect: MultiEffect {
|
||||||
|
blurEnabled: true
|
||||||
|
blurMax: 24
|
||||||
|
blur: 0.5 // 12/24
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: 24
|
||||||
|
color: playArea.containsMouse ? "#e6ffffff" : "#ffffff"
|
||||||
|
QbzIcon {
|
||||||
|
name: QbzPlayer.npPlaying ? "pause" : "play-fill"
|
||||||
|
width: 20
|
||||||
|
height: 20
|
||||||
|
x: Math.round((parent.width - width) / 2) + (QbzPlayer.npPlaying ? 0 : 1)
|
||||||
|
y: Math.round((parent.height - height) / 2)
|
||||||
|
tintName: "black"
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: playArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: QbzPlayer.togglePlay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NavBtn {
|
||||||
|
x: bar.width / 2 + 36
|
||||||
|
y: 22
|
||||||
|
icon: "skip-forward"
|
||||||
|
onClicked: QbzPlayer.next()
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
x: bar.width / 2 + 76
|
||||||
|
y: 31
|
||||||
|
width: 46
|
||||||
|
text: "-" + root.fmt(Math.max(0, QbzPlayer.npDurationSecs - QbzPlayer.npElapsedSecs))
|
||||||
|
color: "#bfffffff"
|
||||||
|
font.pixelSize: 11
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- RIGHT volume/menu group (:339-372) ---------------------------
|
||||||
|
GhostBtn {
|
||||||
|
x: bar.width - 156
|
||||||
|
y: 22
|
||||||
|
// Under lock the fill pins to 100%, so the icon must NOT show
|
||||||
|
// the muted/zero glyph (Tauri VolumeSlider: Volume2 when locked).
|
||||||
|
icon: (!root.volLocked && (QbzPlayer.npMuted || QbzPlayer.npVolume === 0))
|
||||||
|
? "volume-x" : "volume-2"
|
||||||
|
btnEnabled: !root.volLocked
|
||||||
|
onClicked: QbzPlayer.toggleMute()
|
||||||
|
}
|
||||||
|
VolumeBar {
|
||||||
|
x: bar.width - 112
|
||||||
|
y: 31
|
||||||
|
width: 64
|
||||||
|
value: QbzPlayer.npVolume
|
||||||
|
locked: root.volLocked
|
||||||
|
onChanged: function (v) {
|
||||||
|
if (!root.volLocked)
|
||||||
|
QbzPlayer.setVolume(v)
|
||||||
|
}
|
||||||
|
onReleased: function (v) {
|
||||||
|
if (!root.volLocked)
|
||||||
|
QbzPlayer.persistVolume(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The ⋯ trigger + the ONE-entry menu ("Exit Immersive" — exit path
|
||||||
|
// 1, §5.4). Slint shows the popup ABOVE the bar (:375-390); the
|
||||||
|
// shared CardMenu/QbzContextMenu surface clamps into the window.
|
||||||
|
Rectangle {
|
||||||
|
id: menuBtn
|
||||||
|
x: bar.width - 42
|
||||||
|
y: 22
|
||||||
|
width: 28
|
||||||
|
height: 28
|
||||||
|
radius: 14
|
||||||
|
color: menuArea.containsMouse ? "#26ffffff" : "transparent"
|
||||||
|
QbzIcon {
|
||||||
|
name: "ellipsis"
|
||||||
|
width: 12
|
||||||
|
height: 12
|
||||||
|
anchors.centerIn: parent
|
||||||
|
tintName: "white"
|
||||||
|
opacity: 0.65
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: menuArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
root.wakeRequested()
|
||||||
|
// Above the trigger, right edges aligned (Slint: x=-172,
|
||||||
|
// y=-58 for a 200x46 popup off a 28px button).
|
||||||
|
playerMenu.openAtCursor(menuBtn,
|
||||||
|
menuBtn.width - playerMenu.menuWidth,
|
||||||
|
-playerMenu.implicitHeight - 12)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CardMenu {
|
||||||
|
id: playerMenu
|
||||||
|
menuWidth: 200
|
||||||
|
entries: [
|
||||||
|
{ "label": QbzSession.tr("Exit Immersive", QbzSession.trRev),
|
||||||
|
"icon": "x", "action": "exit" }
|
||||||
|
]
|
||||||
|
onPicked: function (a) {
|
||||||
|
if (a === "exit")
|
||||||
|
QbzImmersive.open = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- TinyBar seek (:450-457): full width-32 at y=71 --------------
|
||||||
|
TinyBar {
|
||||||
|
x: 16
|
||||||
|
y: 71
|
||||||
|
width: bar.width - 32
|
||||||
|
value: QbzPlayer.npProgress
|
||||||
|
onChanged: function (v) {
|
||||||
|
QbzPlayer.seek(Math.min(v, QbzPlayer.npSeekableMax))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,360 @@
|
|||||||
|
// ImmersiveSearchCortinilla — the live as-you-type dropdown under the
|
||||||
|
// immersive header search field (ImmersiveSearchCortinilla.slint:33-366;
|
||||||
|
// contract 2026-08-02-immersive-port §12 B5). Mounted by ImmersiveView as
|
||||||
|
// layer 7 (TOPMOST), anchors.fill.
|
||||||
|
//
|
||||||
|
// Like the desktop twin (shell/Cortinilla.qml) this is a plain Item, NOT a
|
||||||
|
// Popup — a Popup grabs the pointer and kills typing in the search field.
|
||||||
|
// Differences from the desktop twin (D8): GLASS immersive palette (dark
|
||||||
|
// translucent panel, white-alpha text) instead of the app theme tokens;
|
||||||
|
// sections ONLY (Artists / Albums / Playlists — NO top-result hero, NO
|
||||||
|
// "View more", NO track rows); reads QbzImmersive.immSearch* (never
|
||||||
|
// QbzBridge.cortinilla*); NO idle auto-close (Slint has no such timer) and
|
||||||
|
// no view-change dismiss — the immersive host never navigates.
|
||||||
|
//
|
||||||
|
// Data: QbzImmersive.immSearchJson (search_qt.rs CortinillaData: query /
|
||||||
|
// top:null / sections with controller flat indices from 1). Keyboard
|
||||||
|
// selection rides immSearchSelectedIndex + immSearchScrollY (content-space
|
||||||
|
// top-y of the selected row, 56/24/4 layout — scrolled into view here).
|
||||||
|
// Row activation -> QbzImmersive.searchRowActivated(flatIndex); the Rust
|
||||||
|
// controller closes the dropdown, clears the field and ACTS ON PLAYBACK —
|
||||||
|
// the user STAYS in immersive.
|
||||||
|
//
|
||||||
|
// All colors are Slint RRGGBBAA converted to Qt #AARRGGBB.
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Effects
|
||||||
|
import com.blitzfc.qbz
|
||||||
|
import "../theme"
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// Keyboard accent (the host feeds QbzShell.ambientAccent so the active
|
||||||
|
// row matches the atmosphere; the Slint passes it in from the host the
|
||||||
|
// same way, default #3fd9c8).
|
||||||
|
property color accent: "#3fd9c8"
|
||||||
|
|
||||||
|
// Only render (and only consume events) when the search is open AND the
|
||||||
|
// live query is long enough to have meaningful results — mirrors the
|
||||||
|
// controller's >= 2 gate so a 1-char query never flashes a half-empty
|
||||||
|
// panel (ImmersiveSearchCortinilla.slint:165-167). searchInputText is
|
||||||
|
// the Qt mirror of Slint's search-query.
|
||||||
|
visible: QbzImmersive.immSearchOpen
|
||||||
|
&& QbzImmersive.searchInputText.trim().length >= 2
|
||||||
|
|
||||||
|
// --- Geometry (all dims passed/computed here — no parent-binding
|
||||||
|
// loops) ---------------------------------------------------------------
|
||||||
|
readonly property int panelWidth: 380
|
||||||
|
// The TOP of the panel (header-band y + field height + a small gap).
|
||||||
|
readonly property int anchorY: 58
|
||||||
|
// The immersive player bar's reserved bottom band (bar height + bottom
|
||||||
|
// inset + a breathing gap) — the panel's bottom edge stays ABOVE it.
|
||||||
|
readonly property int bottomReserved: 138
|
||||||
|
// scroll-cap = window-height - anchor-y - bottom-reserved - 12 (the
|
||||||
|
// 12 = the panel box's top+bottom padding).
|
||||||
|
readonly property int scrollCap: root.height - anchorY - bottomReserved - 12
|
||||||
|
|
||||||
|
// The centered search field's span (same width math as the header
|
||||||
|
// field): the header band across that span stays un-scrimmed so the
|
||||||
|
// field keeps typing/focus.
|
||||||
|
readonly property int fieldWidth: Math.min(root.width - 48, 420)
|
||||||
|
readonly property int fieldLeft: (root.width - root.fieldWidth) / 2
|
||||||
|
// The header band's vertical extent (field 36px + the 6px gap).
|
||||||
|
readonly property int bandBottom: anchorY - 6
|
||||||
|
|
||||||
|
readonly property var doc: parseDoc()
|
||||||
|
function parseDoc() {
|
||||||
|
try {
|
||||||
|
return JSON.parse(QbzImmersive.immSearchJson)
|
||||||
|
} catch (e) {
|
||||||
|
return ({})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readonly property var sections: doc.sections || []
|
||||||
|
|
||||||
|
// Keyboard scroll-into-view (the desktop Cortinilla.qml:63-71 idiom):
|
||||||
|
// the controller publishes the selected row's content-space top-y;
|
||||||
|
// nudge the Flickable so that row is visible. 56px is the row height.
|
||||||
|
Connections {
|
||||||
|
target: QbzImmersive
|
||||||
|
function onImmSearchScrollYChanged() {
|
||||||
|
var y = QbzImmersive.immSearchScrollY
|
||||||
|
if (y < bodyFlick.contentY) {
|
||||||
|
bodyFlick.contentY = Math.max(0, y)
|
||||||
|
} else if (y + 56 > bodyFlick.contentY + bodyFlick.height) {
|
||||||
|
bodyFlick.contentY = y + 56 - bodyFlick.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Click-outside scrims (ANY click outside the panel dismisses) ----
|
||||||
|
// Transparent MouseAreas tile the whole window EXCEPT the panel
|
||||||
|
// (declared later -> on top, keeps its own clicks) and the header band
|
||||||
|
// across the search field's horizontal span.
|
||||||
|
// 1) everything BELOW the header band (panels, player bar region)
|
||||||
|
MouseArea {
|
||||||
|
visible: root.visible
|
||||||
|
x: 0
|
||||||
|
y: root.bandBottom
|
||||||
|
width: root.width
|
||||||
|
height: root.height - y
|
||||||
|
onClicked: QbzImmersive.dismissSearch()
|
||||||
|
}
|
||||||
|
// 2) header band, LEFT of the search field
|
||||||
|
MouseArea {
|
||||||
|
visible: root.visible
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
width: root.fieldLeft
|
||||||
|
height: root.bandBottom
|
||||||
|
onClicked: QbzImmersive.dismissSearch()
|
||||||
|
}
|
||||||
|
// 3) header band, RIGHT of the search field
|
||||||
|
MouseArea {
|
||||||
|
visible: root.visible
|
||||||
|
x: root.fieldLeft + root.fieldWidth
|
||||||
|
y: 0
|
||||||
|
width: root.width - x
|
||||||
|
height: root.bandBottom
|
||||||
|
onClicked: QbzImmersive.dismissSearch()
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- The panel ---------------------------------------------------------
|
||||||
|
// Anchored under the centered search field; its total height is capped
|
||||||
|
// so the bottom edge stays ABOVE the player bar. A tall result set
|
||||||
|
// scrolls inside the Flickable; a short one collapses.
|
||||||
|
// Shadow: 32 / #00000066 / offset-y 8 (the ImmersiveView shadow idiom).
|
||||||
|
Rectangle {
|
||||||
|
visible: root.visible
|
||||||
|
x: (root.width - root.panelWidth) / 2
|
||||||
|
y: root.anchorY + 8
|
||||||
|
width: root.panelWidth
|
||||||
|
height: Math.min(bodyColumn.height + 12, root.scrollCap + 12)
|
||||||
|
radius: 16
|
||||||
|
color: "#66000000"
|
||||||
|
layer.enabled: !root._noShaders
|
||||||
|
layer.effect: MultiEffect {
|
||||||
|
blurEnabled: true
|
||||||
|
blurMax: 64
|
||||||
|
blur: 0.5 // 32/64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readonly property bool _noShaders: GraphicsInfo.api === GraphicsInfo.Software
|
||||||
|
|| GraphicsInfo.api === GraphicsInfo.Null
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: panel
|
||||||
|
visible: root.visible
|
||||||
|
x: (root.width - root.panelWidth) / 2
|
||||||
|
y: root.anchorY
|
||||||
|
width: root.panelWidth
|
||||||
|
height: Math.min(bodyColumn.height + 12, root.scrollCap + 12)
|
||||||
|
radius: 16
|
||||||
|
color: "#94000000"
|
||||||
|
border.width: 1
|
||||||
|
border.color: "#1affffff"
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Flickable {
|
||||||
|
id: bodyFlick
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 6
|
||||||
|
anchors.bottomMargin: 6
|
||||||
|
contentWidth: width
|
||||||
|
contentHeight: bodyColumn.height
|
||||||
|
clip: true
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: bodyColumn
|
||||||
|
width: bodyFlick.width
|
||||||
|
|
||||||
|
// --- Loading skeleton (4 rows; skeleton-only, no cached
|
||||||
|
// instant-paint — the desktop Cortinilla.qml:143-194 idiom,
|
||||||
|
// glass-white boxes like ImmersiveSkeletonRow) --------------
|
||||||
|
Column {
|
||||||
|
visible: QbzImmersive.immSearchLoading
|
||||||
|
width: parent.width
|
||||||
|
topPadding: 4
|
||||||
|
property bool pulse: false
|
||||||
|
Timer {
|
||||||
|
interval: 700
|
||||||
|
running: parent.visible
|
||||||
|
repeat: true
|
||||||
|
onTriggered: parent.pulse = !parent.pulse
|
||||||
|
}
|
||||||
|
Repeater {
|
||||||
|
model: 4
|
||||||
|
delegate: Item {
|
||||||
|
width: bodyColumn.width
|
||||||
|
height: 56
|
||||||
|
Rectangle {
|
||||||
|
x: 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
width: 40
|
||||||
|
height: 40
|
||||||
|
radius: 4
|
||||||
|
color: "#ffffff"
|
||||||
|
opacity: parent.parent.pulse ? 0.32 : 0.08
|
||||||
|
Behavior on opacity { NumberAnimation { duration: 650; easing.type: Easing.InOutQuad } }
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
x: 62
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: 8
|
||||||
|
Rectangle {
|
||||||
|
width: 150
|
||||||
|
height: 11
|
||||||
|
radius: 3
|
||||||
|
color: "#ffffff"
|
||||||
|
opacity: parent.parent.parent.pulse ? 0.32 : 0.08
|
||||||
|
Behavior on opacity { NumberAnimation { duration: 650; easing.type: Easing.InOutQuad } }
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
width: 96
|
||||||
|
height: 9
|
||||||
|
radius: 3
|
||||||
|
color: "#ffffff"
|
||||||
|
opacity: parent.parent.parent.pulse ? 0.32 : 0.08
|
||||||
|
Behavior on opacity { NumberAnimation { duration: 650; easing.type: Easing.InOutQuad } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Loaded content ----------------------------------------
|
||||||
|
Column {
|
||||||
|
visible: !QbzImmersive.immSearchLoading
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
// No results: explicit empty-state line.
|
||||||
|
Item {
|
||||||
|
visible: root.sections.length === 0
|
||||||
|
width: parent.width
|
||||||
|
height: 28
|
||||||
|
Text {
|
||||||
|
x: 14
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: QbzSession.tr("No results for", QbzSession.trRev)
|
||||||
|
+ " “" + (root.doc.query || "") + "”"
|
||||||
|
color: "#80ffffff"
|
||||||
|
font.pixelSize: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Result sections (Artists / Albums / Playlists, then the
|
||||||
|
// local-album section). NO "View more" — immersive has
|
||||||
|
// no results page to navigate to.
|
||||||
|
Repeater {
|
||||||
|
model: root.sections
|
||||||
|
delegate: Column {
|
||||||
|
required property var modelData
|
||||||
|
width: bodyColumn.width
|
||||||
|
leftPadding: 6
|
||||||
|
rightPadding: 6
|
||||||
|
topPadding: 4
|
||||||
|
|
||||||
|
// Section header — title only, 24px, 11px
|
||||||
|
// semibold #ffffff80.
|
||||||
|
Item {
|
||||||
|
width: parent.width
|
||||||
|
height: 24
|
||||||
|
Text {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: modelData.title
|
||||||
|
color: "#80ffffff"
|
||||||
|
font.pixelSize: 11
|
||||||
|
font.weight: 600
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Repeater {
|
||||||
|
model: modelData.rows
|
||||||
|
delegate: ImmRow { row: modelData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QbzScrollBar {
|
||||||
|
target: bodyFlick
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- One result row (ImmersiveResultRow :30-102) -----------------------
|
||||||
|
// 56px, radius 8; keyboard-active #ffffff26 + the 3px accent bar, plain
|
||||||
|
// hover #ffffff14. Hover is PURELY VISUAL — it deliberately does NOT
|
||||||
|
// write the selection, so a stray hover can never hijack the keyboard
|
||||||
|
// selection that Enter activates (same lesson as the main cortinilla).
|
||||||
|
component ImmRow: Rectangle {
|
||||||
|
property var row: ({})
|
||||||
|
width: parent ? parent.width : 0
|
||||||
|
height: 56
|
||||||
|
radius: 8
|
||||||
|
readonly property bool active: QbzImmersive.immSearchSelectedIndex === (row.flatIndex ?? -2)
|
||||||
|
color: active ? "#26ffffff"
|
||||||
|
: (rowArea.containsMouse ? "#14ffffff" : "transparent")
|
||||||
|
|
||||||
|
// Accent bar on the keyboard-active row (distinct from plain hover).
|
||||||
|
Rectangle {
|
||||||
|
visible: parent.active
|
||||||
|
x: 0
|
||||||
|
y: 4
|
||||||
|
width: 3
|
||||||
|
height: parent.height - 8
|
||||||
|
radius: 2
|
||||||
|
color: root.accent
|
||||||
|
}
|
||||||
|
// 40x40 thumb — circle for artists, tile otherwise.
|
||||||
|
Rectangle {
|
||||||
|
x: 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
width: 40
|
||||||
|
height: 40
|
||||||
|
radius: row.kind === "artist" ? 20 : 4
|
||||||
|
color: "#14ffffff"
|
||||||
|
clip: true
|
||||||
|
RoundedImage {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: row.artPath || ""
|
||||||
|
radius: row.kind === "artist" ? 20 : 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
x: 62
|
||||||
|
width: parent.width - 62 - 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: 2
|
||||||
|
Text {
|
||||||
|
width: parent.width
|
||||||
|
text: row.title || ""
|
||||||
|
color: "#ccffffff"
|
||||||
|
font.pixelSize: 14
|
||||||
|
font.weight: 500
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
width: parent.width
|
||||||
|
text: row.subtitle || ""
|
||||||
|
color: "#80ffffff"
|
||||||
|
font.pixelSize: 12
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: rowArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: QbzImmersive.searchRowActivated(row.flatIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,16 +3,16 @@
|
|||||||
// AppShell AFTER QbzToast and BEFORE ArtPreviewOverlay/QbzTooltip (§5.1
|
// AppShell AFTER QbzToast and BEFORE ArtPreviewOverlay/QbzTooltip (§5.1
|
||||||
// declaration-order z convention).
|
// declaration-order z convention).
|
||||||
//
|
//
|
||||||
// BLOCK B2+B3+B4 SCOPE: the overlay shell (root + click-blocker + chrome +
|
// BLOCK B2+B3+B4+B5 SCOPE: the overlay shell (root + click-blocker + chrome +
|
||||||
// auto-hide + exit paths 2-4 + the fullscreen guard + seek arrows) PLUS the
|
// auto-hide + exit paths 2-4 + the fullscreen guard + seek arrows) PLUS the
|
||||||
// B3 panels (the ImmersiveAtmosphere underlay, the five FOCUS panels Album
|
// B3 panels (the ImmersiveAtmosphere underlay, the five FOCUS panels Album
|
||||||
// Reactive / Static / Coverflow / Spectrum / Wave Bed, the layer-4
|
// Reactive / Static / Coverflow / Spectrum / Wave Bed, the layer-4
|
||||||
// ImmersiveSongCard) PLUS the B4 panels: FOCUS Lyrics (mode 4,
|
// ImmersiveSongCard) PLUS the B4 panels: FOCUS Lyrics (mode 4,
|
||||||
// LyricsFocusPanel) and Queue (mode 5, QueueTabsPanel), and the full §5.6
|
// LyricsFocusPanel) and Queue (mode 5, QueueTabsPanel), and the full §5.6
|
||||||
// SPLIT layout (50/50: artwork + ImmersiveTrackMeta LEFT, the Lyrics /
|
// SPLIT layout (50/50: artwork + ImmersiveTrackMeta LEFT, the Lyrics /
|
||||||
// TrackInfo / Suggestions / Queue panels RIGHT) with the §5.5 entry loads.
|
// TrackInfo / Suggestions / Queue panels RIGHT) with the §5.5 entry loads —
|
||||||
// B5 adds the player bar + search cortinilla (layer 7 is therefore absent,
|
// PLUS the B5 layer-5 ImmersivePlayerBar (TinyBar/VolumeBar, §5.7/§5.8) and
|
||||||
// per contract §12 B2).
|
// the B5 layer-7 ImmersiveSearchCortinilla (§3.4).
|
||||||
//
|
//
|
||||||
// Layer order bottom->top (§5.1):
|
// Layer order bottom->top (§5.1):
|
||||||
// 1. root color #0a0a0b, clip (:1199-1200)
|
// 1. root color #0a0a0b, clip (:1199-1200)
|
||||||
@@ -25,7 +25,10 @@
|
|||||||
// 3. FOCUS panels (viewMode==0 && mode==N) / the SPLIT layout (viewMode==1)
|
// 3. FOCUS panels (viewMode==0 && mode==N) / the SPLIT layout (viewMode==1)
|
||||||
// 4. ImmersiveSongCard (viewMode==0 && mode==6 && npHasTrack — trap 19;
|
// 4. ImmersiveSongCard (viewMode==0 && mode==6 && npHasTrack — trap 19;
|
||||||
// does NOT fade with the chrome, :1602-1605)
|
// does NOT fade with the chrome, :1602-1605)
|
||||||
// 6. ImmersiveHeader band (layer 5 — the PlayerBar — is B5)
|
// 5. ImmersivePlayerBar (B5, :1607-1616) — centered, y = height-90-24,
|
||||||
|
// fades with the chrome like the header
|
||||||
|
// 6. ImmersiveHeader band
|
||||||
|
// 7. ImmersiveSearchCortinilla (B5, :1695-1705) — topmost
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Effects
|
import QtQuick.Effects
|
||||||
@@ -517,6 +520,20 @@ Item {
|
|||||||
event.accepted = true
|
event.accepted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Layer 5: the player bar (§5.7, :1607-1616) -------------------------
|
||||||
|
// Centered, y = height-90-24; fades with the auto-hide chrome on the
|
||||||
|
// SAME binding as the header (300ms), inert while hidden.
|
||||||
|
ImmersivePlayerBar {
|
||||||
|
id: playerBar
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
y: root.height - 90 - 24
|
||||||
|
viewportWidth: root.width
|
||||||
|
opacity: root.chromeVisible ? 1 : 0
|
||||||
|
Behavior on opacity { NumberAnimation { duration: 300 } }
|
||||||
|
enabled: opacity > 0
|
||||||
|
onWakeRequested: root.wake()
|
||||||
|
}
|
||||||
|
|
||||||
// --- Layer 6: the header band (§5.2) --------------------------------------
|
// --- Layer 6: the header band (§5.2) --------------------------------------
|
||||||
ImmersiveHeader {
|
ImmersiveHeader {
|
||||||
id: header
|
id: header
|
||||||
@@ -531,4 +548,14 @@ Item {
|
|||||||
Behavior on opacity { NumberAnimation { duration: 300 } }
|
Behavior on opacity { NumberAnimation { duration: 300 } }
|
||||||
enabled: opacity > 0
|
enabled: opacity > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Layer 7: the search cortinilla (§3.4, :1695-1705) -------------------
|
||||||
|
// TOPMOST: above the header band and the player bar. Self-gated on
|
||||||
|
// QbzImmersive.immSearchOpen && query >= 2 chars; NOT chrome-faded (its
|
||||||
|
// open flag is exactly what suppresses the auto-hide, trap 10). The
|
||||||
|
// accent follows the atmosphere so the keyboard-active row matches.
|
||||||
|
ImmersiveSearchCortinilla {
|
||||||
|
anchors.fill: parent
|
||||||
|
accent: QbzShell.ambientAccent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
// TinyBar — the immersive seek micro-slider (ImmersiveView.slint:110-145),
|
||||||
|
// immersive-local per divergence D5: NOT QbzSlider (integer-step; seek needs
|
||||||
|
// a fraction + the npSeekableMax clamp, which the HOST applies).
|
||||||
|
//
|
||||||
|
// Fraction in/out, fill width = parent.width * clamp(value, 0, 1); the
|
||||||
|
// changed() callback fires on press AND pressed-move with
|
||||||
|
// clamp(mouseX / width, 0, 1).
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property real value: 0.0
|
||||||
|
property color fill: "#ffffff"
|
||||||
|
signal changed(real v)
|
||||||
|
|
||||||
|
function clamp01(v) {
|
||||||
|
return Math.max(0.0, Math.min(1.0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
height: 10
|
||||||
|
|
||||||
|
// Track: 2px #ffffff2e (Slint RRGGBBAA -> Qt #AARRGGBB) at y=4.
|
||||||
|
Rectangle {
|
||||||
|
x: 0
|
||||||
|
y: 4
|
||||||
|
width: root.width
|
||||||
|
height: 2
|
||||||
|
radius: 1
|
||||||
|
color: "#2effffff"
|
||||||
|
}
|
||||||
|
// Fill.
|
||||||
|
Rectangle {
|
||||||
|
x: 0
|
||||||
|
y: 4
|
||||||
|
width: root.width * root.clamp01(root.value)
|
||||||
|
height: 2
|
||||||
|
radius: 1
|
||||||
|
color: root.fill
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onPressed: function (mouse) { root.changed(root.clamp01(mouse.x / width)) }
|
||||||
|
onPositionChanged: function (mouse) {
|
||||||
|
if (pressed)
|
||||||
|
root.changed(root.clamp01(mouse.x / width))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
// VolumeBar — the immersive volume micro-slider (ImmersiveView.slint:153-238),
|
||||||
|
// immersive-local per divergence D5 (QbzSlider is integer-step and has no lock
|
||||||
|
// states). Thin white-on-glass track, hover-revealed thumb, drag-time percent
|
||||||
|
// bubble, and a LOCKED state that pins the fill to 100% and dims/no-ops
|
||||||
|
// (bit-perfect ALSA-Direct or a QConnect peer that disallows remote volume).
|
||||||
|
//
|
||||||
|
// Lock FORMULA lives in the host (ImmersivePlayerBar), verbatim from
|
||||||
|
// PlayerBar.qml:92-94 (contract §5.8 / trap 8). Wiring: live changed(v) ->
|
||||||
|
// QbzPlayer.setVolume(v); drag-end released(v) -> QbzPlayer.persistVolume(v).
|
||||||
|
// NOTE: no `opacity` on the root (it would corrupt absolute positioning) —
|
||||||
|
// inner content carries the states instead.
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property real value: 0.0 // 0..1
|
||||||
|
property bool locked: false
|
||||||
|
signal changed(real v) // emits 0..1 — live (every drag tick)
|
||||||
|
signal released(real v) // emits 0..1 — drag-end only (persist)
|
||||||
|
|
||||||
|
// The visual fill fraction: pinned to 100% when locked (matches Tauri).
|
||||||
|
readonly property real shown: root.locked ? 1.0 : Math.max(0.0, Math.min(1.0, root.value))
|
||||||
|
|
||||||
|
function clamp01(v) {
|
||||||
|
return Math.max(0.0, Math.min(1.0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
height: 12
|
||||||
|
|
||||||
|
// Drag-time / hover percent readout, 34x20 at y=-26, #000000b3 (Qt
|
||||||
|
// #AARRGGBB), 11px/600. Hidden when locked.
|
||||||
|
Rectangle {
|
||||||
|
x: root.width - width
|
||||||
|
y: -26
|
||||||
|
width: 34
|
||||||
|
height: 20
|
||||||
|
radius: 6
|
||||||
|
color: "#b3000000"
|
||||||
|
visible: !root.locked && (area.containsMouse || area.pressed)
|
||||||
|
Text {
|
||||||
|
anchors.fill: parent
|
||||||
|
text: Math.round(root.shown * 100)
|
||||||
|
color: "#ffffff"
|
||||||
|
font.pixelSize: 11
|
||||||
|
font.weight: 600
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track background: #ffffff1f locked / #ffffff33.
|
||||||
|
Rectangle {
|
||||||
|
x: 0
|
||||||
|
y: 5
|
||||||
|
width: root.width
|
||||||
|
height: 2
|
||||||
|
radius: 1
|
||||||
|
color: root.locked ? "#1fffffff" : "#33ffffff"
|
||||||
|
}
|
||||||
|
// Fill: #ffffff66 locked / #ffffffb3.
|
||||||
|
Rectangle {
|
||||||
|
x: 0
|
||||||
|
y: 5
|
||||||
|
width: root.width * root.shown
|
||||||
|
height: 2
|
||||||
|
radius: 1
|
||||||
|
color: root.locked ? "#66ffffff" : "#b3ffffff"
|
||||||
|
}
|
||||||
|
// Hover-revealed thumb, 12px white, only !locked && (hover || pressed).
|
||||||
|
// Position computed from root.width (no layout recursion).
|
||||||
|
Rectangle {
|
||||||
|
x: root.width * root.shown - width / 2
|
||||||
|
y: 0
|
||||||
|
width: 12
|
||||||
|
height: 12
|
||||||
|
radius: 6
|
||||||
|
color: "#ffffff"
|
||||||
|
opacity: (!root.locked && (area.containsMouse || area.pressed)) ? 1.0 : 0.0
|
||||||
|
Behavior on opacity { NumberAnimation { duration: 150 } }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ALL pointer events gated !locked (:218-237).
|
||||||
|
MouseArea {
|
||||||
|
id: area
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: root.locked ? Qt.ArrowCursor : Qt.PointingHandCursor
|
||||||
|
onPressed: function (mouse) {
|
||||||
|
if (!root.locked)
|
||||||
|
root.changed(root.clamp01(mouse.x / width))
|
||||||
|
}
|
||||||
|
onPositionChanged: function (mouse) {
|
||||||
|
if (!root.locked && pressed)
|
||||||
|
root.changed(root.clamp01(mouse.x / width))
|
||||||
|
}
|
||||||
|
// Persist only the final value on drag-end (the NPB sliders'
|
||||||
|
// released -> persistVolume; live changes still fire via changed).
|
||||||
|
onReleased: function (mouse) {
|
||||||
|
if (!root.locked)
|
||||||
|
root.released(root.clamp01(mouse.x / width))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,10 +15,13 @@
|
|||||||
//! guard timer). The false→true edge runs §3.1 apply-default-view; both edges
|
//! guard timer). The false→true edge runs §3.1 apply-default-view; both edges
|
||||||
//! drive the viz two-source enable (§3.3a/§4.2).
|
//! drive the viz two-source enable (§3.3a/§4.2).
|
||||||
//!
|
//!
|
||||||
//! The §3.4 search surface is a BRIDGE SURFACE ONLY in B1: `search_live`
|
//! The §3.4 search surface is wired to the immersive search controller in
|
||||||
//! mirrors the text, `dismiss_search` clears open+selection, move/activate
|
//! `search_qt.rs` (B5): `search_live` mirrors the text AND runs the gate ->
|
||||||
//! are no-ops. The controller (debounce, ≥2-char gate, version-guarded load,
|
//! 2-char gate -> 220 ms debounce -> version-guarded load pipeline;
|
||||||
//! dispatch table) lands in B5 (`search_qt.rs`).
|
//! `search_move_selection` clamps the keyboard selection; `search_row_activated`
|
||||||
|
//! runs the (kind x action) playback dispatch table; `dismiss_search` clears
|
||||||
|
//! open+selection. The controller publishes ONLY on this bridge's immSearch*
|
||||||
|
//! properties — never on QbzBridge.cortinilla* (contract §3.4).
|
||||||
|
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
@@ -70,10 +73,11 @@ pub mod qbz_immersive {
|
|||||||
// fresh asset is ready — NEVER cleared on track change (the flicker
|
// fresh asset is ready — NEVER cleared on track change (the flicker
|
||||||
// fix, playback.rs:2344-2351 semantics; §4.3).
|
// fix, playback.rs:2344-2351 semantics; §4.3).
|
||||||
#[qproperty(QString, atmosphere_url)]
|
#[qproperty(QString, atmosphere_url)]
|
||||||
// --- Immersive search surface (§3.4; controller lands in B5) -------
|
// --- Immersive search surface (§3.4; controller: search_qt.rs) -----
|
||||||
#[qproperty(bool, imm_search_open)]
|
#[qproperty(bool, imm_search_open)]
|
||||||
// Sections Albums/Artists/Playlists (+ local albums offline) — NO
|
// Sections Artists/Albums/Playlists IN THAT ORDER (+ a local-album
|
||||||
// track rows, NO top result. Full-shape default, never "{}".
|
// section, always fetched) — NO track rows, NO top result. Full-shape
|
||||||
|
// default, never "{}".
|
||||||
#[qproperty(QString, imm_search_json)]
|
#[qproperty(QString, imm_search_json)]
|
||||||
#[qproperty(bool, imm_search_loading)]
|
#[qproperty(bool, imm_search_loading)]
|
||||||
// -1 = no selection (Down from -1 selects the first row; no wrap).
|
// -1 = no selection (Down from -1 selects the first row; no wrap).
|
||||||
@@ -104,14 +108,17 @@ pub mod qbz_immersive {
|
|||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn set_view(self: Pin<&mut QbzImmersive>, view_mode: i32, mode: i32, split_panel: i32);
|
fn set_view(self: Pin<&mut QbzImmersive>, view_mode: i32, mode: i32, split_panel: i32);
|
||||||
|
|
||||||
/// §3.4 search surface — B1: mirrors text into search_input_text and
|
/// §3.4 search surface: mirrors the text into search_input_text AND
|
||||||
/// nothing else (the controller lands in B5).
|
/// runs the immersive controller (pref gate, >=2-char gate, 220 ms
|
||||||
|
/// debounce, version-guarded load — search_qt::imm_live).
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn search_live(self: Pin<&mut QbzImmersive>, text: QString);
|
fn search_live(self: Pin<&mut QbzImmersive>, text: QString);
|
||||||
/// §3.4 search surface — B1: NO-OP (B5 implements the clamp/scroll).
|
/// §3.4: arrows clamp both ends, Down from -1 -> first row, no wrap
|
||||||
|
/// (search_qt::imm_move_selection + the 56/24/4 scroll arithmetic).
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn search_move_selection(self: Pin<&mut QbzImmersive>, delta: i32);
|
fn search_move_selection(self: Pin<&mut QbzImmersive>, delta: i32);
|
||||||
/// §3.4 search surface — B1: NO-OP (B5 implements the dispatch table).
|
/// §3.4: the per-row-kind x action playback dispatch table — the user
|
||||||
|
/// STAYS in immersive, the field clears (search_qt::imm_row_activated).
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn search_row_activated(self: Pin<&mut QbzImmersive>, flat_index: i32);
|
fn search_row_activated(self: Pin<&mut QbzImmersive>, flat_index: i32);
|
||||||
/// §3.4: clears imm_search_open + the selection.
|
/// §3.4: clears imm_search_open + the selection.
|
||||||
@@ -232,6 +239,11 @@ fn apply_open(mut this: Pin<&mut QbzImmersive>, value: bool) {
|
|||||||
}
|
}
|
||||||
// Unknown key: Slint's `_ => {}` — leave the current view alone.
|
// Unknown key: Slint's `_ => {}` — leave the current view alone.
|
||||||
crate::viz_qt::immersive_opened();
|
crate::viz_qt::immersive_opened();
|
||||||
|
// §3.4 open-edge hygiene: a stale-true desktop cortinillaOpen is
|
||||||
|
// possible in theory — close it deterministically (the Rust
|
||||||
|
// equivalent of QbzBridge.cortinillaDismiss, bridge.rs:359-361; the
|
||||||
|
// desktop Cortinilla must never float under the immersive overlay).
|
||||||
|
crate::search_qt::dismiss();
|
||||||
} else {
|
} else {
|
||||||
crate::viz_qt::immersive_closed();
|
crate::viz_qt::immersive_closed();
|
||||||
}
|
}
|
||||||
@@ -296,26 +308,32 @@ impl qbz_immersive::QbzImmersive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// §3.4 surface — B1: mirror the text only. The 220 ms debounce, the
|
/// §3.4 live entry: mirror the text (two-way with the field), then hand
|
||||||
/// ≥2-char gate, the pref re-read and the version-guarded load all land
|
/// the query to the immersive controller. The controller re-reads the
|
||||||
/// with the B5 controller in search_qt.rs.
|
/// `immersive_search_action` pref FRESH per keystroke and gates on it; the
|
||||||
|
/// overlay-open gate reads THIS object's property (the qinvokable already
|
||||||
|
/// runs on the Qt thread).
|
||||||
pub fn search_live(mut self: Pin<&mut Self>, text: QString) {
|
pub fn search_live(mut self: Pin<&mut Self>, text: QString) {
|
||||||
self.as_mut().set_search_input_text(text);
|
self.as_mut().set_search_input_text(text.clone());
|
||||||
|
crate::search_qt::imm_live(self.open, text.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// §3.4 surface — B1 NO-OP: B5 implements the arrow clamp (Down from -1
|
/// §3.4 arrow move — the controller's clamp (Down from -1 selects the
|
||||||
/// selects the first row, Up from the first row returns to -1, no wrap)
|
/// first row, Up from the first row returns to -1, no wrap) + the 56/24/4
|
||||||
/// and the 56/24/4 scroll-y arithmetic.
|
/// scroll-y arithmetic (main.rs:10506-10548).
|
||||||
pub fn search_move_selection(self: Pin<&mut Self>, _delta: i32) {}
|
pub fn search_move_selection(self: Pin<&mut Self>, delta: i32) {
|
||||||
|
crate::search_qt::imm_move_selection(delta);
|
||||||
|
}
|
||||||
|
|
||||||
/// §3.4 surface — B1 NO-OP: B5 implements the per-row-kind × action
|
/// §3.4 row activation — the controller's (kind x action) playback
|
||||||
/// dispatch table (album/artist/playlist × replace/next/queue).
|
/// dispatch table (main.rs:10579-10751).
|
||||||
pub fn search_row_activated(self: Pin<&mut Self>, _flat_index: i32) {}
|
pub fn search_row_activated(self: Pin<&mut Self>, flat_index: i32) {
|
||||||
|
crate::search_qt::imm_row_activated(flat_index);
|
||||||
|
}
|
||||||
|
|
||||||
/// §3.4 dismiss: clears the dropdown + the selection (main.rs:10552-10564).
|
/// §3.4 dismiss: clears the dropdown + the selection (main.rs:10552-10564).
|
||||||
pub fn dismiss_search(mut self: Pin<&mut Self>) {
|
pub fn dismiss_search(self: Pin<&mut Self>) {
|
||||||
self.as_mut().set_imm_search_open(false);
|
crate::search_qt::imm_dismiss();
|
||||||
self.as_mut().set_imm_search_selected_index(-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ use std::sync::{Arc, RwLock};
|
|||||||
use qbz_app::shell::AppRuntime;
|
use qbz_app::shell::AppRuntime;
|
||||||
use qbz_core::LoggingAdapter;
|
use qbz_core::LoggingAdapter;
|
||||||
use cxx_qt_lib::QString;
|
use cxx_qt_lib::QString;
|
||||||
use qbz_models::{Quality, QueueTrack, RepeatMode};
|
use qbz_models::{PageArtistTrack, Quality, QueueTrack, RepeatMode};
|
||||||
|
|
||||||
/// The request tier for every play. Persisted in ui_prefs.json ("streaming_quality")
|
/// The request tier for every play. Persisted in ui_prefs.json ("streaming_quality")
|
||||||
/// and applied here from Settings > Audio (settings_qt). Default "hires_plus".
|
/// and applied here from Settings > Audio (settings_qt). Default "hires_plus".
|
||||||
@@ -538,32 +538,20 @@ pub(crate) async fn fetch_album_queue(
|
|||||||
Ok(tracks)
|
Ok(tracks)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Artist-card play (ArtistGridCard overlay / menu, phase 16) — playback.rs
|
/// The /artist/page top-tracks -> QueueTrack mapping shared by `play_artist`
|
||||||
/// `play_artist` 1:1: fetch the artist page ONCE, play the Popular tracks;
|
/// and the immersive search's (artist, next|queue) dispatch (contract
|
||||||
/// when the artist has none, fall back to the STUDIO discography (release
|
/// 2026-08-02-immersive-port §3.4: `enqueue_artist_top_by_id` = get_artist_page
|
||||||
/// buckets album/epSingle/ep/single in page order, deduped), concatenating
|
/// -> top_tracks mapped like play_artist -> enqueue_track_list_mode).
|
||||||
/// each album's tracks and skipping albums that fail (a bulk play must not
|
/// make_top_track_queue semantics: /artist/page tracks carry a thinner
|
||||||
/// abort on one unavailable album).
|
/// audio_info than /album/get tracks; fields fall back.
|
||||||
pub async fn play_artist(runtime: &Arc<AppRuntime<LoggingAdapter>>, artist_id: &str) -> Result<(), String> {
|
fn artist_top_queue_tracks(
|
||||||
const STUDIO_TYPES: &[&str] = &["album", "epSingle", "ep", "single"];
|
top_tracks: &[PageArtistTrack],
|
||||||
let id: u64 = artist_id
|
artist_id: &str,
|
||||||
.parse()
|
artist_name: &str,
|
||||||
.map_err(|_| format!("invalid artist id: {artist_id}"))?;
|
) -> Vec<QueueTrack> {
|
||||||
let page = runtime
|
top_tracks
|
||||||
.core()
|
|
||||||
.get_artist_page(id, None)
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("get_artist_page {artist_id} failed: {e}"))?;
|
|
||||||
let artist_name = page.name.display.clone();
|
|
||||||
|
|
||||||
// 1) Popular tracks — the primary behavior.
|
|
||||||
let top: Vec<QueueTrack> = page
|
|
||||||
.top_tracks
|
|
||||||
.unwrap_or_default()
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|track| {
|
.map(|track| {
|
||||||
// make_top_track_queue: /artist/page tracks carry a thinner
|
|
||||||
// audio_info than /album/get tracks; fields fall back.
|
|
||||||
let audio = track.audio_info.as_ref();
|
let audio = track.audio_info.as_ref();
|
||||||
let album = track.album.as_ref();
|
let album = track.album.as_ref();
|
||||||
let album_id = album.map(|a| a.id.clone());
|
let album_id = album.map(|a| a.id.clone());
|
||||||
@@ -576,7 +564,7 @@ pub async fn play_artist(runtime: &Arc<AppRuntime<LoggingAdapter>>, artist_id: &
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|a| a.name.display.clone())
|
.map(|a| a.name.display.clone())
|
||||||
.filter(|n| !n.is_empty())
|
.filter(|n| !n.is_empty())
|
||||||
.unwrap_or_else(|| artist_name.clone()),
|
.unwrap_or_else(|| artist_name.to_string()),
|
||||||
album: album.map(|a| a.title.clone()).unwrap_or_default(),
|
album: album.map(|a| a.title.clone()).unwrap_or_default(),
|
||||||
album_version: None,
|
album_version: None,
|
||||||
duration_secs: track.duration.unwrap_or(0) as u64,
|
duration_secs: track.duration.unwrap_or(0) as u64,
|
||||||
@@ -604,7 +592,30 @@ pub async fn play_artist(runtime: &Arc<AppRuntime<LoggingAdapter>>, artist_id: &
|
|||||||
context_id: Some(artist_id.to_string()),
|
context_id: Some(artist_id.to_string()),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Artist-card play (ArtistGridCard overlay / menu, phase 16) — playback.rs
|
||||||
|
/// `play_artist` 1:1: fetch the artist page ONCE, play the Popular tracks;
|
||||||
|
/// when the artist has none, fall back to the STUDIO discography (release
|
||||||
|
/// buckets album/epSingle/ep/single in page order, deduped), concatenating
|
||||||
|
/// each album's tracks and skipping albums that fail (a bulk play must not
|
||||||
|
/// abort on one unavailable album).
|
||||||
|
pub async fn play_artist(runtime: &Arc<AppRuntime<LoggingAdapter>>, artist_id: &str) -> Result<(), String> {
|
||||||
|
const STUDIO_TYPES: &[&str] = &["album", "epSingle", "ep", "single"];
|
||||||
|
let id: u64 = artist_id
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| format!("invalid artist id: {artist_id}"))?;
|
||||||
|
let page = runtime
|
||||||
|
.core()
|
||||||
|
.get_artist_page(id, None)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("get_artist_page {artist_id} failed: {e}"))?;
|
||||||
|
let artist_name = page.name.display.clone();
|
||||||
|
|
||||||
|
// 1) Popular tracks — the primary behavior.
|
||||||
|
let top: Vec<QueueTrack> =
|
||||||
|
artist_top_queue_tracks(page.top_tracks.as_deref().unwrap_or(&[]), artist_id, &artist_name);
|
||||||
if !top.is_empty() {
|
if !top.is_empty() {
|
||||||
let first_id = top[0].id;
|
let first_id = top[0].id;
|
||||||
set_queue_stamped(runtime, top, Some(0), PlayContext::artist(artist_id)).await;
|
set_queue_stamped(runtime, top, Some(0), PlayContext::artist(artist_id)).await;
|
||||||
@@ -1069,6 +1080,38 @@ pub async fn enqueue_artist_top_mode(
|
|||||||
enqueue_track_list_mode(runtime, queue, mode).await
|
enqueue_track_list_mode(runtime, queue, mode).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Immersive search (artist, next|queue) dispatch (contract
|
||||||
|
/// 2026-08-02-immersive-port §3.4, round-2-verified mapping): fetch the
|
||||||
|
/// artist page BY ID and enqueue its top tracks through the shared mode
|
||||||
|
/// funnel. NEW additive helper — the existing `enqueue_artist_top_mode`
|
||||||
|
/// reads the ArtistView stash (`artist_qt::top_queue`) and is BANNED from
|
||||||
|
/// immersive: there is no artist view under the overlay, so the stash would
|
||||||
|
/// be stale or empty. Unlike `play_artist` there is no discography fallback
|
||||||
|
/// — the Slint arm (`main.rs:10732-10749`) also enqueues top tracks ONLY.
|
||||||
|
pub async fn enqueue_artist_top_by_id(
|
||||||
|
runtime: &Arc<AppRuntime<LoggingAdapter>>,
|
||||||
|
artist_id: &str,
|
||||||
|
mode: &str,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let id: u64 = artist_id
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| format!("invalid artist id: {artist_id}"))?;
|
||||||
|
let page = runtime
|
||||||
|
.core()
|
||||||
|
.get_artist_page(id, None)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("get_artist_page {artist_id} failed: {e}"))?;
|
||||||
|
let tracks = artist_top_queue_tracks(
|
||||||
|
page.top_tracks.as_deref().unwrap_or(&[]),
|
||||||
|
artist_id,
|
||||||
|
&page.name.display,
|
||||||
|
);
|
||||||
|
if tracks.is_empty() {
|
||||||
|
return Err(format!("artist {artist_id} has no top tracks"));
|
||||||
|
}
|
||||||
|
enqueue_track_list_mode(runtime, tracks, mode).await
|
||||||
|
}
|
||||||
|
|
||||||
/// One track from an album context into the queue ("Play next" / "Add to
|
/// One track from an album context into the queue ("Play next" / "Add to
|
||||||
/// queue" on an AlbumView row).
|
/// queue" on an AlbumView row).
|
||||||
pub async fn enqueue_album_track(
|
pub async fn enqueue_album_track(
|
||||||
|
|||||||
@@ -923,6 +923,686 @@ pub async fn search_all_action(runtime: &Arc<AppRuntime<LoggingAdapter>>) {
|
|||||||
submit(runtime, &q, Some(0)).await;
|
submit(runtime, &q, Some(0)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Immersive search controller (contract §3.4 — port of main.rs:10359-10752)
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// The Slint immersive search is a SEPARATE Rust controller from the desktop
|
||||||
|
// cortinilla: it publishes on `QbzImmersive.immSearch*` (NEVER on
|
||||||
|
// `QbzBridge.cortinilla*` — the desktop Cortinilla self-gates on
|
||||||
|
// `cortinillaOpen`, which must stay false while immersive is open), it loads
|
||||||
|
// Artists/Albums/Playlists ONLY (no tracks, NO top-result hero), and a row
|
||||||
|
// activation ACTS ON PLAYBACK per the `immersive_search_action` pref instead
|
||||||
|
// of navigating — immersive has no navigation (main.rs:10362-10365), so
|
||||||
|
// `search_qt::row_clicked`'s `crate::open_album/open_artist` dispatch is the
|
||||||
|
// exact behavior Slint rejects and is NOT reused here.
|
||||||
|
//
|
||||||
|
// The 220 ms debounce + the >=2-char gate + the version guard live HERE in
|
||||||
|
// Rust (Slint-faithful, trap 17 — the desktop cortinilla's QML debounce in
|
||||||
|
// HeaderBar.qml is NOT reused); the QML field calls `QbzImmersive.searchLive`
|
||||||
|
// per keystroke.
|
||||||
|
|
||||||
|
/// Per-category caps for the IMMERSIVE cortinilla (search.rs:609-611).
|
||||||
|
const IMMERSIVE_CAP_ARTISTS: usize = 2;
|
||||||
|
const IMMERSIVE_CAP_ALBUMS: usize = 5;
|
||||||
|
const IMMERSIVE_CAP_PLAYLISTS: usize = 2;
|
||||||
|
|
||||||
|
/// Per-section caps for the LOCAL album section (search.rs LocalCaps,
|
||||||
|
/// :709-737). The NORMAL profile (online + signed in) keeps the on-device
|
||||||
|
/// block compact; the EXPANDED profile (offline OR an unauthenticated
|
||||||
|
/// session, so the dropdown is local-dominated) widens it. Only the `albums`
|
||||||
|
/// cap feeds the immersive UI (immersive shows local ALBUMS only); artists/
|
||||||
|
/// tracks are carried verbatim so `fetch_limit` stays the reference's
|
||||||
|
/// formula.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
struct LocalCaps {
|
||||||
|
albums: usize,
|
||||||
|
artists: usize,
|
||||||
|
tracks: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LocalCaps {
|
||||||
|
/// Normal profile (Qobuz present): compact on-device block.
|
||||||
|
const NORMAL: LocalCaps = LocalCaps { albums: 3, artists: 2, tracks: 3 };
|
||||||
|
/// Expanded profile (offline / not signed in → wider on-device block).
|
||||||
|
const EXPANDED: LocalCaps = LocalCaps { albums: 8, artists: 4, tracks: 8 };
|
||||||
|
|
||||||
|
/// search.rs:731-737 — `expand` is offline OR an unauthenticated session.
|
||||||
|
fn for_session(expand: bool) -> LocalCaps {
|
||||||
|
if expand { Self::EXPANDED } else { Self::NORMAL }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How many raw local TRACK rows to fetch so the grouped album section
|
||||||
|
/// can be filled: albums are DERIVED by grouping tracks, so a single
|
||||||
|
/// album can swallow many rows — over-fetch well beyond the shown cap
|
||||||
|
/// (search.rs:741-746).
|
||||||
|
fn fetch_limit(self) -> u64 {
|
||||||
|
((self.albums.max(self.tracks) * 12) + 40) as u64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Immersive controller state — an OWN version counter (1:1
|
||||||
|
/// `next_immersive_search_version`, main.rs:10415) and an own snapshot, fully
|
||||||
|
/// disjoint from the desktop cortinilla's CORT_VERSION / LAST_CORT.
|
||||||
|
static LAST_IMM: Mutex<Option<CortinillaData>> = Mutex::new(None);
|
||||||
|
static IMM_VERSION: AtomicU64 = AtomicU64::new(0);
|
||||||
|
/// The keyboard-selected flat index mirrored from the bridge property (so
|
||||||
|
/// `imm_move_selection` needs no QML round-trip — the desktop CURRENT_SEL
|
||||||
|
/// pattern, :682).
|
||||||
|
static IMM_SEL: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(-1);
|
||||||
|
|
||||||
|
fn next_imm_version() -> u64 {
|
||||||
|
IMM_VERSION.fetch_add(1, Ordering::SeqCst) + 1
|
||||||
|
}
|
||||||
|
fn is_current_imm_version(v: u64) -> bool {
|
||||||
|
IMM_VERSION.load(Ordering::SeqCst) == v
|
||||||
|
}
|
||||||
|
|
||||||
|
/// search.rs `map_search_all_to_immersive` (:617-706): sections **Artists,
|
||||||
|
/// Albums, Playlists IN THAT ORDER**, caps 2/5/2, **NO track rows, NO top
|
||||||
|
/// result** (immersive has no navigation — selecting acts on the queue). The
|
||||||
|
/// desktop mapper (`map_search_all_to_cortinilla`) builds a top result +
|
||||||
|
/// track rows + wrong caps and is NOT reused. Intra-category order still
|
||||||
|
/// applies the learned ranking before truncation (search.rs `take`).
|
||||||
|
fn map_search_all_to_immersive(query: &str, results: &SearchAllResults) -> CortinillaData {
|
||||||
|
let to_artist_row = |a: &Artist| CortRow {
|
||||||
|
kind: "artist".into(),
|
||||||
|
id: a.id.to_string(),
|
||||||
|
source: "qobuz".into(),
|
||||||
|
title: a.name.clone(),
|
||||||
|
subtitle: map_artist(a).subtitle,
|
||||||
|
art_url: a
|
||||||
|
.image
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|i| i.best().cloned())
|
||||||
|
.unwrap_or_default(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let to_album_row = |al: &Album| {
|
||||||
|
let m = map_album(al);
|
||||||
|
CortRow {
|
||||||
|
kind: "album".into(),
|
||||||
|
id: m.id,
|
||||||
|
source: "qobuz".into(),
|
||||||
|
title: m.title,
|
||||||
|
subtitle: m.artist,
|
||||||
|
art_url: m.art_url,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let to_playlist_row = |p: &Playlist| {
|
||||||
|
let m = map_playlist(p);
|
||||||
|
CortRow {
|
||||||
|
kind: "playlist".into(),
|
||||||
|
id: m.id,
|
||||||
|
source: "qobuz".into(),
|
||||||
|
title: m.title,
|
||||||
|
subtitle: m.subtitle,
|
||||||
|
art_url: m.art_url,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut artist_rows: Vec<CortRow> = results.artists.items.iter().map(&to_artist_row).collect();
|
||||||
|
let mut album_rows: Vec<CortRow> = results.albums.items.iter().map(&to_album_row).collect();
|
||||||
|
let mut playlist_rows: Vec<CortRow> =
|
||||||
|
results.playlists.items.iter().map(&to_playlist_row).collect();
|
||||||
|
// Intra-category order applies the learned ranking BEFORE truncation
|
||||||
|
// (search.rs `take`); the caps themselves live in the assembly seam.
|
||||||
|
rank_within(query, "artist", &mut artist_rows, |r| r.id.clone());
|
||||||
|
rank_within(query, "album", &mut album_rows, |r| r.id.clone());
|
||||||
|
rank_within(query, "playlist", &mut playlist_rows, |r| r.id.clone());
|
||||||
|
|
||||||
|
assemble_immersive_sections(
|
||||||
|
query,
|
||||||
|
artist_rows,
|
||||||
|
album_rows,
|
||||||
|
playlist_rows,
|
||||||
|
(results.artists.total, results.albums.total, results.playlists.total),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Section assembly, factored out of `map_search_all_to_immersive` so the
|
||||||
|
/// caps/order/flat-index contract is unit-testable without a SearchAllResults
|
||||||
|
/// fixture: caps Artists 2 / Albums 5 / Playlists 2 (search.rs:609-611),
|
||||||
|
/// sections Artists, Albums, Playlists IN THAT ORDER (search.rs:690-692),
|
||||||
|
/// empty sections dropped, `top: None`, flat indices from 1
|
||||||
|
/// (`assign_flat_indices`'s no-top arm, :664). Callers pass RANKED,
|
||||||
|
/// UNCAPPED rows; the caps are applied here.
|
||||||
|
fn assemble_immersive_sections(
|
||||||
|
query: &str,
|
||||||
|
mut artist_rows: Vec<CortRow>,
|
||||||
|
mut album_rows: Vec<CortRow>,
|
||||||
|
mut playlist_rows: Vec<CortRow>,
|
||||||
|
totals: (u32, u32, u32),
|
||||||
|
) -> CortinillaData {
|
||||||
|
artist_rows.truncate(IMMERSIVE_CAP_ARTISTS);
|
||||||
|
album_rows.truncate(IMMERSIVE_CAP_ALBUMS);
|
||||||
|
playlist_rows.truncate(IMMERSIVE_CAP_PLAYLISTS);
|
||||||
|
let mut sections: Vec<CortSection> = Vec::new();
|
||||||
|
let mut push = |title: &str, kind: &str, rows: Vec<CortRow>, total: u32| {
|
||||||
|
if !rows.is_empty() {
|
||||||
|
sections.push(CortSection {
|
||||||
|
title: title.to_string(),
|
||||||
|
kind: kind.to_string(),
|
||||||
|
has_more: total as usize > rows.len(),
|
||||||
|
rows,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
push(&qbz_i18n::t("Artists"), "artist", artist_rows, totals.0);
|
||||||
|
push(&qbz_i18n::t("Albums"), "album", album_rows, totals.1);
|
||||||
|
push(&qbz_i18n::t("Playlists"), "playlist", playlist_rows, totals.2);
|
||||||
|
|
||||||
|
let mut data = CortinillaData {
|
||||||
|
query: query.to_string(),
|
||||||
|
top: None,
|
||||||
|
sections,
|
||||||
|
};
|
||||||
|
assign_flat_indices(&mut data);
|
||||||
|
data
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The canonical "artist" attributed to a local track for grouping: the
|
||||||
|
/// album-artist tag when present, else the track performer
|
||||||
|
/// (search.rs:762-767).
|
||||||
|
fn local_album_artist(t: &qbz_library::LocalTrack) -> String {
|
||||||
|
t.album_artist
|
||||||
|
.clone()
|
||||||
|
.filter(|s| !s.is_empty())
|
||||||
|
.unwrap_or_else(|| t.artist.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Group local TRACK rows into local ALBUM cortinilla rows (`source =
|
||||||
|
/// "local"`, `kind = "album"`) — NEW PORT of search.rs
|
||||||
|
/// `derive_local_album_rows` (:774-805); the desktop controller never ported
|
||||||
|
/// local cortinilla sections (POC-NOTE, :25-28). Grouped by
|
||||||
|
/// `album_group_key` in first-seen order (the DB returns rows by match
|
||||||
|
/// relevance); `id` is the group key (the dispatch table's local arms play/
|
||||||
|
/// enqueue by group key). Returns the capped rows plus whether more distinct
|
||||||
|
/// albums existed than shown.
|
||||||
|
fn derive_local_album_rows(rows: &[qbz_library::LocalTrack], cap: usize) -> (Vec<CortRow>, bool) {
|
||||||
|
let mut seen: HashSet<String> = HashSet::new();
|
||||||
|
let mut out: Vec<CortRow> = Vec::new();
|
||||||
|
let mut total = 0usize;
|
||||||
|
for t in rows {
|
||||||
|
let key = t.album_group_key.clone();
|
||||||
|
if key.is_empty() || !seen.insert(key.clone()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
total += 1;
|
||||||
|
if out.len() >= cap {
|
||||||
|
continue; // keep counting for an honest has_more
|
||||||
|
}
|
||||||
|
let title = if t.album_group_title.is_empty() {
|
||||||
|
t.album.clone()
|
||||||
|
} else {
|
||||||
|
t.album_group_title.clone()
|
||||||
|
};
|
||||||
|
// Artwork routing (the one departure from the Slint row builder, which
|
||||||
|
// stores the RAW path and lets its artwork dispatcher route by
|
||||||
|
// scheme): a local fs cover is handed to QML directly as a file://
|
||||||
|
// url; a Plex/http cover rides the SHARED attach_urls +
|
||||||
|
// download_missing flow like the Qobuz rows (artwork_qt::classify
|
||||||
|
// owns the taxonomy — `cached_path`/`download_missing` re-classify
|
||||||
|
// the raw path, so the cache entry is shared with the Local Library
|
||||||
|
// grid).
|
||||||
|
let (art_url, art_path) = match t.artwork_path.as_deref().filter(|p| !p.is_empty()) {
|
||||||
|
Some(p) => match crate::artwork_qt::classify(p) {
|
||||||
|
crate::artwork_qt::ArtUrl::LocalFile(_) => {
|
||||||
|
(String::new(), crate::artwork_qt::file_url(p))
|
||||||
|
}
|
||||||
|
crate::artwork_qt::ArtUrl::Empty => (String::new(), String::new()),
|
||||||
|
// Plex / http: fetchable — the shared pipeline resolves it.
|
||||||
|
_ => (p.to_string(), String::new()),
|
||||||
|
},
|
||||||
|
None => (String::new(), String::new()),
|
||||||
|
};
|
||||||
|
out.push(CortRow {
|
||||||
|
kind: "album".into(),
|
||||||
|
id: key,
|
||||||
|
source: "local".into(),
|
||||||
|
title,
|
||||||
|
subtitle: local_album_artist(t),
|
||||||
|
art_url,
|
||||||
|
art_path,
|
||||||
|
flat_index: 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let has_more = total > out.len();
|
||||||
|
(out, has_more)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Append the local ALBUM section to an immersive payload (search.rs
|
||||||
|
/// `append_immersive_local_albums`, :930-953): LAST, after every Qobuz
|
||||||
|
/// section, section kind `local-album`. No "View more" in immersive, so
|
||||||
|
/// `has_more` is carried but unused. Re-runs `assign_flat_indices` so the
|
||||||
|
/// local rows get contiguous flat indices after the Qobuz sections. No-op
|
||||||
|
/// when `rows` is empty.
|
||||||
|
fn append_immersive_local_albums(
|
||||||
|
data: &mut CortinillaData,
|
||||||
|
rows: &[qbz_library::LocalTrack],
|
||||||
|
cap: usize,
|
||||||
|
) {
|
||||||
|
if rows.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let (album_rows, has_more) = derive_local_album_rows(rows, cap);
|
||||||
|
if album_rows.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.sections.push(CortSection {
|
||||||
|
title: qbz_i18n::t("Albums on Local Library"),
|
||||||
|
kind: "local-album".to_string(),
|
||||||
|
rows: album_rows,
|
||||||
|
has_more,
|
||||||
|
});
|
||||||
|
assign_flat_indices(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch up to `limit` local-library tracks matching `query`, off the UI
|
||||||
|
/// thread (search.rs `load_cortinilla_local` with `gated = false`, :955-1011
|
||||||
|
/// — the immersive search is governed by its OWN "search action" enable,
|
||||||
|
/// independent of the main cortinilla's intelligent-search toggle). Raw
|
||||||
|
/// materials: `with_db` + `db.search_with_filter_page` + the Plex prepend
|
||||||
|
/// (pattern local_albums.rs:255-278).
|
||||||
|
async fn load_imm_local(query: String, limit: u64) -> Vec<qbz_library::LocalTrack> {
|
||||||
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let mut rows = crate::local_state::with_db(|db| {
|
||||||
|
// "default" sort: the cortinilla has no sort control; keep the
|
||||||
|
// historical album-grouped order (search.rs:965-968). The
|
||||||
|
// exclude_network_folders=false arm is the crate-wide documented
|
||||||
|
// GAP (myqbz_builder_qt.rs:29-31 — the Qt port has no
|
||||||
|
// exclude_network_folders_now twin).
|
||||||
|
db.search_with_filter_page(query.trim(), 0, limit, true, false, "default")
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
// Plex is part of the user's Local Library, so the cortinilla
|
||||||
|
// includes it too — PREPENDED so Plex content is visible without
|
||||||
|
// scrolling past a full local page (search.rs:975-1002).
|
||||||
|
if crate::local_plex::is_enabled() {
|
||||||
|
let mut merged = crate::local_plex::search_tracks(&query);
|
||||||
|
merged.append(&mut rows);
|
||||||
|
rows = merged;
|
||||||
|
}
|
||||||
|
rows
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `QbzImmersive.searchLive` (the immersive `on_live`, main.rs:10376-10472):
|
||||||
|
/// gate -> 2-char gate -> open + reset -> debounced version-guarded load.
|
||||||
|
/// `overlay_open` is read by the bridge invokable (the property lives on the
|
||||||
|
/// Qt thread); everything else is re-read FRESH here.
|
||||||
|
pub fn imm_live(overlay_open: bool, query: String) {
|
||||||
|
// Gate: only while the immersive overlay is open AND the configured
|
||||||
|
// action is not "disabled" (the action doubles as the enable switch,
|
||||||
|
// main.rs:10380-10386). The pref is re-read on EVERY keystroke — it can
|
||||||
|
// change in Settings while immersive is open (main.rs:10384). disabled ⇒
|
||||||
|
// no-op: imm_search_open NEVER flips true.
|
||||||
|
if !overlay_open {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if crate::settings_qt::pref_str("immersive_search_action", "replace") == "disabled" {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let q = query.trim().to_string();
|
||||||
|
// chars().count(): grapheme-ish length so a 2-char multibyte query (CJK)
|
||||||
|
// is not rejected (main.rs:10390).
|
||||||
|
if q.chars().count() < 2 {
|
||||||
|
// Below the threshold — cancel the pending debounce (the version bump
|
||||||
|
// makes the sleeping task stale, main.rs:10392's timer stop) and close
|
||||||
|
// the dropdown so a backspaced query leaves no stale one open.
|
||||||
|
next_imm_version();
|
||||||
|
IMM_SEL.store(-1, Ordering::SeqCst);
|
||||||
|
crate::immersive_bridge::ui(|mut b| {
|
||||||
|
b.as_mut().set_imm_search_open(false);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open + loading; ALWAYS reset selection + scroll on every refine —
|
||||||
|
// never leave a stale "active row" from a prior query
|
||||||
|
// (main.rs:10403-10407). Arrow nav fires no keystroke through here, so it
|
||||||
|
// is unaffected.
|
||||||
|
IMM_SEL.store(-1, Ordering::SeqCst);
|
||||||
|
crate::immersive_bridge::ui(|mut b| {
|
||||||
|
b.as_mut().set_imm_search_open(true);
|
||||||
|
b.as_mut().set_imm_search_loading(true);
|
||||||
|
b.as_mut().set_imm_search_selected_index(-1);
|
||||||
|
b.as_mut().set_imm_search_scroll_y(0.0);
|
||||||
|
});
|
||||||
|
// Offline OR an unauthenticated session → widen the on-device album cap
|
||||||
|
// (main.rs:10409-10414 reads OfflineState.offline || offline_session).
|
||||||
|
let status = crate::offline_fwd::engine().status();
|
||||||
|
let expand_local = status.is_offline() || status.offline_session;
|
||||||
|
let version = next_imm_version();
|
||||||
|
let runtime = crate::app();
|
||||||
|
crate::spawn(async move {
|
||||||
|
// 220 ms RUST debounce (main.rs:10422-10471): a newer keystroke bumps
|
||||||
|
// the version, and this task exits without loading when it wakes.
|
||||||
|
tokio::time::sleep(std::time::Duration::from_millis(220)).await;
|
||||||
|
if !is_current_imm_version(version) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
imm_load(&runtime, q, expand_local, version).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The debounced load (search.rs `load_immersive_search`, :1153-1199): Qobuz
|
||||||
|
/// catalog + local albums CONCURRENTLY; a Qobuz failure degrades to a
|
||||||
|
/// local-only dropdown instead of discarding everything.
|
||||||
|
async fn imm_load(
|
||||||
|
runtime: &Arc<AppRuntime<LoggingAdapter>>,
|
||||||
|
q: String,
|
||||||
|
expand_local: bool,
|
||||||
|
version: u64,
|
||||||
|
) {
|
||||||
|
// Blacklist filtering happens INSIDE search_all (`search.rs:1112-1115`),
|
||||||
|
// same as the desktop live path (:735).
|
||||||
|
let (bl, abl) = blacklist_snapshots();
|
||||||
|
let caps = LocalCaps::for_session(expand_local);
|
||||||
|
let q_local = q.clone();
|
||||||
|
let limit = caps.fetch_limit();
|
||||||
|
let (results, local_rows) = tokio::join!(
|
||||||
|
runtime.core().search_all(&q, &bl, &abl),
|
||||||
|
load_imm_local(q_local, limit),
|
||||||
|
);
|
||||||
|
let mut data = match results {
|
||||||
|
Ok(r) => map_search_all_to_immersive(&q, &r),
|
||||||
|
Err(e) => {
|
||||||
|
// Qobuz failed (offline / API error). The on-device rows resolved
|
||||||
|
// independently, so still build a dropdown from JUST the local
|
||||||
|
// section (search.rs:1186-1193). An empty local set then yields an
|
||||||
|
// empty payload (the overlay shows only "No results for …").
|
||||||
|
log::error!("[qbz-qt] immersive search load failed: {e}");
|
||||||
|
CortinillaData {
|
||||||
|
query: q.clone(),
|
||||||
|
top: None,
|
||||||
|
sections: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
append_immersive_local_albums(&mut data, &local_rows, caps.albums);
|
||||||
|
|
||||||
|
// Artwork: disk hits inline; misses (Qobuz CDN + Plex thumbs) download in
|
||||||
|
// the background and republish the SAME payload, version-guarded
|
||||||
|
// (:461-481,:755-801).
|
||||||
|
let mut urls: Vec<(String, &mut String)> = Vec::new();
|
||||||
|
for section in &mut data.sections {
|
||||||
|
for row in &mut section.rows {
|
||||||
|
urls.push((row.art_url.clone(), &mut row.art_path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let missing = attach_urls(urls);
|
||||||
|
*LAST_IMM.lock().unwrap() = Some(data.clone());
|
||||||
|
crate::immersive_bridge::ui(move |mut b| {
|
||||||
|
if is_current_imm_version(version) {
|
||||||
|
let json = serde_json::to_string(&data).unwrap_or_else(|_| "{}".into());
|
||||||
|
b.as_mut().set_imm_search_json(QString::from(json.as_str()));
|
||||||
|
b.as_mut().set_imm_search_loading(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if !missing.is_empty() {
|
||||||
|
crate::spawn(async move {
|
||||||
|
crate::artwork_qt::download_missing(missing).await;
|
||||||
|
if !is_current_imm_version(version) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut snap = LAST_IMM.lock().unwrap().clone();
|
||||||
|
if let Some(data) = &mut snap {
|
||||||
|
let mut urls: Vec<(String, &mut String)> = Vec::new();
|
||||||
|
for section in &mut data.sections {
|
||||||
|
for row in &mut section.rows {
|
||||||
|
urls.push((row.art_url.clone(), &mut row.art_path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = attach_urls(urls);
|
||||||
|
let data = data.clone();
|
||||||
|
*LAST_IMM.lock().unwrap() = Some(data.clone());
|
||||||
|
crate::immersive_bridge::ui(move |mut b| {
|
||||||
|
let json = serde_json::to_string(&data).unwrap_or_else(|_| "{}".into());
|
||||||
|
b.as_mut().set_imm_search_json(QString::from(json.as_str()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Arrow-key move (the immersive `on_move_selection`, main.rs:10506-10548).
|
||||||
|
/// The immersive payload has NO top result, so the navigable order is built
|
||||||
|
/// from section rows only (flat indices start at 1). Both ends clamp — NO
|
||||||
|
/// wrap.
|
||||||
|
pub fn imm_move_selection(delta: i32) {
|
||||||
|
let current = IMM_SEL.load(Ordering::SeqCst);
|
||||||
|
let snap = LAST_IMM.lock().unwrap().clone();
|
||||||
|
let Some(data) = snap else { return };
|
||||||
|
let order: Vec<i32> = data
|
||||||
|
.sections
|
||||||
|
.iter()
|
||||||
|
.flat_map(|s| s.rows.iter().map(|r| r.flat_index))
|
||||||
|
.collect();
|
||||||
|
if order.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let new_index = imm_next_selection(&order, current, delta);
|
||||||
|
// Content-top y of the selected row so the overlay scrolls it into view
|
||||||
|
// (main.rs:10520-10548). The immersive cortinilla has NO top-result
|
||||||
|
// block: each section block = padTop 4 + header 24, rows are 56. These
|
||||||
|
// constants MUST match ImmersiveSearchCortinilla.qml's layout.
|
||||||
|
let scroll_y = imm_scroll_y(&data, new_index);
|
||||||
|
IMM_SEL.store(new_index, Ordering::SeqCst);
|
||||||
|
crate::immersive_bridge::ui(move |mut b| {
|
||||||
|
b.as_mut().set_imm_search_selected_index(new_index);
|
||||||
|
b.as_mut().set_imm_search_scroll_y(scroll_y);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The clamp, verbatim (main.rs:10524-10540): Down from -1 lands on the
|
||||||
|
/// first row, Up from the first row returns to -1, both ends clamp.
|
||||||
|
fn imm_next_selection(order: &[i32], current: i32, delta: i32) -> i32 {
|
||||||
|
let pos = order.iter().position(|&fi| fi == current);
|
||||||
|
if delta > 0 {
|
||||||
|
match pos {
|
||||||
|
None => order[0],
|
||||||
|
Some(p) if p + 1 < order.len() => order[p + 1],
|
||||||
|
Some(_) => order[order.len() - 1],
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match pos {
|
||||||
|
None => -1,
|
||||||
|
Some(0) => -1,
|
||||||
|
Some(p) => order[p - 1],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Content-space top-y of a flat index under the no-top-result layout:
|
||||||
|
/// per-section 28 (padTop 4 + header 24) + 56 per row (main.rs:10530-10547).
|
||||||
|
/// -1 (and any unknown index) scrolls to the top.
|
||||||
|
fn imm_scroll_y(data: &CortinillaData, flat_index: i32) -> f64 {
|
||||||
|
if flat_index < 0 {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
let mut y = 0.0f64;
|
||||||
|
for section in &data.sections {
|
||||||
|
y += 28.0; // padTop 4 + header 24
|
||||||
|
for row in §ion.rows {
|
||||||
|
if row.flat_index == flat_index {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
y += 56.0; // row height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `QbzImmersive.dismissSearch` (main.rs:10552-10564): clears the dropdown +
|
||||||
|
/// the selection.
|
||||||
|
pub fn imm_dismiss() {
|
||||||
|
IMM_SEL.store(-1, Ordering::SeqCst);
|
||||||
|
crate::immersive_bridge::ui(|mut b| {
|
||||||
|
b.as_mut().set_imm_search_open(false);
|
||||||
|
b.as_mut().set_imm_search_selected_index(-1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The round-2-verified dispatch decision (contract §3.4), factored pure so
|
||||||
|
/// the whole table is unit-testable. `action` is the FRESH pref value
|
||||||
|
/// ("replace" | "next" | "queue" — "disabled" is guarded by the caller).
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
enum ImmDispatch {
|
||||||
|
/// local_playback::play_album(rt, key, None, false)
|
||||||
|
LocalPlay,
|
||||||
|
/// local_playback::enqueue(rt, "album", key, mode) — it re-fetches +
|
||||||
|
/// cover-fills itself; do NOT hand-roll the fetch_album_tracks_blocking +
|
||||||
|
/// fill_missing_covers pair (contract §3.4).
|
||||||
|
LocalEnqueue(String),
|
||||||
|
/// playback_qt::play_album
|
||||||
|
PlayAlbum,
|
||||||
|
/// playlist_qt::play_playlist_by_id
|
||||||
|
PlayPlaylist,
|
||||||
|
/// playback_qt::play_artist
|
||||||
|
PlayArtist,
|
||||||
|
/// playback_qt::enqueue_album(rt, id, mode)
|
||||||
|
EnqueueAlbum(String),
|
||||||
|
/// playlist_qt::enqueue_playlist_by_id(rt, id, mode)
|
||||||
|
EnqueuePlaylist(String),
|
||||||
|
/// playback_qt::enqueue_artist_top_by_id(rt, id, mode)
|
||||||
|
EnqueueArtistTop(String),
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// (row.source, row.kind, action) -> the playback target. Local album rows
|
||||||
|
/// branch BEFORE the Qobuz match — a local album's id is a group key, not a
|
||||||
|
/// numeric Qobuz id (main.rs:10614-10621).
|
||||||
|
fn imm_dispatch(source: &str, kind: &str, action: &str) -> ImmDispatch {
|
||||||
|
if source == "local" {
|
||||||
|
return match action {
|
||||||
|
"replace" => ImmDispatch::LocalPlay,
|
||||||
|
"next" | "queue" => ImmDispatch::LocalEnqueue(action.to_string()),
|
||||||
|
_ => ImmDispatch::None,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
match (kind, action) {
|
||||||
|
("album", "replace") => ImmDispatch::PlayAlbum,
|
||||||
|
("playlist", "replace") => ImmDispatch::PlayPlaylist,
|
||||||
|
("artist", "replace") => ImmDispatch::PlayArtist,
|
||||||
|
("album", mode @ ("next" | "queue")) => ImmDispatch::EnqueueAlbum(mode.to_string()),
|
||||||
|
("playlist", mode @ ("next" | "queue")) => ImmDispatch::EnqueuePlaylist(mode.to_string()),
|
||||||
|
("artist", mode @ ("next" | "queue")) => ImmDispatch::EnqueueArtistTop(mode.to_string()),
|
||||||
|
_ => ImmDispatch::None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `QbzImmersive.searchRowActivated` (main.rs:10579-10751): resolve the flat
|
||||||
|
/// index against the controller snapshot, close the dropdown + clear the
|
||||||
|
/// field (the user STAYS in immersive — no navigation), then dispatch to
|
||||||
|
/// playback per the FRESH pref.
|
||||||
|
pub fn imm_row_activated(flat_index: i32) {
|
||||||
|
let snap = LAST_IMM.lock().unwrap().clone();
|
||||||
|
let Some(data) = snap else { return };
|
||||||
|
let row = data
|
||||||
|
.sections
|
||||||
|
.iter()
|
||||||
|
.flat_map(|s| s.rows.iter())
|
||||||
|
.find(|r| r.flat_index == flat_index)
|
||||||
|
.cloned();
|
||||||
|
let Some(row) = row else { return };
|
||||||
|
|
||||||
|
// Close the dropdown (STAY in immersive) AND clear the field, mirroring
|
||||||
|
// the main cortinilla: once a result is activated, a lingering query
|
||||||
|
// would re-invoke the dropdown when focus returns to the field
|
||||||
|
// (main.rs:10595-10599).
|
||||||
|
IMM_SEL.store(-1, Ordering::SeqCst);
|
||||||
|
crate::immersive_bridge::ui(|mut b| {
|
||||||
|
b.as_mut().set_imm_search_open(false);
|
||||||
|
b.as_mut().set_imm_search_selected_index(-1);
|
||||||
|
b.as_mut().set_search_input_text(QString::from(""));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Read the configured action FRESH (it can change in Settings while
|
||||||
|
// immersive is open — main.rs:10601-10608). "disabled" is also gated
|
||||||
|
// upstream in imm_live, but guard here too in case the dropdown was
|
||||||
|
// already open when it flipped.
|
||||||
|
let action = crate::settings_qt::pref_str("immersive_search_action", "replace");
|
||||||
|
if action == "disabled" {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let runtime = crate::app();
|
||||||
|
match imm_dispatch(&row.source, &row.kind, &action) {
|
||||||
|
ImmDispatch::LocalPlay => {
|
||||||
|
let key = row.id.clone();
|
||||||
|
crate::spawn(async move {
|
||||||
|
crate::local_playback::play_album(&runtime, key, None, false).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ImmDispatch::LocalEnqueue(mode) => {
|
||||||
|
let key = row.id.clone();
|
||||||
|
crate::spawn(async move {
|
||||||
|
crate::local_playback::enqueue(&runtime, "album".to_string(), key, mode).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ImmDispatch::PlayAlbum => {
|
||||||
|
let id = row.id.clone();
|
||||||
|
crate::spawn(async move {
|
||||||
|
if let Err(e) = crate::playback_qt::play_album(&runtime, &id).await {
|
||||||
|
log::error!("[qbz-qt] immersive search play_album {id}: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ImmDispatch::PlayPlaylist => {
|
||||||
|
if let Ok(pid) = row.id.parse::<u64>() {
|
||||||
|
crate::spawn(async move {
|
||||||
|
if let Err(e) = crate::playlist_qt::play_playlist_by_id(&runtime, pid).await {
|
||||||
|
log::error!("[qbz-qt] immersive search play_playlist {pid}: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImmDispatch::PlayArtist => {
|
||||||
|
let id = row.id.clone();
|
||||||
|
crate::spawn(async move {
|
||||||
|
if let Err(e) = crate::playback_qt::play_artist(&runtime, &id).await {
|
||||||
|
log::error!("[qbz-qt] immersive search play_artist {id}: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ImmDispatch::EnqueueAlbum(mode) => {
|
||||||
|
let id = row.id.clone();
|
||||||
|
crate::spawn(async move {
|
||||||
|
if let Err(e) = crate::playback_qt::enqueue_album(&runtime, &id, &mode).await {
|
||||||
|
log::error!("[qbz-qt] immersive search enqueue_album {id} ({mode}): {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ImmDispatch::EnqueuePlaylist(mode) => {
|
||||||
|
if let Ok(pid) = row.id.parse::<u64>() {
|
||||||
|
crate::spawn(async move {
|
||||||
|
if let Err(e) =
|
||||||
|
crate::playlist_qt::enqueue_playlist_by_id(&runtime, pid, &mode).await
|
||||||
|
{
|
||||||
|
log::error!("[qbz-qt] immersive search enqueue_playlist {pid} ({mode}): {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImmDispatch::EnqueueArtistTop(mode) => {
|
||||||
|
let id = row.id.clone();
|
||||||
|
crate::spawn(async move {
|
||||||
|
if let Err(e) =
|
||||||
|
crate::playback_qt::enqueue_artist_top_by_id(&runtime, &id, &mode).await
|
||||||
|
{
|
||||||
|
log::error!("[qbz-qt] immersive search enqueue_artist_top {id} ({mode}): {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ImmDispatch::None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Results page
|
// Results page
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -1572,4 +2252,138 @@ mod tests {
|
|||||||
assert_eq!(tier(Some(16)), "cd");
|
assert_eq!(tier(Some(16)), "cd");
|
||||||
assert_eq!(tier(None), "");
|
assert_eq!(tier(None), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Immersive search controller (§3.4)
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
fn imm_row(kind: &str, id: &str, source: &str) -> CortRow {
|
||||||
|
CortRow {
|
||||||
|
kind: kind.into(),
|
||||||
|
id: id.into(),
|
||||||
|
source: source.into(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn immersive_sections_order_caps_and_flat_indices() {
|
||||||
|
// Contract §3.4 / search.rs:609-611,690-692: Artists, Albums,
|
||||||
|
// Playlists IN THAT ORDER; caps 2/5/2; NO top result; NO track rows;
|
||||||
|
// flat indices from 1 (main.rs:10491-10499).
|
||||||
|
let artists: Vec<CortRow> = (0..4).map(|i| imm_row("artist", &format!("ar{i}"), "qobuz")).collect();
|
||||||
|
let albums: Vec<CortRow> = (0..7).map(|i| imm_row("album", &format!("al{i}"), "qobuz")).collect();
|
||||||
|
let playlists: Vec<CortRow> = (0..3).map(|i| imm_row("playlist", &format!("pl{i}"), "qobuz")).collect();
|
||||||
|
let data = assemble_immersive_sections("q", artists, albums, playlists, (4, 7, 3));
|
||||||
|
|
||||||
|
assert!(data.top.is_none(), "the immersive payload has NO top result");
|
||||||
|
let kinds: Vec<&str> = data.sections.iter().map(|s| s.kind.as_str()).collect();
|
||||||
|
assert_eq!(kinds, ["artist", "album", "playlist"], "section order is Artists/Albums/Playlists");
|
||||||
|
assert_eq!(data.sections[0].rows.len(), 2, "artists cap 2");
|
||||||
|
assert_eq!(data.sections[1].rows.len(), 5, "albums cap 5");
|
||||||
|
assert_eq!(data.sections[2].rows.len(), 2, "playlists cap 2");
|
||||||
|
assert!(data.sections.iter().all(|s| s.has_more), "totals exceed every cap");
|
||||||
|
// Flat indices run from 1, contiguous across sections.
|
||||||
|
let flats: Vec<i32> = data
|
||||||
|
.sections
|
||||||
|
.iter()
|
||||||
|
.flat_map(|s| s.rows.iter().map(|r| r.flat_index))
|
||||||
|
.collect();
|
||||||
|
assert_eq!(flats, (1..=9).collect::<Vec<i32>>());
|
||||||
|
assert!(data.sections.iter().flat_map(|s| s.rows.iter()).all(|r| r.kind != "track"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn immersive_sections_drop_empty_sections() {
|
||||||
|
let data = assemble_immersive_sections(
|
||||||
|
"q",
|
||||||
|
vec![],
|
||||||
|
vec![imm_row("album", "a1", "qobuz")],
|
||||||
|
vec![],
|
||||||
|
(0, 1, 0),
|
||||||
|
);
|
||||||
|
assert_eq!(data.sections.len(), 1);
|
||||||
|
assert_eq!(data.sections[0].kind, "album");
|
||||||
|
assert!(!data.sections[0].has_more);
|
||||||
|
assert_eq!(data.sections[0].rows[0].flat_index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn immersive_dispatch_table_matches_the_contract() {
|
||||||
|
// Contract §3.4 round-2-verified mapping (main.rs:10614-10749).
|
||||||
|
// Local album rows branch BEFORE the Qobuz match (the id is a group
|
||||||
|
// key, not a numeric Qobuz id).
|
||||||
|
assert_eq!(imm_dispatch("local", "album", "replace"), ImmDispatch::LocalPlay);
|
||||||
|
assert_eq!(imm_dispatch("local", "album", "next"), ImmDispatch::LocalEnqueue("next".into()));
|
||||||
|
assert_eq!(imm_dispatch("local", "album", "queue"), ImmDispatch::LocalEnqueue("queue".into()));
|
||||||
|
// Qobuz replace arms.
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "album", "replace"), ImmDispatch::PlayAlbum);
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "playlist", "replace"), ImmDispatch::PlayPlaylist);
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "artist", "replace"), ImmDispatch::PlayArtist);
|
||||||
|
// Qobuz next/queue arms (mode carried verbatim).
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "album", "next"), ImmDispatch::EnqueueAlbum("next".into()));
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "album", "queue"), ImmDispatch::EnqueueAlbum("queue".into()));
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "playlist", "next"), ImmDispatch::EnqueuePlaylist("next".into()));
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "playlist", "queue"), ImmDispatch::EnqueuePlaylist("queue".into()));
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "artist", "next"), ImmDispatch::EnqueueArtistTop("next".into()));
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "artist", "queue"), ImmDispatch::EnqueueArtistTop("queue".into()));
|
||||||
|
// Unknown combinations are inert (no track rows exist in the payload;
|
||||||
|
// an unknown action does nothing).
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "track", "replace"), ImmDispatch::None);
|
||||||
|
assert_eq!(imm_dispatch("qobuz", "album", "later"), ImmDispatch::None);
|
||||||
|
assert_eq!(imm_dispatch("local", "album", "later"), ImmDispatch::None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn immersive_selection_clamps_both_ends_no_wrap() {
|
||||||
|
// main.rs:10524-10540: Down from -1 -> first row; Up from the first
|
||||||
|
// row -> -1; both ends clamp (no wrap).
|
||||||
|
let order = vec![1, 2, 3, 4];
|
||||||
|
assert_eq!(imm_next_selection(&order, -1, 1), 1, "Down from -1 lands on the first row");
|
||||||
|
assert_eq!(imm_next_selection(&order, -1, -1), -1, "Up from -1 stays at -1");
|
||||||
|
assert_eq!(imm_next_selection(&order, 1, -1), -1, "Up from the first row returns to -1");
|
||||||
|
assert_eq!(imm_next_selection(&order, 1, 1), 2);
|
||||||
|
assert_eq!(imm_next_selection(&order, 4, 1), 4, "Down on the last row clamps (no wrap)");
|
||||||
|
assert_eq!(imm_next_selection(&order, 3, -1), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn immersive_scroll_arithmetic_matches_the_no_top_layout() {
|
||||||
|
// main.rs:10530-10547: per-section padTop 4 + header 24 (= 28), 56
|
||||||
|
// per row, NO top-result block. Section 1 has 2 rows, section 2 has 1.
|
||||||
|
let mut data = CortinillaData {
|
||||||
|
query: "q".into(),
|
||||||
|
top: None,
|
||||||
|
sections: vec![
|
||||||
|
CortSection {
|
||||||
|
title: "Artists".into(),
|
||||||
|
kind: "artist".into(),
|
||||||
|
has_more: false,
|
||||||
|
rows: vec![imm_row("artist", "1", "qobuz"), imm_row("artist", "2", "qobuz")],
|
||||||
|
},
|
||||||
|
CortSection {
|
||||||
|
title: "Albums".into(),
|
||||||
|
kind: "album".into(),
|
||||||
|
has_more: false,
|
||||||
|
rows: vec![imm_row("album", "3", "qobuz")],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
assign_flat_indices(&mut data);
|
||||||
|
assert_eq!(imm_scroll_y(&data, -1), 0.0, "no selection scrolls to the top");
|
||||||
|
assert_eq!(imm_scroll_y(&data, 1), 28.0, "first section header block");
|
||||||
|
assert_eq!(imm_scroll_y(&data, 2), 84.0, "28 + one 56px row");
|
||||||
|
assert_eq!(imm_scroll_y(&data, 3), 168.0, "28 + 2*56 + the second section's 28");
|
||||||
|
assert_eq!(imm_scroll_y(&data, 99), 0.0, "unknown index falls to 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn local_caps_profiles_and_fetch_limit() {
|
||||||
|
// search.rs:717-746: normal 3/2/3, expanded 8/4/8; fetch_limit =
|
||||||
|
// max(albums, tracks) * 12 + 40.
|
||||||
|
assert_eq!(LocalCaps::for_session(false), LocalCaps { albums: 3, artists: 2, tracks: 3 });
|
||||||
|
assert_eq!(LocalCaps::for_session(true), LocalCaps { albums: 8, artists: 4, tracks: 8 });
|
||||||
|
assert_eq!(LocalCaps::NORMAL.fetch_limit(), 76);
|
||||||
|
assert_eq!(LocalCaps::EXPANDED.fetch_limit(), 136);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user