[vlc-devel] [RFC 3/3] qt: playlist: select on drag

Romain Vimont rom1v at videolabs.io
Fri Jul 12 16:20:38 CEST 2019


When we drag an unselected item while others are selected, the drag&drop
moved the selected items, which was unexpected.

Instead, select the item dragged.

Fixes #22491
---
 modules/gui/qt/qml/playlist/PLItem.qml           | 2 ++
 modules/gui/qt/qml/playlist/PlaylistListView.qml | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/modules/gui/qt/qml/playlist/PLItem.qml b/modules/gui/qt/qml/playlist/PLItem.qml
index 8d18128f0a..c8484fe2c4 100644
--- a/modules/gui/qt/qml/playlist/PLItem.qml
+++ b/modules/gui/qt/qml/playlist/PLItem.qml
@@ -32,6 +32,7 @@ Rectangle {
 
     signal itemClicked(int keys, int modifier)
     signal itemDoubleClicked(int keys, int modifier)
+    signal dragStarting()
     property alias hovered: mouse.containsMouse
 
     property var dragitem: null
@@ -75,6 +76,7 @@ Rectangle {
             target: mouse.drag
             onActiveChanged: {
                 if (target.active) {
+                    root.dragStarting()
                     dragItem.count = plmodel.getSelection().length
                     dragItem.visible = true
                 } else {
diff --git a/modules/gui/qt/qml/playlist/PlaylistListView.qml b/modules/gui/qt/qml/playlist/PlaylistListView.qml
index f55fec5857..c60220aada 100644
--- a/modules/gui/qt/qml/playlist/PlaylistListView.qml
+++ b/modules/gui/qt/qml/playlist/PlaylistListView.qml
@@ -106,6 +106,13 @@ Utils.NavigableFocusScope {
             onItemDoubleClicked: mainPlaylistController.goTo(index, true)
             color: VLCStyle.colors.getBgColor(model.selected, plitem.hovered, plitem.activeFocus)
 
+            onDragStarting: {
+                if (!root.plmodel.isSelected(index)) {
+                    /* the dragged item is not in the selection, replace the selection */
+                    root.plmodel.setSelection([index])
+                }
+            }
+
             onDropedMovedAt: {
                 if (drop.hasUrls) {
                     mainPlaylistController.insert(target, drop.urls)
-- 
2.20.1



More information about the vlc-devel mailing list