[vlc-devel] [PATCH 05/19] qml: capture mouse events on playlist footer

Fatih Uzunoglu fuzun54 at outlook.com
Wed Aug 12 23:17:12 CEST 2020


---
 .../gui/qt/playlist/qml/PlaylistListView.qml  | 69 ++++++++++++-------
 1 file changed, 46 insertions(+), 23 deletions(-)

diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 2ba99db651..5621d83068 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -310,37 +310,60 @@ Widgets.NavigableFocusScope {
                     }
                 }
 
-                footer: DropArea {
+                footer: Item {
                     width: parent.width
                     height: Math.max(VLCStyle.icon_normal, view.height - y)
 
-                    onEntered: {
-                        if(drag.source.model.index === root.plmodel.count - 1)
-                            return
+                    MouseArea {
+                        anchors.fill: parent
+                        acceptedButtons: Qt.RightButton | Qt.LeftButton
 
-                        root.setItemDropIndicatorVisible(view.modelCount - 1, true, false);
+                        onClicked: {
+                            if( mouse.button === Qt.RightButton )
+                            {
+                                view.forceActiveFocus()
+                                root.plmodel.deselectAll()
+                                contextMenu.model = root.plmodel
+                                contextMenu.popup()
+                            }
+                            else if ( mouse.button === Qt.LeftButton )
+                            {
+                                view.forceActiveFocus()
+                                root.plmodel.deselectAll()
+                            }
+                        }
                     }
-                    onExited: {
-                        if(drag.source.model.index === root.plmodel.count - 1)
-                            return
 
-                        root.setItemDropIndicatorVisible(view.modelCount - 1, false, false);
-                    }
-                    onDropped: {
-                        if(drag.source.model.index === root.plmodel.count - 1)
-                            return
+                    DropArea {
+                        anchors.fill: parent
+                        onEntered: {
+                            if(drag.source.model.index === root.plmodel.count - 1)
+                                return
 
-                        if (drop.hasUrls) {
-                            //force conversion to an actual list
-                            var urlList = []
-                            for ( var url in drop.urls)
-                                urlList.push(drop.urls[url])
-                            mainPlaylistController.insert(root.plmodel.count, urlList)
-                        } else {
-                            root.plmodel.moveItemsPost(root.plmodel.getSelection(), root.plmodel.count - 1)
+                            root.setItemDropIndicatorVisible(view.modelCount - 1, true, false);
+                        }
+                        onExited: {
+                            if(drag.source.model.index === root.plmodel.count - 1)
+                                return
+
+                            root.setItemDropIndicatorVisible(view.modelCount - 1, false, false);
+                        }
+                        onDropped: {
+                            if(drag.source.model.index === root.plmodel.count - 1)
+                                return
+
+                            if (drop.hasUrls) {
+                                //force conversion to an actual list
+                                var urlList = []
+                                for ( var url in drop.urls)
+                                    urlList.push(drop.urls[url])
+                                mainPlaylistController.insert(root.plmodel.count, urlList)
+                            } else {
+                                root.plmodel.moveItemsPost(root.plmodel.getSelection(), root.plmodel.count - 1)
+                            }
+                            root.setItemDropIndicatorVisible(view.modelCount - 1, false, false);
+                            drop.accept()
                         }
-                        root.setItemDropIndicatorVisible(view.modelCount - 1, false, false);
-                        drop.accept()
                     }
                 }
 
-- 
2.25.1



More information about the vlc-devel mailing list