[vlc-commits] [Git][videolan/vlc][master] qml: set attached delayRemove on view delegates when drag is active

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Sat Sep 25 18:02:32 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
861fb677 by Fatih Uzunoglu at 2021-09-25T17:40:00+00:00
qml: set attached delayRemove on view delegates when drag is active

QtQuick views destroy the delegate when it goes out of
boundaries set by cacheBuffer property. Since drag
items are "connected" to the delegate, the drag event
can not be handled properly.

Setting attached ListView.delayRemove property of the
delegate when drag is active prevents it getting
destroyed.

- - - - -


5 changed files:

- modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml
- modules/gui/qt/playlist/qml/PlaylistDelegate.qml
- modules/gui/qt/playlist/qml/PlaylistListView.qml
- modules/gui/qt/widgets/qml/TableViewDelegate.qml


Changes:

=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
=====================================
@@ -133,6 +133,11 @@ MouseArea {
                 target: content
                 anchors { horizontalCenter: undefined; verticalCenter: undefined }
             }
+
+            PropertyChanges {
+                target: dragArea
+                ListView.delayRemove: true
+            }
         }
 
         onXChanged: {


=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorButtonList.qml
=====================================
@@ -121,6 +121,8 @@ GridView{
             buttonDragItem.Drag.source = dragArea
             held = true
             root._held = true
+
+            dragArea.ListView.delayRemove = true
         }
 
         onReleased: {
@@ -128,6 +130,8 @@ GridView{
             buttonDragItem.visible = false
             held = false
             root._held = false
+
+            dragArea.ListView.delayRemove = false
         }
 
         onPositionChanged: {


=====================================
modules/gui/qt/playlist/qml/PlaylistDelegate.qml
=====================================
@@ -45,13 +45,13 @@ Control {
     // Events
 
     onHoveredChanged: {
-        if(hovered)
-            showTooltip(false)
+        if (hovered)
+            adjustTooltip()
     }
 
-    onSelectedChanged: {
-        if(selected)
-            showTooltip(true)
+    onVisualFocusChanged: {
+        if (visualFocus)
+            adjustTooltip()
     }
 
     // Connections
@@ -68,16 +68,17 @@ Control {
 
     // Functions
 
-    function showTooltip(selectAction) {
+    function adjustTooltip() {
         plInfoTooltip.close()
         plInfoTooltip.text = Qt.binding(function() { return (textInfo.text + '\n' + textArtist.text); })
         plInfoTooltip.parent = textInfoColumn
-        if (selectionLength > 1 && selectAction)
-            plInfoTooltip.timeout = 2000
-        else
+        if (hovered)
             plInfoTooltip.timeout = 0
-        plInfoTooltip.visible = Qt.binding(function() { return ( (selectAction ? selected : hovered) && !overlayMenu.shown && mainInterface.playlistVisible &&
-                                                                (textInfo.implicitWidth > textInfo.width || textArtist.implicitWidth > textArtist.width)); })
+        else
+            plInfoTooltip.timeout = 2000
+        plInfoTooltip.visible = Qt.binding(function() { return ( (visualFocus || hovered) && !mouseArea.drag.active &&
+                                                                !overlayMenu.shown && mainInterface.playlistVisible &&
+                                                                (textInfo.implicitWidth > textInfo.width || textArtist.implicitWidth > textArtist.width) ) })
     }
 
     // Childs
@@ -182,6 +183,8 @@ Control {
                 else {
                     dragItem.Drag.drop()
                 }
+
+                delegate.ListView.delayRemove = drag.active
             }
 
             onPositionChanged: {


=====================================
modules/gui/qt/playlist/qml/PlaylistListView.qml
=====================================
@@ -176,7 +176,6 @@ Control {
             }
         }
 
-        // FIXME: Drag animation for listView sometimes messes up dragging (dragged item sticking to the cursor).
         SmoothedAnimation {
             id: upAnimation
             target: listView.listView


=====================================
modules/gui/qt/widgets/qml/TableViewDelegate.qml
=====================================
@@ -139,6 +139,8 @@ Control {
             }
 
             root.dragItem.Drag.active = drag.active;
+
+            root.ListView.delayRemove = drag.active;
         }
 
         // Childs



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/861fb677f47169c42ea08c048a864191a84b44a4

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




More information about the vlc-commits mailing list