[vlc-commits] qml: hide playlist overlay menu items according to model properties

Fatih Uzunoglu git at videolan.org
Thu Oct 15 10:32:47 CEST 2020


vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Oct  9 19:56:37 2020 +0300| [52b42e583caffbc9ee03286e6d388ed0a260326a] | committer: Pierre Lamot

qml: hide playlist overlay menu items according to model properties

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

 modules/gui/qt/playlist/qml/PlaylistListView.qml | 23 +++++++++++++++++++++++
 modules/gui/qt/playlist/qml/PlaylistMenu.qml     |  5 ++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 088a08e493..c99b5577f5 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -74,6 +74,9 @@ Widgets.NavigableFocusScope {
             leftPadding: root.leftPadding
             rightPadding: root.rightPadding
 
+            isPLEmpty: (root.plmodel.count === 0)
+            isItemNotSelected: (root.plmodel.selectedCount === 0)
+
             //rootmenu
             Action { id:playAction;         text: i18n.qtr("Play");                      onTriggered: mainPlaylistController.goTo(root.plmodel.getSelection()[0], true); icon.source: "qrc:///toolbar/play_b.svg"                   }
             Action { id:streamAction;       text: i18n.qtr("Stream");                    onTriggered: dialogProvider.streamingDialog(root.plmodel.getSelection().map(function(i) { return root.plmodel.itemAt(i).url; }), false); icon.source: "qrc:/menu/stream.svg" }
@@ -134,6 +137,26 @@ Widgets.NavigableFocusScope {
                         deleteAction
                     ]
                 },
+                "rootmenu_plempty" : {
+                    title: i18n.qtr("Playlist"),
+                    entries: [
+                        addFileAction,
+                        addDirAction,
+                        addAdvancedAction
+                    ]
+                },
+                "rootmenu_noselection" : {
+                    title: i18n.qtr("Playlist"),
+                    entries: [
+                        addFileAction,
+                        addDirAction,
+                        addAdvancedAction,
+                        savePlAction,
+                        clearAllAction,
+                        sortAction,
+                        selectTracksAction
+                    ]
+                },
                 "sortmenu" :{
                     title: i18n.qtr("Sort Playlist"),
                     entries:  [
diff --git a/modules/gui/qt/playlist/qml/PlaylistMenu.qml b/modules/gui/qt/playlist/qml/PlaylistMenu.qml
index 6f491f2b10..24ec66db57 100644
--- a/modules/gui/qt/playlist/qml/PlaylistMenu.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistMenu.qml
@@ -34,6 +34,9 @@ Widgets.NavigableFocusScope {
     property int leftPadding: 0
     property int rightPadding: 0
 
+    property bool isPLEmpty: false
+    property bool isItemNotSelected: false
+
     onActiveFocusChanged: {
         if (!activeFocus) {
             overlayMenu.close()
@@ -46,7 +49,7 @@ Widgets.NavigableFocusScope {
     }
 
     function open() {
-        playlistMenu.currentModel = "rootmenu"
+        playlistMenu.currentModel = isPLEmpty ? "rootmenu_plempty" : (isItemNotSelected ? "rootmenu_noselection" : "rootmenu")
         playlistMenu.menuHierachy = []
         overlayMenu.visible = true
         overlayMenu.forceActiveFocus()



More information about the vlc-commits mailing list