[vlc-commits] [Git][videolan/vlc][master] 8 commits: qml: fix implicit size of NavigableCol

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jun 14 13:35:32 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
36dbb894 by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: fix implicit size of NavigableCol

- - - - -
b686ea52 by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: use NavigableCol in BrowseHomeDisplay

- - - - -
a3b72796 by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: set focus on first index when seleciton is empty

in ExpandGridView, this behaviour is same as KeyNavigableListView

- - - - -
184f914c by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: simplify sub views in BrowseHomeDisplay

- - - - -
00ca12e0 by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: allow quering instantiated objects from NavigableCol

- - - - -
aef4fdc0 by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: generalize resetFocus handling in BrowseHomeDisplay

- - - - -
779ed006 by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: add 'Computer' section in Browse view

fixes #28597

- - - - -
60d10c8d by Prince Gupta at 2024-06-14T13:13:09+00:00
qml: rename sections in Browse view

see discussion in MR 5354

- - - - -


3 changed files:

- modules/gui/qt/network/qml/BrowseHomeDisplay.qml
- modules/gui/qt/widgets/qml/ExpandGridView.qml
- modules/gui/qt/widgets/qml/NavigableCol.qml


Changes:

=====================================
modules/gui/qt/network/qml/BrowseHomeDisplay.qml
=====================================
@@ -147,7 +147,9 @@ FocusScope {
 
         Util.FlickableScrollHandler { }
 
-        Column {
+        Navigation.parentItem: root
+
+        Widgets.NavigableCol {
             id: column
 
             width: foldersSection.width
@@ -156,155 +158,115 @@ FocusScope {
             spacing: (MainCtx.gridView ? VLCStyle.gridView_spacing : VLCStyle.tableView_spacing) -
                      VLCStyle.layoutTitle_top_padding
 
-            BrowseDeviceView {
-                id: foldersSection
-
-                width: root.width
-                height: contentHeight
-
-                visible: (model.count !== 0)
-
-                model: StandardPathModel {
-                    //we only have a handfull of standard path (5 or 6)
-                    //so we don't limit them
+            Navigation.parentItem: root
 
-                    sortCriteria: MainCtx.sort.criteria
-                    sortOrder: MainCtx.sort.order
-                    searchPattern: MainCtx.search.pattern
-                }
+            model: ObjectModel {
+                HomeDeviceView {
+                    id: foldersSection
 
-                title: qsTr("My Folders")
+                    title: qsTr("Folders")
 
-                Navigation.parentItem: root
+                    model: StandardPathModel {
+                        //we only have a handfull of standard path (5 or 6)
+                        //so we don't limit them
 
-                Navigation.downAction: function() {
-                    if (deviceSection.visible)
-                        deviceSection.setCurrentItemFocus(Qt.TabFocusReason)
-                    else if (lanSection.visible)
-                        lanSection.setCurrentItemFocus(Qt.TabFocusReason)
-                    else
-                        root.Navigation.defaultNavigationDown()
+                        sortCriteria: MainCtx.sort.criteria
+                        sortOrder: MainCtx.sort.order
+                        searchPattern: MainCtx.search.pattern
+                    }
                 }
 
-                onBrowse: (tree, reason) => root.browse(tree, reason)
-
-                onSeeAll: (reason) => root.seeAllFolders(title, reason)
-
-                onActiveFocusChanged: _centerFlickableOnItem(foldersSection)
-                onCurrentIndexChanged: _centerFlickableOnItem(foldersSection)
-            }
-
-            BrowseDeviceView {
-                id: deviceSection
-
-                width: root.width
-                height: contentHeight
-
-                maximumRows: root.maximumRows
-
-                visible: (model.count !== 0)
-
-                model: NetworkDeviceModel {
-                    ctx: MainCtx
-
-                    limit: deviceSection.maximumCount
-
-                    sortOrder: MainCtx.sort.order
-                    sortCriteria: MainCtx.sort.criteria
-                    searchPattern: MainCtx.search.pattern
-
-                    sd_source: NetworkDeviceModel.CAT_DEVICES
-                    source_name: "*"
-                }
+                HomeDeviceView {
+                    id: computerSection
 
+                    title: qsTr("Computer")
 
-                title: qsTr("My Machine")
+                    model: NetworkDeviceModel {
+                        ctx: MainCtx
 
-                Navigation.parentItem: root
+                        sd_source: NetworkDeviceModel.CAT_MYCOMPUTER
+                        source_name: "*"
 
-                Navigation.upAction: function() {
-                    if (foldersSection.visible)
-                        foldersSection.setCurrentItemFocus(Qt.TabFocusReason)
-                    else
-                        root.Navigation.defaultNavigationUp()
-                }
+                        limit: computerSection.maximumCount
 
-                Navigation.downAction: function() {
-                    if (lanSection.visible)
-                        lanSection.setCurrentItemFocus(Qt.TabFocusReason)
-                    else
-                        root.Navigation.defaultNavigationDown()
+                        sortOrder: MainCtx.sort.order
+                        sortCriteria: MainCtx.sort.criteria
+                        searchPattern: MainCtx.search.pattern
+                    }
                 }
 
-                onBrowse: (tree, reason) => root.browse(tree, reason)
-
-                onSeeAll: (reason) => root.seeAllDevices(title, model.sd_source, reason)
-
-                onActiveFocusChanged: _centerFlickableOnItem(deviceSection)
-                onCurrentIndexChanged: _centerFlickableOnItem(deviceSection)
-            }
-
-            BrowseDeviceView {
-                id: lanSection
-
-                width: root.width
-                height: contentHeight
-
-                maximumRows: root.maximumRows
+                HomeDeviceView {
+                    id: deviceSection
 
-                visible: (model.count !== 0)
+                    title: qsTr("Devices")
 
-                model: NetworkDeviceModel {
-                    ctx: MainCtx
+                    model: NetworkDeviceModel {
+                        ctx: MainCtx
 
-                    sd_source: NetworkDeviceModel.CAT_LAN
-                    source_name: "*"
+                        limit: deviceSection.maximumCount
 
-                    limit: lanSection.maximumCount
+                        sortOrder: MainCtx.sort.order
+                        sortCriteria: MainCtx.sort.criteria
+                        searchPattern: MainCtx.search.pattern
 
-                    sortOrder: MainCtx.sort.order
-                    sortCriteria: MainCtx.sort.criteria
-                    searchPattern: MainCtx.search.pattern
+                        sd_source: NetworkDeviceModel.CAT_DEVICES
+                        source_name: "*"
+                    }
                 }
 
-                title: qsTr("My LAN")
+                HomeDeviceView {
+                    id: lanSection
 
-                Navigation.parentItem: root
+                    title: qsTr("Network")
 
-                Navigation.upAction: function() {
-                    if (deviceSection.visible)
-                        deviceSection.setCurrentItemFocus(Qt.TabFocusReason)
-                    else if (foldersSection.visible)
-                        foldersSection.setCurrentItemFocus(Qt.TabFocusReason)
-                    else
-                        root.Navigation.defaultNavigationUp()
-                }
+                    model: NetworkDeviceModel {
+                        ctx: MainCtx
 
-                onBrowse: (tree, reason) => root.browse(tree, reason)
+                        sd_source: NetworkDeviceModel.CAT_LAN
+                        source_name: "*"
 
-                onSeeAll: (reason) => root.seeAllDevices(title, model.sd_source, reason)
+                        limit: lanSection.maximumCount
 
-                onActiveFocusChanged: _centerFlickableOnItem(lanSection)
-                onCurrentIndexChanged: _centerFlickableOnItem(lanSection)
+                        sortOrder: MainCtx.sort.order
+                        sortCriteria: MainCtx.sort.criteria
+                        searchPattern: MainCtx.search.pattern
+                    }
+                }
             }
         }
     }
 
     function resetFocus() {
-        const widgetlist = [foldersSection, deviceSection, lanSection]
-        for (let i in widgetlist) {
-            if (widgetlist[i].activeFocus && widgetlist[i].visible)
+        for (let i = 0; i < column.count; ++i) {
+            const widget = column.itemAt(i)
+            if (widget.activeFocus && widget.visible)
                 return
         }
 
         let found  = false;
-        for (let i in widgetlist) {
-            if (widgetlist[i].visible && !found) {
-                widgetlist[i].focus = true
+        for (let i = 0; i < column.count; ++i){
+            const widget = column.itemAt(i)
+            if (widget.visible && !found) {
+                widget.focus = true
                 found = true
             } else {
-                widgetlist[i].focus = false
+                widget.focus = false
             }
         }
     }
+
+    component HomeDeviceView: BrowseDeviceView {
+        width: root.width
+        height: contentHeight
+
+        maximumRows: root.maximumRows
+
+        visible: (model.count !== 0)
+
+        onBrowse: (tree, reason) => root.browse(tree, reason)
+        onSeeAll: (reason) => root.seeAllDevices(title, model.sd_source, reason)
+
+        onActiveFocusChanged: _centerFlickableOnItem(this)
+        onCurrentIndexChanged: _centerFlickableOnItem(this)
+    }
 }


=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -386,13 +386,15 @@ FocusScope {
         // NOTE: Saving the focus reason for later.
         _currentFocusReason = reason;
 
-        if (!model || model.count === 0 || currentIndex === -1) {
+        if (!model || model.count === 0) {
             // NOTE: By default we want the focus on the flickable.
             flickable.forceActiveFocus(reason);
-
             return;
         }
 
+        if (currentIndex === -1)
+            currentIndex = 0
+
         if (_containsItem(currentIndex))
             Helpers.enforceFocus(_getItem(currentIndex), reason);
         else


=====================================
modules/gui/qt/widgets/qml/NavigableCol.qml
=====================================
@@ -36,6 +36,19 @@ T.Control {
     property alias model: repeater.model
     property alias delegate: repeater.delegate
 
+    property alias count: repeater.count
+
+    function itemAt(index) {
+        return repeater.itemAt(index)
+    }
+
+    implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+                            implicitContentWidth + leftPadding + rightPadding)
+
+    implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+                             implicitContentHeight + topPadding + bottomPadding)
+
+
     // Settings
 
     Navigation.navigable: (_countEnabled > 0)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c6eb30f9dee18b44538e5938784d517d9ccee45d...60d10c8dad4a1c5e48af494208588b171fe49876

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c6eb30f9dee18b44538e5938784d517d9ccee45d...60d10c8dad4a1c5e48af494208588b171fe49876
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list