[vlc-devel] [PATCH 02/15] qml: fix playlist drop indicator

Fatih Uzunoglu fuzun54 at outlook.com
Thu Feb 11 21:23:30 UTC 2021


This patch fixes the race condition in the playlist regarding symmetric drop indication. The race condition was causing problems when Qt 5.15 was being used.
---
 modules/gui/qt/playlist/qml/PlaylistDelegate.qml | 14 +++++++-------
 modules/gui/qt/playlist/qml/PlaylistListView.qml | 12 +++++++-----
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/modules/gui/qt/playlist/qml/PlaylistDelegate.qml b/modules/gui/qt/playlist/qml/PlaylistDelegate.qml
index 3cf7d98adb..e05f482f5b 100644
--- a/modules/gui/qt/playlist/qml/PlaylistDelegate.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistDelegate.qml
@@ -86,13 +86,11 @@ Rectangle {
 
         onSetItemDropIndicatorVisible: {
             if (index === model.index) {
-                // show top drop indicator bar
-                topDropIndicator.visible = visible
+                topDropIndicator.visible = Qt.binding(function() { return visible || higherDropArea.containsDragItem; })
             }
         }
     }
 
-    // top drop indicator bar
     Rectangle {
         id: topDropIndicator
 
@@ -102,7 +100,7 @@ Rectangle {
         height: VLCStyle.dp(1)
         anchors.top: parent.top
 
-        visible: false
+        visible: higherDropArea.containsDragItem
         color: colors.accent
     }
 
@@ -290,14 +288,16 @@ Rectangle {
                 Layout.fillWidth: true
                 Layout.fillHeight: true
 
+                property bool containsDragItem: false
+
                 onEntered: {
                     if (!isDropAcceptable(drag, index))
                         return
 
-                    topDropIndicator.visible = true
+                    containsDragItem = true
                 }
                 onExited: {
-                    topDropIndicator.visible = false
+                    containsDragItem = false
                 }
                 onDropped: {
                     if (!isDropAcceptable(drop, index))
@@ -305,7 +305,7 @@ Rectangle {
 
                     root.acceptDrop(index, drop)
 
-                    topDropIndicator.visible = false
+                    containsDragItem = false
                 }
             }
 
diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 056b33d492..54c0d7dded 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -360,7 +360,7 @@ Widgets.NavigableFocusScope {
                     property alias firstItemIndicatorVisible: firstItemIndicator.visible
 
                     function setDropIndicatorVisible(visible) {
-                        dropIndicator.visible = visible
+                        dropIndicator.visible = Qt.binding(function() { return (visible || dropArea.containsDragItem); })
                     }
 
                     MouseArea {
@@ -388,7 +388,7 @@ Widgets.NavigableFocusScope {
                         height: VLCStyle.dp(1)
                         anchors.top: parent.top
 
-                        visible: false
+                        visible: dropArea.containsDragItem
                         color: colors.accent
                     }
 
@@ -424,6 +424,8 @@ Widgets.NavigableFocusScope {
 
                         anchors.fill: parent
 
+                        property bool containsDragItem: false
+
                         onEntered: {
                             if(!root.isDropAcceptable(drag, root.model.count))
                                 return
@@ -431,13 +433,13 @@ Widgets.NavigableFocusScope {
                             if (root.model.count === 0)
                                 firstItemIndicator.visible = true
                             else
-                                dropIndicator.visible = true
+                                containsDragItem = true
                         }
                         onExited: {
                             if (root.model.count === 0)
                                 firstItemIndicator.visible = false
                             else
-                                dropIndicator.visible = false
+                                containsDragItem = false
                         }
                         onDropped: {
                             if(!root.isDropAcceptable(drop, root.model.count))
@@ -448,7 +450,7 @@ Widgets.NavigableFocusScope {
                             if (root.model.count === 0)
                                 firstItemIndicator.visible = false
                             else
-                                dropIndicator.visible = false
+                                containsDragItem = false
                         }
                     }
                 }
-- 
2.27.0



More information about the vlc-devel mailing list