vlc | branch: master | Romain Vimont <[email protected]> | Tue Jul  9 18:30:32 
2019 +0200| [7feb15682ff074e0a3437c034d06ff59749f6222] | committer: 
Jean-Baptiste Kempf

qt: playlist: select on drag

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

Signed-off-by: Jean-Baptiste Kempf <[email protected]>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7feb15682ff074e0a3437c034d06ff59749f6222
---

 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 fa75adbea2..3a15ec2668 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
@@ -74,6 +75,7 @@ Rectangle {
         property bool hold: false
         onPositionChanged: {
             if (hold && !dragItem.visible) {
+                root.dragStarting()
                 dragItem.count = plmodel.getSelection().length
                 dragItem.visible = true
             }
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)

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to