[vlc-commits] [Git][videolan/vlc][master] qml: hide toolbar editor delegate until drop is completed

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Nov 21 14:37:00 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
2d5967f5 by Fatih Uzunoglu at 2024-11-21T13:59:54+00:00
qml: hide toolbar editor delegate until drop is completed

Currently, when `drop()` is called, the delegate is shown
in its original position with internal drag. This causes
the delegate to be shown for a momentary period of time
until it is removed from the view.

In order to prevent flickering, hide the delegate before
calling `drop()` and if the delegate is dropped in the same
view (intra-view move) then show it since the delegate
should not remain hidden in its new position.

- - - - -


3 changed files:

- modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
- modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml


Changes:

=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
=====================================
@@ -75,7 +75,10 @@ T.Control {
 
             } else {
                 dragAutoScrollHandler.dragItem = null
-                drag.target.Drag.drop()
+                control.visible = false
+                const action = drag.target.Drag.drop()
+                if (action === Qt.IgnoreAction)
+                    control.visible = true
                 removeInfoRectVisible = false
                 root.dragStopped(controlId)
             }
@@ -103,11 +106,11 @@ T.Control {
         onDropped: (drop) => {
             let destIndex = parent.DelegateModel.itemsIndex
 
-            if((drag.source.dndView === dndView)
-                    && (drag.source.DelegateModel.itemsIndex < destIndex))
+            if((drop.source.dndView === dndView)
+                    && (drop.source.DelegateModel.itemsIndex < destIndex))
                 --destIndex
 
-            dropEvent(drag, destIndex)
+            dropEvent(drop, destIndex)
         }
     }
 


=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
=====================================
@@ -81,13 +81,17 @@ ListView {
             // moving from same section
             playerBtnDND.model.move(drag.source.DelegateModel.itemsIndex,
                                     destIndex)
+            drag.source.visible = true
+            drag.accept(Qt.MoveAction)
         } else if (drag.source.objectName === "buttonsList") {
             // moving from buttonsList
             playerBtnDND.model.insert(destIndex, {"id" : drag.source.mIndex})
+            drag.accept(Qt.CopyAction)
         } else {
             // moving between sections or views
             playerBtnDND.model.insert(destIndex, {"id" : drag.source.controlId})
             drag.source.dndView.model.remove(drag.source.DelegateModel.itemsIndex)
+            drag.accept(Qt.MoveAction)
         }
     }
 
@@ -155,10 +159,10 @@ ListView {
             onDropped: (drop) => {
                 let destIndex = playerBtnDND.count
 
-                if (drag.source.dndView === playerBtnDND)
+                if (drop.source.dndView === playerBtnDND)
                     --destIndex
 
-                dropEvent(drag, destIndex)
+                dropEvent(drop, destIndex)
             }
         }
     }


=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml
=====================================
@@ -79,7 +79,8 @@ GridView {
             if (isFromList())
                 return
 
-            drag.source.dndView.model.remove(drag.source.DelegateModel.itemsIndex)
+            drop.source.dndView.model.remove(drop.source.DelegateModel.itemsIndex)
+            drop.accept(Qt.MoveAction)
         }
     }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2d5967f5ef77f578bf8c2c1c04420209188098c0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2d5967f5ef77f578bf8c2c1c04420209188098c0
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list