[vlc-commits] qml: enable moving controls between sections of customization

Fatih Uzunoglu git at videolan.org
Mon Nov 16 10:04:05 CET 2020


vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Tue Aug 11 20:47:30 2020 +0300| [0e1dfc0997c40dea41a8db010072e8101e190076] | committer: Pierre Lamot

qml: enable moving controls between sections of customization

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

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

 .../gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml  | 16 ++++++++++++----
 modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml  | 19 ++++++++++++-------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml b/modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
index 2503c127ba..b52a09b94e 100644
--- a/modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
+++ b/modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
@@ -27,6 +27,7 @@ import "qrc:///style/"
 MouseArea {
     id: dragArea
 
+    property int controlId: model.id
     property bool held: false
     property bool dropVisible: false
     property var dndView: null
@@ -111,10 +112,8 @@ MouseArea {
         }
 
         onDropped: {
-            if (drag.source.objectName == "buttonsList")
-                dndView.model.insert(parent.DelegateModel.itemsIndex,
-                                            {"id" : drag.source.mIndex})
-            else{
+            if (drag.source.dndView === playerBtnDND) {
+                // moving from same section
                 var srcIndex = drag.source.DelegateModel.itemsIndex
                 var destIndex = parent.DelegateModel.itemsIndex
 
@@ -122,6 +121,15 @@ MouseArea {
                     destIndex -= 1
                 playerBtnDND.model.move(srcIndex,destIndex)
             }
+            else if (drag.source.objectName == "buttonsList"){
+                // moving from buttonsList
+                dndView.model.insert(parent.DelegateModel.itemsIndex, {"id" : drag.source.mIndex})
+            }
+            else {
+                // moving between sections
+                dndView.model.insert(parent.DelegateModel.itemsIndex, {"id" : drag.source.controlId})
+            }
+
             dropVisible = false
         }
     }
diff --git a/modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml b/modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
index 0b4b4cf54f..4a2b9638eb 100644
--- a/modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
+++ b/modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
@@ -69,14 +69,19 @@ ListView {
             }
 
             onDropped: {
-                if (drag.source.objectName == "buttonsList"){
-                    playerBtnDND.model.insert(playerBtnDND.count,
-                                             {"id" : drag.source.mIndex})
+                if (drag.source.dndView === playerBtnDND) {
+                    // moving from same section
+                    playerBtnDND.model.move(drag.source.DelegateModel.itemsIndex, playerBtnDND.count - 1)
                 }
-                else
-                    playerBtnDND.model.move(
-                                drag.source.DelegateModel.itemsIndex,
-                                playerBtnDND.count-1)
+                else if (drag.source.objectName == "buttonsList"){
+                    // moving from buttonsList
+                    playerBtnDND.model.insert(playerBtnDND.count, {"id" : drag.source.mIndex})
+                }
+                else {
+                    // moving between sections
+                    playerBtnDND.model.insert(playerBtnDND.count, {"id" : drag.source.controlId})
+                }
+
                 dropVisible = false
             }
         }



More information about the vlc-commits mailing list