[vlc-commits] qml: add network contextMenu

Abel Tesfaye git at videolan.org
Wed Aug 21 15:08:40 CEST 2019


vlc | branch: master | Abel Tesfaye <Abeltesfaye45 at gmail.com> | Tue Aug  6 13:21:56 2019 +0300| [d9821a3dbee2c7f36d626b2603f24bd1a4258e22] | committer: Jean-Baptiste Kempf

qml: add network contextMenu

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d9821a3dbee2c7f36d626b2603f24bd1a4258e22
---

 .../gui/qt/qml/mediacenter/MCNetworkDisplay.qml    | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/modules/gui/qt/qml/mediacenter/MCNetworkDisplay.qml b/modules/gui/qt/qml/mediacenter/MCNetworkDisplay.qml
index 8b0149ffa9..29d4a1228a 100644
--- a/modules/gui/qt/qml/mediacenter/MCNetworkDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MCNetworkDisplay.qml
@@ -18,6 +18,7 @@
 import QtQuick 2.11
 import QtQuick.Controls 2.4
 import QtQml.Models 2.2
+import QtQml 2.11
 
 import org.videolan.vlc 0.1
 import org.videolan.medialib 0.1
@@ -29,7 +30,47 @@ Utils.NavigableFocusScope {
     id: root
 
     property alias tree: mlModel.tree
+    Utils.MenuExt {
+        id: contextMenu
+        property var model: ({})
+        property bool isIndexible: !contextMenu.model ? false : Boolean(contextMenu.model.can_index)
+        property bool isFileType: !contextMenu.model ? false : contextMenu.model.type === MLNetworkModel.TYPE_FILE
+        closePolicy: Popup.CloseOnReleaseOutside | Popup.CloseOnEscape
+        focus:true
 
+        Instantiator {
+            id: instanciator
+            function perform(id){
+                switch(id){
+                    case 0: console.log("not implemented"); break;
+                    case 1: contextMenu.model.indexed = !contextMenu.model.indexed; break;
+                    default: console.log("unknown id:",id)
+                }
+                contextMenu.close()
+            }
+            model: [
+                {
+                    active: contextMenu.isFileType,
+                    text: qsTr("Play all"),
+                    performId: 0
+                },
+                {
+                    active: contextMenu.isIndexible,
+                    text: !contextMenu.model ? "" : contextMenu.model.indexed ? qsTr("Unindex") : qsTr("Index") ,
+                    performId: 1
+                }
+            ]
+            onObjectAdded: model[index].active && contextMenu.insertItem( index, object )
+            onObjectRemoved: model[index].active && contextMenu.removeItem( object )
+            delegate: Utils.MenuItemExt {
+                focus: true
+                text: modelData.text
+                onTriggered: instanciator.perform(modelData.performId)
+            }
+        }
+
+        onClosed: contextMenu.parent.forceActiveFocus()
+    }
     Utils.SelectableDelegateModel {
         id: delegateModel
 



More information about the vlc-commits mailing list