[vlc-commits] qml: add method to set and restore focus from the playlist in the player

Pierre Lamot git at videolan.org
Sun Jul 28 08:43:59 CEST 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Jul 26 18:42:30 2019 +0200| [a029d76962bd598153a4ad24c685846f0e81e2cf] | committer: Jean-Baptiste Kempf

qml: add method to set and restore focus from the playlist in the player

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

 modules/gui/qt/qml/player/Player.qml | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index 6339857e6d..c97b1f8689 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -30,6 +30,8 @@ import "qrc:///menus/" as Menus
 Utils.NavigableFocusScope {
     id: rootPlayer
 
+    property alias playlistWidget: playlistpopup
+
     //center image
     Rectangle {
         visible: !rootWindow.hasEmbededVideo
@@ -123,13 +125,11 @@ Utils.NavigableFocusScope {
             right: parent.right
             bottom: controlBarView.top
         }
+
+        property var previousFocus: undefined
         focus: false
         expandHorizontally: true
         state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden"
-        onVisibleChanged: {
-            if (playlistpopup.visible)
-                playlistpopup.forceActiveFocus()
-        }
         component: Rectangle {
             color: VLCStyle.colors.setColorAlpha(VLCStyle.colors.banner, 0.8)
             width: rootPlayer.width/4
@@ -139,8 +139,8 @@ Utils.NavigableFocusScope {
                 id: playlistView
                 focus: true
                 anchors.fill: parent
-                onActionLeft: playlistpopup.closeAndFocus(controlBarView)
-                onActionCancel: playlistpopup.closeAndFocus(controlBarView)
+                onActionLeft: playlistpopup.closeAndFocus(playlistpopup.previousFocus)
+                onActionCancel: playlistpopup.closeAndFocus(playlistpopup.previousFocus)
             }
         }
         onStateChanged: {
@@ -148,11 +148,17 @@ Utils.NavigableFocusScope {
                 toolbarAutoHide.restart()
         }
 
+        function gainFocus(previous) {
+            console.log("gain Focus")
+            playlistpopup.previousFocus = previous
+            playlistpopup.forceActiveFocus()
+        }
+
+
         function closeAndFocus(item){
+            rootWindow.playlistVisible = false
             if (!item)
                 return
-
-            rootWindow.playlistVisible = false
             item.forceActiveFocus()
         }
     }



More information about the vlc-commits mailing list