[vlc-commits] qml: fix playlist drop indicator
Fatih Uzunoglu
git at videolan.org
Wed Feb 17 09:31:44 UTC 2021
vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Feb 12 00:23:30 2021 +0300| [655601fa40a164510ac99da87481271e3f436d4c] | committer: Pierre Lamot
qml: fix playlist drop indicator
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.
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=655601fa40a164510ac99da87481271e3f436d4c
---
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
}
}
}
More information about the vlc-commits
mailing list