[vlc-commits] [Git][videolan/vlc][master] 6 commits: qml/NetworkDisplay: don't access objects out-of-scope

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Sep 12 16:35:28 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
2d1e36cc by Prince Gupta at 2021-09-12T16:14:10+00:00
qml/NetworkDisplay: don't access objects out-of-scope

- - - - -
bec6a584 by Prince Gupta at 2021-09-12T16:14:10+00:00
qml/NetworkAddressbar: remove unncessary imports

- - - - -
c3055581 by Prince Gupta at 2021-09-12T16:14:10+00:00
qml: fix mouse navigation of NetworkAddressBar

- - - - -
608829ed by Prince Gupta at 2021-09-12T16:14:10+00:00
qml/ServicesHomeDisplay: formatting fixes for sourceBrowseComponent

- - - - -
7ac8ea70 by Prince Gupta at 2021-09-12T16:14:10+00:00
qml/NetworkBrowseDisplay: don't use 'variant' as data type in signal

- - - - -
155355f4 by Prince Gupta at 2021-09-12T16:14:10+00:00
qml: correctly handle focusReason in Network display

- - - - -


4 changed files:

- modules/gui/qt/network/qml/NetworkAddressbar.qml
- modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
- modules/gui/qt/network/qml/NetworkDisplay.qml
- modules/gui/qt/network/qml/ServicesHomeDisplay.qml


Changes:

=====================================
modules/gui/qt/network/qml/NetworkAddressbar.qml
=====================================
@@ -1,4 +1,3 @@
-
 /*****************************************************************************
  * Copyright (C) 2020 VLC authors and VideoLAN
  *
@@ -19,20 +18,16 @@
 import QtQuick 2.11
 import QtQuick.Controls 2.4
 import QtQuick.Layouts 1.11
-import QtQml.Models 2.11
 
 import org.videolan.vlc 0.1
 
 import "qrc:///style/"
 import "qrc:///widgets/" as Widgets
 
-import org.videolan.vlc 0.1
-
 Control {
     id: control
 
     property var path
-    signal homeButtonClicked
 
     property var _contentModel
     property var _menuModel
@@ -40,6 +35,9 @@ Control {
     readonly property int maximumWidth: VLCStyle.bannerTabButton_width_large * 4
     readonly property int minimumWidth: VLCStyle.bannerTabButton_width_large
 
+    signal browse(var tree, int reason)
+    signal homeButtonClicked(int reason)
+
     onPathChanged: createContentModel()
     onAvailableWidthChanged: createContentModel()
     implicitWidth: VLCStyle.bannerTabButton_width_large * 4
@@ -47,12 +45,6 @@ Control {
     focus: true
     onActiveFocusChanged: if (activeFocus) contentItem.forceActiveFocus(focusReason)
 
-    function changeTree(newTree) {
-        history.push(["mc", "network", {
-                          "tree": newTree
-                      }])
-    }
-
     function createContentModel() {
         var contentModel = []
         var menuModel = []
@@ -103,7 +95,7 @@ Control {
             Keys.priority: Keys.AfterItem
             Keys.onPressed: Navigation.defaultKeyAction(event)
 
-            onClicked: control.homeButtonClicked()
+            onClicked: control.homeButtonClicked(focusReason)
         }
 
         AddressbarButton {
@@ -168,7 +160,7 @@ Control {
                     onlyIcon: false
                     highlighted: index === contentRepeater.count - 1
 
-                    onClicked: changeTree(modelData.tree)
+                    onClicked: browse(modelData.tree, focusReason)
                 }
 
                 Widgets.IconLabel {
@@ -216,7 +208,7 @@ Control {
         }
 
         onSelected: {
-            changeTree(control._menuModel[index].tree)
+            browse(control._menuModel[index].tree, Qt.MouseFocusReason)
         }
     }
 }


=====================================
modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
=====================================
@@ -47,11 +47,7 @@ FocusScope {
 
     property alias _currentView: view.currentItem
 
-    signal browse(variant tree, int reason)
-
-    providerModel: modelMedia
-
-    contextMenu: NetworkMediaContextMenu { model: modelMedia }
+    signal browse(var tree, int reason)
 
     onTreeChanged: providerModel.tree = tree
 


=====================================
modules/gui/qt/network/qml/NetworkDisplay.qml
=====================================
@@ -47,7 +47,7 @@ Widgets.PageLoader {
         url: "qrc:///network/NetworkHomeDisplay.qml"
     }, {
         name: "browse",
-        url: "qrc:///network/NetworkBrowseDisplay.qml"
+        component: browseComponent
     }]
 
     // Events
@@ -101,19 +101,37 @@ Widgets.PageLoader {
 
     // Children
 
-    NetworkMediaModel {
-        id: modelMedia
+    Component {
+        id: browseComponent
+
+        NetworkBrowseDisplay {
+            providerModel: NetworkMediaModel {
+                ctx: mainctx
+            }
 
-        ctx: mainctx
+            contextMenu: NetworkMediaContextMenu {
+                model: providerModel
+            }
+        }
     }
 
     Component {
         id: componentBar
 
         NetworkAddressbar {
-            path: modelMedia.path
+            path: view === "browse" ? root.stackView.currentItem.providerModel.path : []
+
+            onHomeButtonClicked: {
+                history.push(["mc", "network", "home"])
+
+                stackView.currentItem.setCurrentItemFocus(reason)
+            }
+
+            onBrowse: {
+                history.push(["mc", "network", "browse", { "tree": tree }])
 
-            onHomeButtonClicked: history.push(["mc", "network", "home"])
+                stackView.currentItem.setCurrentItemFocus(reason)
+            }
         }
     }
 }


=====================================
modules/gui/qt/network/qml/ServicesHomeDisplay.qml
=====================================
@@ -63,18 +63,26 @@ Widgets.PageLoader {
 
         NetworkBrowseDisplay {
             property alias source_name: deviceModel.source_name
+
             property Component addressBar: NetworkAddressbar {
                 path: [{display: deviceModel.name, tree: {}}]
 
-                onHomeButtonClicked: history.push(["mc", "discover", "services"])
+                onHomeButtonClicked: {
+                    history.push(["mc", "discover", "services"])
+
+                    stackView.currentItem.setCurrentItemFocus(reason)
+                }
             }
 
             providerModel: deviceModel
             contextMenu: contextMenu
 
-            onBrowse: history.push(["mc", "discover", "services", "source_browse",
-                                    { tree: tree,
-                                      "root_name": deviceModel.name, "source_name": source_name }])
+            onBrowse: {
+                history.push(["mc", "discover", "services", "source_browse",
+                              { tree: tree, "root_name": deviceModel.name, "source_name": source_name }])
+
+                stackView.currentItem.setCurrentItemFocus(reason)
+            }
 
             NetworkDeviceModel {
                 id: deviceModel
@@ -93,41 +101,47 @@ Widgets.PageLoader {
 
     Component {
         id: sourceBrowseComponent
-        NetworkBrowseDisplay {
 
-            providerModel: mediaModel
-            contextMenu: contextMenu
+        NetworkBrowseDisplay {
             property string root_name
             property string source_name
+
             property Component addressBar: NetworkAddressbar {
                 path: {
-                    var _path = mediaModel.path
+                    var _path = providerModel.path
                     _path.unshift({display: root_name, tree: {"source_name": source_name, "isRoot": true}})
                     return _path
                 }
 
-                onHomeButtonClicked: history.push(["mc", "discover", "services"])
-                function changeTree(new_tree) {
-                    if (!!new_tree.isRoot)
-                        history.push(["mc", "discover", "services", "source_root", { source_name: new_tree.source_name }])
-                    else
-                        history.push(["mc", "discover", "services", "source_browse", { tree: new_tree, "root": root_name }]);
+                onHomeButtonClicked: {
+                    history.push(["mc", "discover", "services"])
+
+                    stackView.currentItem.setCurrentItemFocus(reason)
                 }
-            }
 
-            onBrowse: history.push(["mc", "discover", "services", "source_browse",
-                                    { tree: tree, "root": root_name }])
+                onBrowse: {
+                    if (!!tree.isRoot)
+                        history.push(["mc", "discover", "services", "source_root", { source_name: tree.source_name }])
+                    else
+                        history.push(["mc", "discover", "services", "source_browse", { tree: tree, "root": root_name }])
 
-            NetworkMediaModel {
-                id: mediaModel
+                    stackView.currentItem.setCurrentItemFocus(reason)
+                }
+            }
 
+            providerModel: NetworkMediaModel {
                 ctx: mainctx
             }
 
-            NetworkMediaContextMenu {
-                id: contextMenu
+            contextMenu: NetworkMediaContextMenu {
+                model: providerModel
+            }
+
+            onBrowse: {
+                history.push(["mc", "discover", "services", "source_browse",
+                                    { tree: tree, "root": root_name }])
 
-                model: mediaModel
+                stackView.currentItem.setCurrentItemFocus(reason)
             }
         }
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/67fbe60e319ccdbf2be5db4056764473a406a523...155355f4f1041ee6dd9f4e83abf46a8419941606

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/67fbe60e319ccdbf2be5db4056764473a406a523...155355f4f1041ee6dd9f4e83abf46a8419941606
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list