vlc | branch: master | Fatih Uzunoglu <[email protected]> | Fri Jan 8 00:36:46 2021 +0300| [0db969d41d172af5d64e40238ceb105b8a2d8742] | committer: Pierre Lamot
qml: fix symmetric drop indication in playlist Signed-off-by: Pierre Lamot <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0db969d41d172af5d64e40238ceb105b8a2d8742 --- modules/gui/qt/playlist/qml/PlaylistDelegate.qml | 52 ++++++++++++------------ modules/gui/qt/playlist/qml/PlaylistListView.qml | 14 +------ 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/modules/gui/qt/playlist/qml/PlaylistDelegate.qml b/modules/gui/qt/playlist/qml/PlaylistDelegate.qml index eb2017d74f..5c8e35ab83 100644 --- a/modules/gui/qt/playlist/qml/PlaylistDelegate.qml +++ b/modules/gui/qt/playlist/qml/PlaylistDelegate.qml @@ -95,21 +95,12 @@ Rectangle { } Connections { - target: root + target: listView onSetItemDropIndicatorVisible: { - if (index === model.index) - { - if (top) - { - // show top drop indicator bar - topDropIndicator.visible = isVisible - } - else - { - // show bottom drop indicator bar - bottomDropIndicator.visible = isVisible - } + if (index === model.index) { + // show top drop indicator bar + topDropIndicator.visible = visible } } } @@ -121,7 +112,6 @@ Rectangle { width: parent.width height: 1 anchors.top: parent.top - antialiasing: true visible: false color: colors.accent } @@ -285,18 +275,21 @@ Rectangle { Layout.fillHeight: true onEntered: { - if (isDropAcceptable(drag, model.index)) - root.setItemDropIndicatorVisible(model.index, true, true) + if (!isDropAcceptable(drag, index)) + return + + topDropIndicator.visible = true } onExited: { - root.setItemDropIndicatorVisible(model.index, false, true) + topDropIndicator.visible = false } onDropped: { if (!isDropAcceptable(drop, model.index)) return - delegate.dropedMovedAt(model.index, drop) - root.setItemDropIndicatorVisible(model.index, false, true) + root.acceptDrop(index, drop) + + topDropIndicator.visible = false } } @@ -305,24 +298,29 @@ Rectangle { Layout.fillWidth: true Layout.fillHeight: true - readonly property bool _isLastItem: model.index === delegate._model.count - 1 - readonly property int _targetIndex: _isLastItem ? model.index + 1 : model.index + function handleDropIndicators(visible) { + if ( index === _model.count - 1 ) + listView.footerItem.setDropIndicatorVisible(visible) + else + listView.setItemDropIndicatorVisible(index + 1, visible) + } onEntered: { - if (!isDropAcceptable(drag, _targetIndex)) + if (!isDropAcceptable(drag, index + 1)) return - root.setItemDropIndicatorVisible(_targetIndex, true, !_isLastItem) + handleDropIndicators(true) } onExited: { - root.setItemDropIndicatorVisible(_targetIndex, false, !_isLastItem) + handleDropIndicators(false) } onDropped: { - if(!isDropAcceptable(drop, _targetIndex)) + if(!isDropAcceptable(drop, index + 1)) return - delegate.dropedMovedAt(_targetIndex, drop) - root.setItemDropIndicatorVisible(_targetIndex, false, !_isLastItem) + root.acceptDrop(index + 1, drop) + + handleDropIndicators(false) } } } diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml index eb81ee3f0b..db08572d54 100644 --- a/modules/gui/qt/playlist/qml/PlaylistListView.qml +++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml @@ -37,8 +37,6 @@ Widgets.NavigableFocusScope { property VLCColors colors: VLCStyle.colors - signal setItemDropIndicatorVisible(int index, bool isVisible, bool top) - enum Mode { Normal, Select, // Keyboard item selection mode, activated through PlaylistOverlayMenu @@ -274,6 +272,8 @@ Widgets.NavigableFocusScope { property int shiftIndex: -1 property int mode: PlaylistListView.Mode.Normal + signal setItemDropIndicatorVisible(int index, bool visible) + Connections { target: root.model onRowsInserted: { @@ -457,16 +457,6 @@ Widgets.NavigableFocusScope { } } - Connections { - target: root - - onSetItemDropIndicatorVisible: { - if ((index === model.index && !top) || (index === model.index + 1 && top)) { - bottomSeparator.visible = !isVisible - } - } - } - Rectangle { id: bottomSeparator anchors.top: delegate.bottom _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
