diff options
author | Jan Holthuis <jholthuis@mixxx.org> | 2021-12-13 14:19:27 +0100 |
---|---|---|
committer | Jan Holthuis <jholthuis@mixxx.org> | 2022-01-11 19:53:42 +0100 |
commit | 600bc478178f1aa747a5baf062f1d7b84245aa0f (patch) | |
tree | d2c765dac2f25ae7cdc894abbf81bc679fcc5ad9 | |
parent | 339da28e882c0aa321befa1ce500a6046a711c91 (diff) |
QML: Add support for changing selection using library COs
-rw-r--r-- | res/qml/Library.qml | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/res/qml/Library.qml b/res/qml/Library.qml index 706d4e263e..8311c2ee47 100644 --- a/res/qml/Library.qml +++ b/res/qml/Library.qml @@ -8,9 +8,88 @@ Item { color: Theme.deckBackgroundColor anchors.fill: parent + Mixxx.ControlProxy { + id: focusedWidgetControl + + group: "[Library]" + key: "focused_widget" + Component.onCompleted: value = 3 + } + + Mixxx.ControlProxy { + group: "[Playlist]" + key: "SelectTrackKnob" + onValueChanged: { + listView.moveSelection(value); + } + } + + Mixxx.ControlProxy { + group: "[Playlist]" + key: "SelectPrevTrack" + onValueChanged: { + if (value != 0) + listView.moveSelection(-1); + + } + } + + Mixxx.ControlProxy { + group: "[Playlist]" + key: "SelectNextTrack" + onValueChanged: { + if (value != 0) + listView.moveSelection(1); + + } + } + + Mixxx.ControlProxy { + group: "[Library]" + key: "MoveVertical" + onValueChanged: { + if (focusedWidgetControl.value == 3) + listView.moveSelection(value); + + } + } + + Mixxx.ControlProxy { + group: "[Library]" + key: "MoveUp" + onValueChanged: { + if (value != 0 && focusedWidgetControl.value == 3) + listView.moveSelection(-1); + + } + } + + Mixxx.ControlProxy { + group: "[Library]" + key: "MoveDown" + onValueChanged: { + if (value != 0 && focusedWidgetControl.value == 3) + listView.moveSelection(1); + + } + } + ListView { id: listView + function moveSelection(value) { + if (value == 0) + return ; + + const rowCount = model.rowCount(); + if (rowCount == 0) + return ; + + let newIndex = currentIndex = (currentIndex + value) % rowCount; + while (newIndex < 0)newIndex += rowCount + currentIndex = newIndex; + } + anchors.fill: parent anchors.margins: 10 clip: true |