vlc | branch: master | Romain Vimont <[email protected]> | Fri Jul 12 16:20:38 
2019 +0200| [6dfa49b0528996f0a0e4c3e6a0064b9853d0e9b6] | 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=6dfa49b0528996f0a0e4c3e6a0064b9853d0e9b6
---

 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)

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

Reply via email to