diff --git a/.github/workflows/test-crates.yml b/.github/workflows/test-crates.yml index 69631fbf7..164d17456 100644 --- a/.github/workflows/test-crates.yml +++ b/.github/workflows/test-crates.yml @@ -91,6 +91,7 @@ on: - "scripts/test-array-model-qml.sh" - "scripts/test-keyed-model-qml.sh" - "scripts/test-multi-select-qml.sh" + - "scripts/test-track-row-click-qml.sh" - "scripts/test-settings-fieldset-qml.sh" - "scripts/test-remote-volume-qml.sh" - "scripts/test-wallpaper-field-qml.sh" @@ -126,6 +127,7 @@ on: - "scripts/test-array-model-qml.sh" - "scripts/test-keyed-model-qml.sh" - "scripts/test-multi-select-qml.sh" + - "scripts/test-track-row-click-qml.sh" - "scripts/test-settings-fieldset-qml.sh" - "scripts/test-remote-volume-qml.sh" - "scripts/test-wallpaper-field-qml.sh" diff --git a/crates/qbz-qt/qml/immersive/SuggestionsPanel.qml b/crates/qbz-qt/qml/immersive/SuggestionsPanel.qml index 329c72587..2e4297d05 100644 --- a/crates/qbz-qt/qml/immersive/SuggestionsPanel.qml +++ b/crates/qbz-qt/qml/immersive/SuggestionsPanel.qml @@ -400,7 +400,8 @@ Item { width: parent ? parent.width : 0 height: 56 radius: 8 - color: rowArea.containsMouse ? "#21ffffff" : "transparent" + readonly property bool hovered: rowArea.containsMouse || artPlayArea.containsMouse + color: recRow.hovered ? "#21ffffff" : "transparent" Behavior on color { ColorAnimation { duration: 150 } } Row { @@ -427,7 +428,7 @@ Item { Rectangle { anchors.fill: parent color: "#80000000" - opacity: rowArea.containsMouse ? 1.0 : 0.0 + opacity: recRow.hovered ? 1.0 : 0.0 Behavior on opacity { NumberAnimation { duration: 150 } } QbzIcon { name: "play-fill" @@ -437,6 +438,14 @@ Item { tintName: "white" } } + // The hover disc is the row's play button: first click plays. + MouseArea { + id: artPlayArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: QbzSuggestions.playTrack(recRow.track.id) + } } // Title + artist (:340-357). @@ -472,12 +481,15 @@ Item { } } + // The track-row policy (#790, rows/TrackRow.qml `clickPlays`): a + // single click on the body does nothing, a double click plays. Behind + // the cells (z -1) so the artwork's play button answers its own click. MouseArea { id: rowArea + z: -1 anchors.fill: parent hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: QbzSuggestions.playTrack(track.id) + onDoubleClicked: QbzSuggestions.playTrack(recRow.track.id) } } diff --git a/crates/qbz-qt/qml/rows/TrackRow.qml b/crates/qbz-qt/qml/rows/TrackRow.qml index aef60795c..bd4f0320f 100644 --- a/crates/qbz-qt/qml/rows/TrackRow.qml +++ b/crates/qbz-qt/qml/rows/TrackRow.qml @@ -100,8 +100,19 @@ Rectangle { property bool queueOnly: false property bool zebra: false property bool artistLink: false - property bool clickPlays: true - // Debounce for clickPlays rows (see onReleased). + /// Does a SINGLE click on the row body play? Only on a kiosk host. + /// + /// Desktop policy (#790), the same on every surface: the play disc plays + /// on its first click, a single click on the body does nothing (it is + /// where a select, a drag or a right-click starts), and a double click on + /// any part of the row that is not a control plays. Playlists, search, + /// the queue and the library used to play on one click while the album + /// page needed two — one gesture meaning two things by screen. + /// + /// The kiosk keeps tap-to-play: it is driven by touch, has no hover to + /// reveal the play disc, and a double tap is not a touch convention. + property bool clickPlays: root.kioskHost + // Debounce for clickPlays rows (see bodyClicked). property real _lastPlayRequestMs: 0 /// RETIRED and INERT. primitives/TrackRow.slint has exactly ONE quality /// form (the bare QualityBadgeFull below) — there was never an icon/text @@ -579,7 +590,7 @@ Rectangle { // ENABLED even when the chevron is not armed, and the click is // swallowed instead. A DISABLED MouseArea does not accept the // press at all, so it fell through to the row body underneath - // (`trArea`, z:-1) — and this surface has `clickPlays: true`, so + // (`trArea`, z:-1) — and a kiosk host has `clickPlays` on, so // clicking the greyed-out ↑ on the first row STARTED PLAYBACK. // The reference has no disabled state at all (its chevrons are // always armed and the Rust arm no-ops at the ends), so a dead @@ -836,9 +847,9 @@ Rectangle { // TrackPlayCell.slint:234-243 — the cell is its OWN click target: // a non-current cell plays the track, the current cell toggles // play/pause. Without it the circle was a control that rendered - // and did nothing on the album view (clickPlays:false there, so - // the press fell through to the row body, which only reacts to a - // double-click). Declared LAST so it sits ABOVE the glyph, and it + // and did nothing on the album view (clickPlays off, so the press + // fell through to the row body, which only reacts to a double + // click) — today that is every desktop surface (#790). Declared LAST so it sits ABOVE the glyph, and it // is above the row-body area regardless (that one is pinned z:-1). MouseArea { id: playArea @@ -1041,7 +1052,7 @@ Rectangle { parts.push(span(i)) return parts.join(", ") } - color: root.artistLink && root.item.artistId && artistLinkArea.containsMouse + color: !linkMode && hotSpan === 0 && root.item.artistId ? theme.textPrimary : theme.textMuted font.pixelSize: 12 elide: Text.ElideRight @@ -1063,6 +1074,14 @@ Rectangle { } return -1 } + /// The name under `x` that is a real link (-1 = none): the + /// span in link mode; the drawn text otherwise. The area spans + /// the whole column, and the whitespace past the names belongs + /// to the row body (a double click there plays, #790). + function linkAt(x) { + var i = linkMode ? spanAt(x) : (x >= 0 && x <= contentWidth ? 0 : -1) + return (i >= 0 && spans[i].href !== "") ? i : -1 + } function activate(i) { var s = artistLine.spans[i] if (!s || s.href === "") @@ -1091,12 +1110,9 @@ Rectangle { enabled: !root.selectMode && root.artistLink && (artistLine.linkMode || !!root.item.artistId) hoverEnabled: true - cursorShape: (artistLine.linkMode - ? (artistLine.hotSpan >= 0 && artistLine.spans[artistLine.hotSpan].href !== "") - : enabled) ? Qt.PointingHandCursor : Qt.ArrowCursor + cursorShape: artistLine.hotSpan >= 0 ? Qt.PointingHandCursor : Qt.ArrowCursor onPositionChanged: function (mouse) { - if (artistLine.linkMode) - artistLine.hotSpan = artistLine.spanAt(mouse.x) + artistLine.hotSpan = artistLine.linkAt(mouse.x) } onExited: artistLine.hotSpan = -1 // Entering select mode under the pointer disables the area @@ -1106,14 +1122,15 @@ Rectangle { // both through one handler, so gating only the menu would // leave the LINK navigating to the track's own artist. onClicked: function (mouse) { - if (artistLine.linkMode) { - var i = artistLine.spanAt(mouse.x) - if (i >= 0) - artistLine.activate(i) - return - } - if (root.routeGoToExternally) root.goToRequested("artist") - else QbzArtist.openArtist(root.item.artistId) + var i = artistLine.linkAt(mouse.x) + if (i >= 0) + artistLine.activate(i) + else + root.bodyClicked() + } + onDoubleClicked: function (mouse) { + if (artistLine.linkAt(mouse.x) < 0) + root.bodyDoubleClicked() } } } @@ -1124,7 +1141,7 @@ Rectangle { width: cols.colAlbum anchors.verticalCenter: parent.verticalCenter text: root.item.album || "" - color: (albumArea.containsMouse && albumArea.enabled) ? theme.accent : theme.textMuted + color: albumArea.overName ? theme.accent : theme.textMuted font.pixelSize: 12 elide: Text.ElideRight MouseArea { @@ -1133,10 +1150,25 @@ Rectangle { // Not a link in select mode, for the artist line's reason. enabled: !root.selectMode && !!root.item.albumId && !root.releaseGone hoverEnabled: true - cursorShape: Qt.PointingHandCursor + // Only the drawn name is the link; the rest of the column is + // row body (the artist line's rule, #790). + property bool overName: false + onPositionChanged: function (mouse) { overName = mouse.x <= parent.contentWidth } + onExited: overName = false + onEnabledChanged: if (!enabled) overName = false + cursorShape: overName ? Qt.PointingHandCursor : Qt.ArrowCursor // The names ride along so a release the catalog lost can // still be named on its page (album_qt::publish_unavailable). - onClicked: QbzAlbum.openAlbumFrom(root.item.albumId, root.item.album || "", root.item.artist || "") + onClicked: function (mouse) { + if (mouse.x <= parent.contentWidth) + QbzAlbum.openAlbumFrom(root.item.albumId, root.item.album || "", root.item.artist || "") + else + root.bodyClicked() + } + onDoubleClicked: function (mouse) { + if (mouse.x > parent.contentWidth) + root.bodyDoubleClicked() + } } } // Duration. @@ -1611,6 +1643,32 @@ Rectangle { } }) } + /// A single left click on a part of the row that is not a control. + /// Plays only where `clickPlays` (the kiosk); otherwise nothing. + function bodyClicked() { + if (!root.clickPlays || root.selectMode || root.pulledDead || root.playBlocked) + return + // ONE play per gesture. A double tap is two releases plus the + // doubleClicked handler: three `playRequested`s within ~300 ms, i.e. + // three restarts of the same track (2026-08-29 smoke: three "served + // from OFFLINE cache" in 230 ms). The second release inside the + // double-click window is dropped here; bodyDoubleClicked yields to + // clickPlays rows. + const now = Date.now() + if (now - root._lastPlayRequestMs > 400) { + root._lastPlayRequestMs = now + root.playRequested() + } + } + /// A double click on a part of the row that is not a control: the + /// desktop play gesture (#790). Inert in select mode (the two single + /// clicks already toggled), on a dead or play-blocked row, and on a + /// clickPlays row, whose first release already played. + function bodyDoubleClicked() { + if (root.clickPlays || root.selectMode || root.pulledDead || root.playBlocked) + return + root.playRequested() + } MouseArea { id: trArea anchors.fill: parent @@ -1740,18 +1798,7 @@ Rectangle { if (wasDragging) { mouse.accepted = true } else if (root.clickPlays) { - // ONE play per gesture. A double-click is two releases plus - // the doubleClicked handler: three `playRequested`s within - // ~300 ms, i.e. three restarts of the same track (2026-08-29 - // smoke: three "served from OFFLINE cache" in 230 ms). The - // second release inside the double-click window is dropped - // here; the doubleClicked arm below already yields to - // clickPlays rows. - const now = Date.now() - if (now - root._lastPlayRequestMs > 400) { - root._lastPlayRequestMs = now - root.playRequested() - } + root.bodyClicked() } else { mouse.accepted = false } @@ -1764,19 +1811,10 @@ Rectangle { // ":156 — In select mode a double-click just selects (via // `clicked`); no play." The single-click release above has already // toggled twice by then, which lands back where it started, so the - // double-click must not add a third. - if (root.selectMode) - return - // The album view plays on DOUBLE-click (clickPlays:false there), - // so the single-click block above is not enough on its own. - if (root.pulledDead) - return - // A clickPlays row already played on the first release; a third - // emission here restarted the track a third time. - if (root.clickPlays) - return + // double-click must not add a third. That gate, the dead / blocked + // row and the clickPlays row all live in bodyDoubleClicked. if (mouse.button === Qt.LeftButton) - root.playRequested() + root.bodyDoubleClicked() } } } diff --git a/crates/qbz-qt/qml/views/AlbumView.qml b/crates/qbz-qt/qml/views/AlbumView.qml index 397279ec6..cc5315ea6 100644 --- a/crates/qbz-qt/qml/views/AlbumView.qml +++ b/crates/qbz-qt/qml/views/AlbumView.qml @@ -1893,7 +1893,6 @@ Rectangle { item: trackCell.modelData.track number: trackCell.modelData.trackNumber zebra: true - clickPlays: false artistLink: true qualityStyle: "text" showDownload: true diff --git a/crates/qbz-qt/qml/views/PurchaseAlbumView.qml b/crates/qbz-qt/qml/views/PurchaseAlbumView.qml index 45c5cc7c7..8ea050afd 100644 --- a/crates/qbz-qt/qml/views/PurchaseAlbumView.qml +++ b/crates/qbz-qt/qml/views/PurchaseAlbumView.qml @@ -1198,10 +1198,9 @@ Rectangle { // cache state are different features that // must not overwrite each other (§G.4). draggable: false - // Click-to-play only where the catalog - // says the track is streamable. It defaults - // FALSE on this screen; do not invert it. - clickPlays: trackRow.streamable + // Double-click / play disc play only where + // the catalog says the track is streamable; + // the guard is here, not on the row. onPlayRequested: { if (trackRow.streamable) QbzPlayer.playAlbumFrom(root.doc.id || "", diff --git a/crates/qbz-qt/qml/views/library/FeedListRow.qml b/crates/qbz-qt/qml/views/library/FeedListRow.qml index 370fa9bec..876ae1f37 100644 --- a/crates/qbz-qt/qml/views/library/FeedListRow.qml +++ b/crates/qbz-qt/qml/views/library/FeedListRow.qml @@ -123,19 +123,26 @@ Rectangle { } } - // Row body — click plays/opens by kind. Declared BEFORE the cells so - // the ⋯ button and art-play win their clicks. + readonly property bool isTrack: feedRow.item.kind === "track" + function playTrack() { + if (!feedRow.pulledDead) + feedRow.view.playTrackInContext(feedRow.item.id) + } + + // Row body — click opens by kind. Declared BEFORE the cells so the ⋯ + // button and art-play win their clicks. A TRACK row follows the track-row + // policy (#790, rows/TrackRow.qml `clickPlays`): the art-play disc plays, + // a single click on the body does nothing, a double click plays. MouseArea { id: rowArea anchors.fill: parent hoverEnabled: true - cursorShape: feedRow.pulledDead ? Qt.ArrowCursor : Qt.PointingHandCursor + cursorShape: (feedRow.pulledDead || feedRow.isTrack) ? Qt.ArrowCursor : Qt.PointingHandCursor + onDoubleClicked: if (feedRow.isTrack) feedRow.playTrack() onClicked: { - if (feedRow.item.kind === "track") { - if (!feedRow.pulledDead) - feedRow.view.playTrackInContext(feedRow.item.id) - } - else if (feedRow.item.kind === "album") { + if (feedRow.isTrack) + return + if (feedRow.item.kind === "album") { if (!feedRow.pulledDead) QbzAlbum.openAlbum(feedRow.item.id) } @@ -266,14 +273,13 @@ Rectangle { MouseArea { id: lrTitleArea anchors.fill: parent + // A track's title is not a link: disabled, its clicks + // reach the row body (single = nothing, double = play). + enabled: !feedRow.isTrack hoverEnabled: true cursorShape: feedRow.pulledDead ? Qt.ArrowCursor : Qt.PointingHandCursor onClicked: { - if (feedRow.item.kind === "track") { - if (!feedRow.pulledDead) - feedRow.view.playTrackInContext(feedRow.item.id) - } - else if (feedRow.item.kind === "album") { + if (feedRow.item.kind === "album") { if (!feedRow.pulledDead) QbzAlbum.openAlbum(feedRow.item.id) } @@ -290,7 +296,7 @@ Rectangle { text: feedRow.item.subtitle color: (feedRow.item.artistId !== "" && (feedRow.item.kind === "track" || feedRow.item.kind === "album") - && lrSubArea.containsMouse) ? theme.accent : theme.textMuted + && lrSubArea.hotName) ? theme.accent : theme.textMuted font.pixelSize: 12 verticalAlignment: Text.AlignVCenter elide: Text.ElideRight @@ -298,10 +304,23 @@ Rectangle { id: lrSubArea anchors.fill: parent hoverEnabled: true - cursorShape: (feedRow.item.artistId !== "" - && (feedRow.item.kind === "track" || feedRow.item.kind === "album")) - ? Qt.PointingHandCursor : Qt.ArrowCursor - onClicked: if (feedRow.item.artistId !== "") QbzArtist.openArtist(feedRow.item.artistId) + // On a track row only the drawn name is the link; the + // whitespace past it is row body (double click plays). + readonly property bool isLink: feedRow.item.artistId !== "" + && (feedRow.item.kind === "track" || feedRow.item.kind === "album") + function overName(x) { return !feedRow.isTrack || x <= parent.contentWidth } + property bool hotName: false + onPositionChanged: function (mouse) { hotName = overName(mouse.x) } + onExited: hotName = false + cursorShape: (isLink && hotName) ? Qt.PointingHandCursor : Qt.ArrowCursor + onClicked: function (mouse) { + if (feedRow.item.artistId !== "" && overName(mouse.x)) + QbzArtist.openArtist(feedRow.item.artistId) + } + onDoubleClicked: function (mouse) { + if (feedRow.isTrack && !(isLink && overName(mouse.x))) + feedRow.playTrack() + } } } } diff --git a/crates/qbz-qt/qml/views/local/LocalTrackRow.qml b/crates/qbz-qt/qml/views/local/LocalTrackRow.qml index 47f521dff..79e96ed91 100644 --- a/crates/qbz-qt/qml/views/local/LocalTrackRow.qml +++ b/crates/qbz-qt/qml/views/local/LocalTrackRow.qml @@ -122,6 +122,22 @@ Item { color: (root.zebra && root.number % 2 === 0) ? "#07ffffff" : "transparent" } + // The trailing gutter this wrapper draws OUTSIDE the shared row (source + // glyph + ⋯ cell) is row body too: without it a double click there — or a + // select-mode click — landed on nothing (#790). Covers ONLY the gutter, + // never the shared row, so it cannot receive the clicks the shared row's + // body area propagates. Declared before the ⋯ button so that stays on top. + MouseArea { + x: sharedRow.width + width: root.width - sharedRow.width + height: root.height + onClicked: function (mouse) { + if (root.selectMode) root.toggleSelect(mouse.modifiers) + else sharedRow.bodyClicked() + } + onDoubleClicked: sharedRow.bodyDoubleClicked() + } + TrackRow { kioskHost: root.kioskHost; id: sharedRow // 26px source-glyph gutter + the 46px (32 cell + 14 gap) the shared diff --git a/crates/qbz-qt/qml/views/purchases/PurchaseTrackRow.qml b/crates/qbz-qt/qml/views/purchases/PurchaseTrackRow.qml index 96faa58e1..562b50a0c 100644 --- a/crates/qbz-qt/qml/views/purchases/PurchaseTrackRow.qml +++ b/crates/qbz-qt/qml/views/purchases/PurchaseTrackRow.qml @@ -22,7 +22,8 @@ // the reference's, so the control can be armed later without moving a pixel. // (Flagged to the orchestrator rather than invented.) // -// The row body plays, and only when `streamable` — the purchases-list default +// A DOUBLE click on the row body plays (the track-row policy, #790: a single +// click does nothing), and only when `streamable` — the purchases-list default // is TRUE (§G.2), so an unplayable row is one the API really did mark that way. import QtQuick @@ -93,8 +94,7 @@ Rectangle { anchors.fill: parent enabled: root.streamable hoverEnabled: true - cursorShape: root.streamable ? Qt.PointingHandCursor : Qt.ArrowCursor - onClicked: root.playRequested() + onDoubleClicked: root.playRequested() } Row { diff --git a/scripts/qml-tests/imports/com/blitzfc/qbz/QbzShell.qml b/scripts/qml-tests/imports/com/blitzfc/qbz/QbzShell.qml index c653af935..cd841342e 100644 --- a/scripts/qml-tests/imports/com/blitzfc/qbz/QbzShell.qml +++ b/scripts/qml-tests/imports/com/blitzfc/qbz/QbzShell.qml @@ -10,4 +10,9 @@ QtObject { property string themeJson: ""; property int ambientMode: 0 property string wallpaperWindowsJson: "[]" property int trackRequests: 0 - function trackWindowPosition() { trackRequests++ } } + function trackWindowPosition() { trackRequests++ } + property int dragStarts: 0 + function dragStart(id, title, subtitle, x, y, inline) { dragStarts++ } + function dragStartLocal(id, title, subtitle, x, y, inline) { dragStarts++ } + function dragMove(x, y) {} + function dragEnd() {} } diff --git a/scripts/qml-tests/tst_track_row_click.qml b/scripts/qml-tests/tst_track_row_click.qml new file mode 100644 index 000000000..a16537826 --- /dev/null +++ b/scripts/qml-tests/tst_track_row_click.qml @@ -0,0 +1,328 @@ +// Track-row click policy (issue #790): on every desktop track row a single +// click on the body does NOTHING, a double click anywhere that is not a +// control plays exactly once, and the play disc plays on its first click. +// The REAL row components are clicked through the window, so whichever +// MouseArea really sits on top at a point is the one that answers. Select +// mode, dead rows and the drag gesture must keep their own behaviour, and the +// kiosk (touch, no hover disc) keeps tap-to-play. +import QtQuick +import QtTest +import com.blitzfc.qbz +import "../../crates/qbz-qt/qml/rows" +import "../../crates/qbz-qt/qml/views/local" as Local +import "../../crates/qbz-qt/qml/views/purchases" as Purchases +import "../../crates/qbz-qt/qml/views/library" as Library + +Item { + id: root + width: 1200; height: 900 + + function track(i) { + return { "id": "t" + i, "title": "Track " + i, "artist": "Artist " + i, + "artistId": "a" + i, "album": "Album " + i, "albumId": "al" + i, + "duration": "3:00", "qualityTier": "", "qualityDetail": "" } + } + + property var plays: [] + property var toggles: [] + function played(tag) { root.plays = root.plays.concat([tag]) } + + TrackRow { + id: desktopRow + y: 0 + width: 1000 + height: 50 + item: root.track(1) + number: 1 + artistLink: true + showAlbum: true + onPlayRequested: root.played("desktop") + onToggleSelect: function (mods) { root.toggles = root.toggles.concat([mods]) } + } + + TrackRow { + id: kioskRow + y: 60 + width: 1000 + height: 64 + kioskHost: true + item: root.track(2) + number: 2 + onPlayRequested: root.played("kiosk") + } + + Local.LocalTrackRow { + id: localRow + y: 140 + width: 1000 + item: ({ "id": "11", "title": "Local 1", "artist": "Local Artist", "album": "Local Album", + "albumId": "la1", "duration": "4:00", "source": "local", "qualityTier": "", + "qualityDetail": "" }) + number: 1 + onPlayRequested: root.played("local") + } + + Purchases.PurchaseTrackRow { + id: purchaseRow + y: 210 + width: 1000 + track: ({ "id": "p1", "title": "Bought 1", "artist": "Seller", "album": "Receipt", + "duration": 200, "streamable": true }) + onPlayRequested: root.played("purchase") + } + + QtObject { + id: feedView + property var artMap: ({}) + property bool skelPhase: false + property bool showSourceBadges: false + function playTrackInContext(id) { root.played("feed:" + id) } + function trackAction(item, action) {} + function trackMenuModel(item) { return [] } + } + Library.FeedListRow { + id: feedTrack + y: 290 + width: 1000 + view: feedView + item: ({ "kind": "track", "id": "f1", "title": "Feed track", "subtitle": "Feed artist", + "artistId": "fa1", "source": "qobuz", "artKey": "" }) + } + Library.FeedListRow { + id: feedAlbum + y: 350 + width: 1000 + view: feedView + item: ({ "kind": "album", "id": "fal1", "title": "Feed album", "subtitle": "Feed artist", + "artistId": "fa1", "source": "qobuz", "artKey": "" }) + } + + TestCase { + name: "TrackRowClick" + when: windowShown + + function find(item, pred) { + if (!item) + return null + if (pred(item)) + return item + var kids = item.children || [] + for (var i = 0; i < kids.length; i++) { + var hit = find(kids[i], pred) + if (hit) + return hit + } + return null + } + function shown(item) { + for (var it = item; it; it = it.parent) + if (!it.visible) + return false + return true + } + function textItem(host, text) { + var t = find(host, function (it) { + return it.text === text && it.contentWidth !== undefined && shown(it) + }) + verify(t !== null, "text '" + text + "' is drawn") + return t + } + function at(item, x, y) { return item.mapToItem(root, x, y) } + function click(item, x, y) { + var p = at(item, x, y) + mouseClick(root, p.x, p.y, Qt.LeftButton) + wait(20) + } + function doubleClick(item, x, y) { + var p = at(item, x, y) + mouseDoubleClickSequence(root, p.x, p.y, Qt.LeftButton) + wait(20) + } + // Centre of a drawn text: a point with nothing but the body under it + // when the text is plain (duration, title). + function textCentre(host, text) { + var t = textItem(host, text) + return t.mapToItem(host, t.width / 2, t.height / 2) + } + // The far end of a text's box, past the drawn glyphs: whitespace. + function textTail(host, text) { + var t = textItem(host, text) + verify(t.width - t.contentWidth > 20, "'" + text + "' leaves whitespace") + return t.mapToItem(host, t.width - 6, t.height / 2) + } + function textHead(host, text) { + var t = textItem(host, text) + return t.mapToItem(host, 4, t.height / 2) + } + + function init() { + root.plays = [] + root.toggles = [] + QbzArtist.opened = [] + QbzAlbum.opened = [] + QbzShell.dragStarts = 0 + desktopRow.selectMode = false + desktopRow.playBlocked = false + desktopRow.item = root.track(1) + wait(450) // outside the row's double-click window and play debounce + } + + function test_desktop_single_click_on_body_does_nothing() { + var p = textCentre(desktopRow, "3:00") + click(desktopRow, p.x, p.y) + p = textCentre(desktopRow, "Track 1") + click(desktopRow, p.x, p.y) + compare(root.plays, []) + } + + function test_desktop_double_click_plays_once() { + var p = textCentre(desktopRow, "3:00") + doubleClick(desktopRow, p.x, p.y) + compare(root.plays, ["desktop"]) + } + + function test_desktop_body_cursor_does_not_promise_a_click() { + var body = find(desktopRow, function (it) { return it.z === -1 && it.cursorShape !== undefined }) + verify(body !== null) + compare(body.cursorShape, Qt.ArrowCursor) + } + + function test_play_disc_plays_on_first_click() { + click(desktopRow, 20, desktopRow.height / 2) + compare(root.plays, ["desktop"]) + } + + function test_artist_name_navigates_and_its_whitespace_plays() { + var p = textHead(desktopRow, "Artist 1") + click(desktopRow, p.x, p.y) + compare(QbzArtist.opened, ["a1"]) + compare(root.plays, []) + wait(450) + QbzArtist.opened = [] + p = textTail(desktopRow, "Artist 1") + click(desktopRow, p.x, p.y) + compare(QbzArtist.opened, [], "whitespace beside the name is not a link") + wait(450) + doubleClick(desktopRow, p.x, p.y) + compare(root.plays, ["desktop"]) + compare(QbzArtist.opened, []) + } + + function test_album_name_navigates_and_its_whitespace_plays() { + var p = textHead(desktopRow, "Album 1") + click(desktopRow, p.x, p.y) + compare(QbzAlbum.opened, ["al1"]) + wait(450) + QbzAlbum.opened = [] + p = textTail(desktopRow, "Album 1") + doubleClick(desktopRow, p.x, p.y) + compare(root.plays, ["desktop"]) + compare(QbzAlbum.opened, []) + } + + function test_select_mode_click_toggles_and_double_click_never_plays() { + desktopRow.selectMode = true + wait(20) + var p = textCentre(desktopRow, "3:00") + click(desktopRow, p.x, p.y) + compare(root.toggles.length, 1) + wait(450) + root.toggles = [] + click(desktopRow, p.x, p.y, Qt.ShiftModifier) + wait(450) + doubleClick(desktopRow, p.x, p.y) + compare(root.plays, []) + } + + function test_select_mode_click_keeps_modifiers() { + desktopRow.selectMode = true + wait(20) + var p = at(desktopRow, textCentre(desktopRow, "3:00").x, textCentre(desktopRow, "3:00").y) + mouseClick(root, p.x, p.y, Qt.LeftButton, Qt.ShiftModifier) + wait(20) + compare(root.toggles, [Qt.ShiftModifier]) + } + + function test_dead_and_blocked_rows_do_not_play_on_double_click() { + var dead = root.track(1) + dead.qobuzUnavailable = true + desktopRow.item = dead + wait(20) + var p = textCentre(desktopRow, "3:00") + doubleClick(desktopRow, p.x, p.y) + compare(root.plays, [], "pulled row") + desktopRow.item = root.track(1) + desktopRow.playBlocked = true + wait(450) + doubleClick(desktopRow, p.x, p.y) + compare(root.plays, [], "play-blocked row") + } + + function test_horizontal_drag_starts_a_drag_and_never_plays() { + var p = at(desktopRow, textCentre(desktopRow, "Track 1").x, textCentre(desktopRow, "Track 1").y) + mousePress(root, p.x, p.y, Qt.LeftButton) + for (var dx = 4; dx <= 40; dx += 4) + mouseMove(root, p.x + dx, p.y + 1) + mouseRelease(root, p.x + 40, p.y + 1, Qt.LeftButton) + wait(20) + compare(QbzShell.dragStarts, 1) + compare(root.plays, []) + } + + function test_kiosk_row_keeps_tap_to_play() { + var p = textCentre(kioskRow, "3:00") + click(kioskRow, p.x, p.y) + compare(root.plays, ["kiosk"]) + wait(450) + root.plays = [] + doubleClick(kioskRow, p.x, p.y) + compare(root.plays, ["kiosk"], "a double tap is still one play") + } + + function test_local_row_single_click_does_nothing_and_gutter_double_click_plays() { + var p = textCentre(localRow, "4:00") + click(localRow, p.x, p.y) + compare(root.plays, []) + wait(450) + doubleClick(localRow, p.x, p.y) + compare(root.plays, ["local"]) + wait(450) + root.plays = [] + // The source-glyph gutter the wrapper draws outside the shared row. + doubleClick(localRow, localRow.width - 13, localRow.height / 2) + compare(root.plays, ["local"]) + } + + function test_purchase_row_single_click_does_nothing_double_click_plays() { + var p = textCentre(purchaseRow, "Bought 1") + click(purchaseRow, p.x, p.y) + compare(root.plays, []) + wait(450) + doubleClick(purchaseRow, p.x, p.y) + compare(root.plays, ["purchase"]) + } + + function test_feed_track_row_single_click_does_nothing_double_click_plays() { + var p = textCentre(feedTrack, "Feed track") + click(feedTrack, p.x, p.y) + p = textCentre(feedTrack, "Track") + click(feedTrack, p.x, p.y) + compare(root.plays, []) + wait(450) + doubleClick(feedTrack, p.x, p.y) + compare(root.plays, ["feed:f1"]) + wait(450) + root.plays = [] + p = textCentre(feedTrack, "Feed track") + doubleClick(feedTrack, p.x, p.y) + compare(root.plays, ["feed:f1"]) + } + + function test_feed_album_row_still_opens_on_click() { + var p = textCentre(feedAlbum, "Feed album") + click(feedAlbum, p.x, p.y) + compare(QbzAlbum.opened, ["fal1"]) + compare(root.plays, []) + } + } +} diff --git a/scripts/qt-runtime-gate.sh b/scripts/qt-runtime-gate.sh index 852a22c0c..2ecf99d5c 100644 --- a/scripts/qt-runtime-gate.sh +++ b/scripts/qt-runtime-gate.sh @@ -17,6 +17,7 @@ bash scripts/test-library-folders-qml.sh bash scripts/test-array-model-qml.sh bash scripts/test-keyed-model-qml.sh bash scripts/test-multi-select-qml.sh +bash scripts/test-track-row-click-qml.sh bash scripts/test-settings-fieldset-qml.sh bash scripts/test-wallpaper-field-qml.sh bash scripts/test-card-menu-qml.sh diff --git a/scripts/test-track-row-click-qml.sh b/scripts/test-track-row-click-qml.sh new file mode 100755 index 000000000..b2aec3f79 --- /dev/null +++ b/scripts/test-track-row-click-qml.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Track-row click policy (#790): a single click on a desktop track row's body +# does nothing, a double click on any non-control part plays once, the play disc +# plays at once; select mode, dead rows, drag and kiosk tap-to-play are kept. +# Same run in CI and locally. +set -euo pipefail +cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." +if [[ -n "${QT_ROOT_DIR:-}" ]]; then + qt_track_row_click_bins="$QT_ROOT_DIR/bin" +else + qt_track_row_click_qmake="${QMAKE:-}" + if [[ -z "$qt_track_row_click_qmake" ]]; then + qt_track_row_click_qmake="$(command -v qmake6 || command -v qmake)" + fi + qt_track_row_click_bins="$("$qt_track_row_click_qmake" -query QT_INSTALL_BINS)" +fi +QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software \ + "$qt_track_row_click_bins/qmltestrunner" \ + -input scripts/qml-tests/tst_track_row_click.qml \ + -import scripts/qml-tests/imports