[vlc-devel] [PATCH 01/18] qml: fix focus in local menu group

Prince Gupta guptaprince8832 at gmail.com
Thu Apr 1 14:29:36 UTC 2021


---
 .../gui/qt/maininterface/qml/BannerSources.qml   | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/maininterface/qml/BannerSources.qml b/modules/gui/qt/maininterface/qml/BannerSources.qml
index 6ac68049ff..92594f7271 100644
--- a/modules/gui/qt/maininterface/qml/BannerSources.qml
+++ b/modules/gui/qt/maininterface/qml/BannerSources.qml
@@ -176,12 +176,25 @@ Widgets.NavigableFocusScope {
                 }
             }
 
-            Item {
+            Widgets.NavigableFocusScope {
                 id: localToolbar
 
                 width: parent.width
                 height: VLCStyle.localToolbar_height
 
+                onActiveFocusChanged: {
+                    if (activeFocus) {
+                        // sometimes when view changes, one of the "focusable" object will become disabled
+                        // but because of focus chainning, FocusScope still tries to force active focus on the object
+                        // but that will fail, manually assign focus in such cases
+                        var focusable = [localContextGroup, localMenuGroup, playlistGroup]
+                        if (!focusable.some(function (obj) { return obj.activeFocus; })) {
+                            // no object has focus
+                            localToolbar.nextItemInFocusChain(true).forceActiveFocus()
+                        }
+                    }
+                }
+
                 Rectangle {
                     id: localToolbarBg
                     color: VLCStyle.colors.bg
@@ -309,6 +322,7 @@ Widgets.NavigableFocusScope {
 
                         focus: !!item && item.focus && item.visible
                         visible: !!item
+                        enabled: status === Loader.Ready
                         y: (VLCStyle.localToolbar_height - item.height) / 2
                         width: !!item
                                ? clamp(localMenuView.availableWidth
-- 
2.27.0



More information about the vlc-devel mailing list