diff options
author | Jan Holthuis <jholthuis@mixxx.org> | 2021-12-27 00:11:11 +0100 |
---|---|---|
committer | Jan Holthuis <jholthuis@mixxx.org> | 2022-01-11 19:53:42 +0100 |
commit | 0bc7711524cd1e3b5b5d967a439ab95b3ace4f75 (patch) | |
tree | 5ed211cae6e9e61bad47e50cb56f1094c5e3b94a | |
parent | 77c28799acd8f5c9cf82319c7f0f09a25b30982c (diff) |
LibraryControl: Move FocusWidgetControl into separate component
-rw-r--r-- | res/qml/FocusedWidgetControl.qml | 14 | ||||
-rw-r--r-- | res/qml/Library.qml | 2 | ||||
-rw-r--r-- | res/qml/LibraryControl.qml | 39 |
3 files changed, 36 insertions, 19 deletions
diff --git a/res/qml/FocusedWidgetControl.qml b/res/qml/FocusedWidgetControl.qml new file mode 100644 index 0000000000..1821f62a90 --- /dev/null +++ b/res/qml/FocusedWidgetControl.qml @@ -0,0 +1,14 @@ +import Mixxx 0.1 as Mixxx + +Mixxx.ControlProxy { + + enum WidgetKind { + None, + Searchbar, + Sidebar, + LibraryView + } + + group: "[Library]" + key: "focused_widget" +} diff --git a/res/qml/Library.qml b/res/qml/Library.qml index 94cebe4efb..7b88561f25 100644 --- a/res/qml/Library.qml +++ b/res/qml/Library.qml @@ -10,6 +10,8 @@ Item { anchors.fill: parent LibraryControl { + id: libraryControl + onMoveSelection: listView.moveSelection(offset) onLoadSelectedTrack: listView.loadSelectedTrack(group, play) onLoadSelectedTrackIntoNextAvailableDeck: listView.loadSelectedTrackIntoNextAvailableDeck(play) diff --git a/res/qml/LibraryControl.qml b/res/qml/LibraryControl.qml index 8f22f1001c..3ec61ed2d7 100644 --- a/res/qml/LibraryControl.qml +++ b/res/qml/LibraryControl.qml @@ -4,25 +4,23 @@ import QtQuick 2.12 Item { id: root - property bool focused: focusedWidgetControl.value == 3 + property alias focusWidget: focusedWidgetControl.value signal moveSelection(int offset) signal loadSelectedTrack(string group, bool play) signal loadSelectedTrackIntoNextAvailableDeck(bool play) - Mixxx.ControlProxy { + FocusedWidgetControl { id: focusedWidgetControl - group: "[Library]" - key: "focused_widget" - Component.onCompleted: value = 3 + Component.onCompleted: this.value = FocusedWidgetControl.WidgetKind.LibraryView } Mixxx.ControlProxy { group: "[Library]" key: "GoToItem" onValueChanged: { - if (value != 0 && root.focused) + if (value != 0 && root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView) root.loadSelectedTrackIntoNextAvailableDeck(false); } @@ -32,7 +30,7 @@ Item { group: "[Playlist]" key: "LoadSelectedIntoFirstStopped" onValueChanged: { - if (value != 0) + if (value != 0 && root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView) root.loadSelectedTrackIntoNextAvailableDeck(false); } @@ -42,9 +40,10 @@ Item { group: "[Playlist]" key: "SelectTrackKnob" onValueChanged: { - if (value != 0) + if (value != 0) { + root.focusWidget = FocusedWidgetControl.WidgetKind.LibraryView; root.moveSelection(value); - + } } } @@ -52,9 +51,10 @@ Item { group: "[Playlist]" key: "SelectPrevTrack" onValueChanged: { - if (value != 0) + if (value != 0) { + root.focusWidget = FocusedWidgetControl.WidgetKind.LibraryView; root.moveSelection(-1); - + } } } @@ -62,9 +62,10 @@ Item { group: "[Playlist]" key: "SelectNextTrack" onValueChanged: { - if (value != 0) + if (value != 0) { + root.focusWidget = FocusedWidgetControl.WidgetKind.LibraryView; root.moveSelection(1); - + } } } @@ -72,7 +73,7 @@ Item { group: "[Library]" key: "MoveVertical" onValueChanged: { - if (root.focused && value != 0) + if (value != 0 && root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView) root.moveSelection(value); } @@ -82,7 +83,7 @@ Item { group: "[Library]" key: "MoveUp" onValueChanged: { - if (root.focused && value != 0) + if (value != 0 && root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView) root.moveSelection(-1); } @@ -92,7 +93,7 @@ Item { group: "[Library]" key: "MoveDown" onValueChanged: { - if (root.focused && value != 0) + if (value != 0 && root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView) root.moveSelection(1); } @@ -110,7 +111,7 @@ Item { delegate: LibraryControlLoadSelectedTrackHandler { group: "[Channel" + (index + 1) + "]" - enabled: root.focused + enabled: root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView onLoadTrackRequested: root.loadSelectedTrack(group, play) } @@ -128,7 +129,7 @@ Item { delegate: LibraryControlLoadSelectedTrackHandler { group: "[PreviewDeck" + (index + 1) + "]" - enabled: root.focused + enabled: root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView onLoadTrackRequested: root.loadSelectedTrack(group, play) } @@ -146,7 +147,7 @@ Item { delegate: LibraryControlLoadSelectedTrackHandler { group: "[Sampler" + (index + 1) + "]" - enabled: root.focused + enabled: root.focusWidget == FocusedWidgetControl.WidgetKind.LibraryView onLoadTrackRequested: root.loadSelectedTrack(group, play) } |