[vlc-devel] [RFC 8/8] qt: playlist: select on drag
Romain Vimont
rom1v at videolabs.io
Tue Jul 9 18:30:32 CEST 2019
When we drag an unselected item while others are selected, the drag&drop
moved the selected items, which was unexpected.
Instead, select the item dragged.
Fixes #22491
---
modules/gui/qt/qml/playlist/PLItem.qml | 2 ++
modules/gui/qt/qml/playlist/PlaylistListView.qml | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/modules/gui/qt/qml/playlist/PLItem.qml b/modules/gui/qt/qml/playlist/PLItem.qml
index fa75adbea2..3a15ec2668 100644
--- a/modules/gui/qt/qml/playlist/PLItem.qml
+++ b/modules/gui/qt/qml/playlist/PLItem.qml
@@ -32,6 +32,7 @@ Rectangle {
signal itemClicked(int keys, int modifier)
signal itemDoubleClicked(int keys, int modifier)
+ signal dragStarting()
property alias hovered: mouse.containsMouse
property var dragitem: null
@@ -74,6 +75,7 @@ Rectangle {
property bool hold: false
onPositionChanged: {
if (hold && !dragItem.visible) {
+ root.dragStarting()
dragItem.count = plmodel.getSelection().length
dragItem.visible = true
}
diff --git a/modules/gui/qt/qml/playlist/PlaylistListView.qml b/modules/gui/qt/qml/playlist/PlaylistListView.qml
index f55fec5857..c60220aada 100644
--- a/modules/gui/qt/qml/playlist/PlaylistListView.qml
+++ b/modules/gui/qt/qml/playlist/PlaylistListView.qml
@@ -106,6 +106,13 @@ Utils.NavigableFocusScope {
onItemDoubleClicked: mainPlaylistController.goTo(index, true)
color: VLCStyle.colors.getBgColor(model.selected, plitem.hovered, plitem.activeFocus)
+ onDragStarting: {
+ if (!root.plmodel.isSelected(index)) {
+ /* the dragged item is not in the selection, replace the selection */
+ root.plmodel.setSelection([index])
+ }
+ }
+
onDropedMovedAt: {
if (drop.hasUrls) {
mainPlaylistController.insert(target, drop.urls)
--
2.20.1
More information about the vlc-devel
mailing list