[vlc-devel] [PATCH 36/49] qml: only show the playlist on demand within the player view

Pierre Lamot pierre at videolabs.io
Fri Oct 11 15:18:00 CEST 2019


  the playlist shown independently from the global display state of the
  playlist. This allows to avoid displaying the playlist within the player
  when starting a video.

  When the playlist isn't docked, toggling the playlist display state will
  continue to affect the floating playlist visiblity
---
 modules/gui/qt/qml/player/Player.qml | 45 ++++++++++++++--------------
 modules/gui/qt/qml/player/TopBar.qml |  9 ++----
 2 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index 45c8da989b..74e72e8c77 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -30,8 +30,6 @@ import "qrc:///menus/" as Menus
 Utils.NavigableFocusScope {
     id: rootPlayer
 
-    property alias playlistWidget: playlistpopup
-
     //center image
     Rectangle {
         visible: !rootWindow.hasEmbededVideo
@@ -159,8 +157,15 @@ Utils.NavigableFocusScope {
                     toolbarAutoHide.restart()
             }
 
+            onTogglePlaylistVisiblity:  {
+                if (rootWindow.playlistDocked)
+                    playlistpopup.showPlaylist = !playlistpopup.showPlaylist
+                else
+                    rootWindow.playlistVisible = !rootWindow.playlistVisible
+            }
+
             navigationParent: rootPlayer
-            navigationDown: function () { controlBarView.forceActiveFocus() }
+            navigationDownItem: playlistpopup.showPlaylist ? playlistpopup : controlBarView
 
             Keys.onPressed: {
                 if (event.accepted)
@@ -181,11 +186,11 @@ Utils.NavigableFocusScope {
             right: parent.right
             bottom: controlBarView.top
         }
-
+        property bool showPlaylist: false
         property var previousFocus: undefined
         focus: false
         edge: Utils.DrawerExt.Edges.Right
-        state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden"
+        state: showPlaylist && rootWindow.playlistDocked ? "visible" : "hidden"
         component: Rectangle {
             color: VLCStyle.colors.setColorAlpha(VLCStyle.colors.banner, 0.8)
             width: rootPlayer.width/4
@@ -195,28 +200,24 @@ Utils.NavigableFocusScope {
                 id: playlistView
                 focus: true
                 anchors.fill: parent
-                onActionLeft: playlistpopup.closeAndFocus(playlistpopup.previousFocus)
-                onActionCancel: playlistpopup.closeAndFocus(playlistpopup.previousFocus)
+
+                navigationParent: rootPlayer
+                navigationUpItem: topcontrolView
+                navigationDownItem: controlBarView
+                navigationLeft: function() {
+                    playlistpopup.showPlaylist = false
+                    controlBarView.forceActiveFocus()
+                }
+                navigationCancel: function() {
+                    playlistpopup.showPlaylist = false
+                    controlBarView.forceActiveFocus()
+                }
             }
         }
         onStateChanged: {
             if (state === "hidden")
                 toolbarAutoHide.restart()
         }
-
-        function gainFocus(previous) {
-            console.log("gain Focus")
-            playlistpopup.previousFocus = previous
-            playlistpopup.forceActiveFocus()
-        }
-
-
-        function closeAndFocus(item){
-            rootWindow.playlistVisible = false
-            if (!item)
-                return
-            item.forceActiveFocus()
-        }
     }
 
     Utils.DrawerExt {
@@ -260,7 +261,7 @@ Utils.NavigableFocusScope {
                     }
 
                     navigationParent: rootPlayer
-                    navigationUp: function() { topcontrolView.forceActiveFocus() }
+                    navigationUpItem: playlistpopup.showPlaylist ? playlistpopup : topcontrolView
 
                     //unhandled keys are forwarded as hotkeys
                     Keys.onPressed: {
diff --git a/modules/gui/qt/qml/player/TopBar.qml b/modules/gui/qt/qml/player/TopBar.qml
index e818d44347..a519095309 100644
--- a/modules/gui/qt/qml/player/TopBar.qml
+++ b/modules/gui/qt/qml/player/TopBar.qml
@@ -34,6 +34,8 @@ Utils.NavigableFocusScope{
                               || topcontrollerMouseArea.containsMouse || lockAutoHide
     property bool lockAutoHide: false
 
+    signal togglePlaylistVisiblity();
+
     Keys.priority: Keys.AfterItem
     Keys.onPressed: defaultKeyAction(event, 0)
 
@@ -79,12 +81,7 @@ Utils.NavigableFocusScope{
                     size: VLCStyle.icon_normal
                     text: VLCIcons.playlist
                     color: VLCStyle.colors.playerFg
-                    onClicked: {
-                        rootWindow.playlistVisible = !rootWindow.playlistVisible
-                        if (rootWindow.playlistVisible && rootWindow.playlistDocked) {
-                            playlistWidget.gainFocus(playlistBtn)
-                        }
-                    }
+                    onClicked: togglePlaylistVisiblity()
                     property bool acceptFocus: true
                 }
             }
-- 
2.20.1



More information about the vlc-devel mailing list