[vlc-commits] qml: make PlayerButtonLayout a FocusScope.

Pierre Lamot git at videolan.org
Thu Aug 29 10:45:14 CEST 2019


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Aug 29 09:44:26 2019 +0200| [d6476f1640b53f9f5fa655e36dc9c6a52efbc34f] | committer: Jean-Baptiste Kempf

qml: make PlayerButtonLayout a FocusScope.

  this avoids referencing internal items from outside for navigation

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

 modules/gui/qt/qml/player/ControlBar.qml          | 28 ++++++-----------------
 modules/gui/qt/qml/player/MiniPlayer.qml          | 12 ++++++----
 modules/gui/qt/qml/player/PlayerButtonsLayout.qml | 22 +++++++++++++++---
 3 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/modules/gui/qt/qml/player/ControlBar.qml b/modules/gui/qt/qml/player/ControlBar.qml
index 87d2e0ac12..7921a914a1 100644
--- a/modules/gui/qt/qml/player/ControlBar.qml
+++ b/modules/gui/qt/qml/player/ControlBar.qml
@@ -84,8 +84,13 @@ Utils.NavigableFocusScope {
             Keys.onDownPressed: buttons.focus = true
         }
 
-        Utils.NavigableFocusScope {
+
+        PlayerButtonsLayout {
             id: buttons
+
+            model: playerControlBarModel
+            forceColors: true
+
             Layout.fillHeight: true
             Layout.fillWidth: true
 
@@ -105,27 +110,8 @@ Utils.NavigableFocusScope {
 
             Keys.priority: Keys.AfterItem
             Keys.onPressed: defaultKeyAction(event, 0)
-
-            ToolBar {
-                id: buttonstoolbar
-                focusPolicy: Qt.StrongFocus
-                focus: true
-                rightPadding: 0
-                leftPadding: 0
-                anchors.fill: parent
-
-                background: Rectangle {
-                    color: "transparent"
-                }
-
-                PlayerButtonsLayout {
-                    focus: true
-                    anchors.fill: parent
-                    model: playerControlBarModel
-                    forceColors: true
-                }
-            }
         }
+
     }
     Connections{
         target: rootWindow
diff --git a/modules/gui/qt/qml/player/MiniPlayer.qml b/modules/gui/qt/qml/player/MiniPlayer.qml
index 7f83087377..89ee15f792 100644
--- a/modules/gui/qt/qml/player/MiniPlayer.qml
+++ b/modules/gui/qt/qml/player/MiniPlayer.qml
@@ -125,7 +125,7 @@ Utils.NavigableFocusScope {
                     }
                 }
 
-                KeyNavigation.right: buttonrow.children[0].item
+                KeyNavigation.right: buttonrow
             }
 
             Item {
@@ -138,16 +138,20 @@ Utils.NavigableFocusScope {
                 Layout.rightMargin: VLCStyle.margin_normal
                 model: miniPlayerModel
                 defaultSize: VLCStyle.icon_normal
-            }
 
+
+                onActionUp: root.actionUp(index)
+                onActionDown: root.actionDown(index)
+                onActionLeft: playingItemInfo.forceActiveFocus()
+                onActionRight: root.actionRight(index)
+                onActionCancel: root.actionCancel(index)
+            }
         }
 
         Connections{
             target: rootWindow
             onToolBarConfUpdated: {
-                playingItemInfo.KeyNavigation.right = null
                 miniPlayerModel.reloadModel()
-                playingItemInfo.KeyNavigation.right = buttonrow.children[0].item
             }
         }
 
diff --git a/modules/gui/qt/qml/player/PlayerButtonsLayout.qml b/modules/gui/qt/qml/player/PlayerButtonsLayout.qml
index df96583817..e75b0b4f62 100644
--- a/modules/gui/qt/qml/player/PlayerButtonsLayout.qml
+++ b/modules/gui/qt/qml/player/PlayerButtonsLayout.qml
@@ -26,13 +26,27 @@ import org.videolan.vlc 0.1
 import "qrc:///style/"
 import "qrc:///utils/" as Utils
 
-RowLayout{
-    id: buttonrow
-    property bool _focusGiven: false
+Utils.NavigableFocusScope {
+    id: playerButtonsLayout
     property alias model: buttonsRepeater.model
     property var defaultSize: VLCStyle.icon_medium
     property bool forceColors: false
 
+    property alias implicitWidth: buttonrow.implicitWidth
+    property alias implicitHeight: buttonrow.implicitHeight
+
+    Keys.priority: Keys.AfterItem
+    Keys.onPressed: {
+        if (!event.accepted)
+            defaultKeyAction(event, 0)
+    }
+
+RowLayout{
+    id: buttonrow
+    property bool _focusGiven: false
+
+    anchors.fill: parent
+
     Repeater{
         id: buttonsRepeater
         delegate: Loader{
@@ -71,3 +85,5 @@ RowLayout{
         }
     }
 }
+
+}



More information about the vlc-commits mailing list