feat(qt): Shift ranges in the offline manager
The manager's checkboxes toggled one track at a time. They now follow the shared rule over the track rows as drawn, album headers excluded, and a Shift or Ctrl click on a track row selects instead of starting playback; a plain click still plays. The Slint had this surface on its range table (SURFACE_OFFLINE). cc
This commit is contained in:
1 file changed
+27
-10
@@ -107,18 +107,22 @@ Rectangle {
|
|||||||
var p = root.livePatch[row.trackId]
|
var p = root.livePatch[row.trackId]
|
||||||
return (row.kind === "track" && p !== undefined) ? p.status : row.status
|
return (row.kind === "track" && p !== undefined) ? p.status : row.status
|
||||||
}
|
}
|
||||||
function toggleSelect(trackId) {
|
/// The rule every multi-select list shares (controls/SelectionModel.qml):
|
||||||
var s = Object.assign({}, root.selected)
|
/// a plain or Ctrl click toggles one track, Shift adds the range from the
|
||||||
if (s[trackId] === true)
|
/// last one — over the TRACK rows as drawn, never the album headers
|
||||||
delete s[trackId]
|
/// between them. The Slint had this surface on its Shift-range table
|
||||||
else
|
/// (selection.rs SURFACE_OFFLINE); the port left it toggle-only.
|
||||||
s[trackId] = true
|
SelectionModel { id: offlineSel; idKey: "trackId" }
|
||||||
root.selected = s
|
function toggleSelect(trackId, mods) {
|
||||||
|
var tracks = root.rows.filter(function (row) { return row.kind === "track" })
|
||||||
|
root.selected = offlineSel.next(root.selected, trackId, tracks,
|
||||||
|
mods === undefined ? Qt.NoModifier : mods)
|
||||||
}
|
}
|
||||||
|
|
||||||
function bulkAction(id) {
|
function bulkAction(id) {
|
||||||
if (id === "clear") {
|
if (id === "clear") {
|
||||||
root.selected = ({})
|
root.selected = ({})
|
||||||
|
offlineSel.anchorId = ""
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (id === "select-all") {
|
if (id === "select-all") {
|
||||||
@@ -507,8 +511,19 @@ Rectangle {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: rowItem.isAlbum
|
cursorShape: rowItem.isAlbum
|
||||||
? Qt.ArrowCursor : Qt.PointingHandCursor
|
? Qt.ArrowCursor : Qt.PointingHandCursor
|
||||||
onClicked: if (!rowItem.isAlbum)
|
// A plain click plays; a Shift or Ctrl click is
|
||||||
QbzOffline.playTrack(rowItem.modelData.trackId)
|
// a selection gesture, as in any file list, so
|
||||||
|
// it ticks (or ranges) instead of starting
|
||||||
|
// playback.
|
||||||
|
onClicked: function (mouse) {
|
||||||
|
if (rowItem.isAlbum)
|
||||||
|
return
|
||||||
|
if ((mouse.modifiers & (Qt.ShiftModifier | Qt.ControlModifier
|
||||||
|
| Qt.MetaModifier)) !== 0)
|
||||||
|
root.toggleSelect(rowItem.modelData.trackId, mouse.modifiers)
|
||||||
|
else
|
||||||
|
QbzOffline.playTrack(rowItem.modelData.trackId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
@@ -526,7 +541,9 @@ Rectangle {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
visible: !rowItem.isAlbum
|
visible: !rowItem.isAlbum
|
||||||
checked: rowItem.checked
|
checked: rowItem.checked
|
||||||
onToggled: root.toggleSelect(rowItem.modelData.trackId)
|
onToggled: function (mods) {
|
||||||
|
root.toggleSelect(rowItem.modelData.trackId, mods)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user