[vlc-commits] [Git][videolan/vlc][master] qml: get rid of the intermediate content item in pages

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Nov 10 02:46:26 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
c3002b8b by Fatih Uzunoglu at 2026-11-10T00:07:04+01:00
qml: get rid of the intermediate content item in pages

`Page` creates an intermediate item because it has to
parent the stray visual children into that. This is a
documented behavior of `Pane`, it is not an eccentric
behavior of `Page`.

Just as we assign the header item to `header`, we now
do the same for the content item with this patch.

This patch not only helps slightly lowering the memory
consumption, but also helps with debugging the scene
through GammaRay.

- - - - -


18 changed files:

- modules/gui/qt/medialibrary/qml/HomeDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoGroupDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoPlaylistsDisplay.qml
- modules/gui/qt/network/qml/BrowseDisplay.qml
- modules/gui/qt/network/qml/BrowseHomeDisplay.qml
- modules/gui/qt/network/qml/BrowseTreeDisplay.qml
- modules/gui/qt/network/qml/DiscoverUrlDisplay.qml
- modules/gui/qt/network/qml/ServicesManage.qml
- modules/gui/qt/network/qml/ServicesSources.qml
- modules/gui/qt/widgets/qml/PageExt.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/HomeDisplay.qml
=====================================
@@ -77,11 +77,9 @@ Widgets.PageLoader {
 
             title: qsTr("Continue Watching")
 
-            VideoAll {
+            contentItem: VideoAll {
                 id: continueWatching
 
-                anchors.fill: parent
-
                 focus: true
 
                 model: MLRecentVideoModel {
@@ -125,11 +123,9 @@ Widgets.PageLoader {
 
             title: qsTr("Favorites")
 
-            MediaView {
+            contentItem: MediaView {
                 focus: true
 
-                anchors.fill: parent
-
                 model: MLMediaModel {
                     favoriteOnly: true
 
@@ -157,11 +153,9 @@ Widgets.PageLoader {
 
             title: qsTr("New Videos")
 
-            VideoAll {
+            contentItem: VideoAll {
                 id: newVideo
 
-                anchors.fill: parent
-
                 focus: true
 
                 model: MLVideoModel {
@@ -197,11 +191,9 @@ Widgets.PageLoader {
 
             title: qsTr("New Music")
 
-            MediaView {
+            contentItem: MediaView {
                 focus: true
 
-                anchors.fill: parent
-
                 model: MLAudioModel {
                     ml: MediaLib
 


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
=====================================
@@ -29,9 +29,7 @@ Widgets.PageExt {
 
     title: qsTr("Albums")
 
-    MusicAlbums {
-        anchors.fill: parent
-
+    contentItem: MusicAlbums {
         focus: true
 
         searchPattern: root.search.pattern


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -149,11 +149,7 @@ Widgets.PageExt {
         model: artistModel
     }
 
-    RowLayout {
-        anchors.fill: parent
-        anchors.leftMargin: root.leftPadding
-        anchors.rightMargin: root.rightPadding
-
+    contentItem: RowLayout {
         visible: artistModel.count > 0
 
         spacing: 0
@@ -322,6 +318,8 @@ Widgets.PageExt {
     }
 
     Widgets.EmptyLabelButton {
+        parent: root // Can't parent to layout content item due to anchoring
+        anchors.verticalCenterOffset: parent.header?.height ?? 0
         anchors.centerIn: parent
 
         visible: !artistModel.loading && (artistModel.count <= 0)


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
=====================================
@@ -53,11 +53,9 @@ Widgets.PageLoader {
 
             title: qsTr("Artists")
 
-            MusicAllArtists {
+            contentItem: MusicAllArtists {
                 id: artistsView
 
-                anchors.fill: parent
-
                 focus: true
 
                 searchPattern: artistPage.search.pattern


=====================================
modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
=====================================
@@ -51,11 +51,9 @@ Widgets.PageLoader {
             title: qsTr("Genres")
 
             /* List View */
-            MusicGenres {
+            contentItem: MusicGenres {
                 id: genresView
 
-                anchors.fill: parent
-
                 focus: true
 
                 displayMarginBeginning: root.displayMarginBeginning
@@ -86,11 +84,9 @@ Widgets.PageLoader {
             title: qsTr("Genres - %1").arg(genreName)
 
             /* List View */
-            MusicAlbums {
+            contentItem: MusicAlbums {
                 id: albumsView
 
-                anchors.fill: parent
-
                 focus: true
 
                 searchPattern: albumGenrePage.search.pattern


=====================================
modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml
=====================================
@@ -60,10 +60,7 @@ Widgets.PageLoader {
 
             title: qsTr("Playlists")
 
-            PlaylistMediaList {
-
-                anchors.fill: parent
-
+            contentItem: PlaylistMediaList {
                 focus: true
 
                 isMusic: true


=====================================
modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
=====================================
@@ -50,10 +50,7 @@ Widgets.PageExt {
         tracklistdisplay_id.positionViewAtBeginningAnimated()
     }
 
-    FocusScope {
-
-        anchors.fill: parent
-
+    contentItem: FocusScope {
         focus: true
 
         // Aliases


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -89,9 +89,7 @@ Widgets.PageExt {
     }
 
 
-    FocusScope {
-
-        anchors.fill:  parent
+    contentItem: FocusScope {
 
         MLPlaylistModel {
             id: model


=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -70,11 +70,9 @@ Widgets.PageExt {
 
     title: qsTr("Videos")
 
-    VideoAll {
+    contentItem: VideoAll {
         id: videoAll
 
-        anchors.fill: parent
-
         focus: true
 
         model: _meta?.model ?? null


=====================================
modules/gui/qt/medialibrary/qml/VideoGroupDisplay.qml
=====================================
@@ -45,13 +45,11 @@ Widgets.PageExt {
         onGrouping: (grouping) => { MainCtx.grouping = grouping }
     }
 
-    VideoAll {
+    contentItem: VideoAll {
         id: videoAll
 
         // Aliases
 
-        anchors.fill: parent
-
         focus: true
 
         displayMarginBeginning: root.displayMarginBeginning


=====================================
modules/gui/qt/medialibrary/qml/VideoPlaylistsDisplay.qml
=====================================
@@ -59,11 +59,9 @@ Widgets.PageLoader {
 
             title: qsTr("Playlists")
 
-            PlaylistMediaList {
+            contentItem: PlaylistMediaList {
                 id: playlistView
 
-                anchors.fill: parent
-
                 focus: true
 
                 isMusic: false


=====================================
modules/gui/qt/network/qml/BrowseDisplay.qml
=====================================
@@ -103,14 +103,12 @@ Widgets.PageLoader {
 
             title: folderModel.name
 
-            BrowseDeviceView {
+            contentItem: BrowseDeviceView {
                 property var sortModel: [
                     { text: qsTr("Alphabetic"), criteria: "name" },
                     { text: qsTr("Url"),        criteria: "mrl"  }
                 ]
 
-                anchors.fill: parent
-
                 displayMarginBeginning: root.displayMarginBeginning
                 displayMarginEnd: root.displayMarginEnd
 
@@ -148,11 +146,9 @@ Widgets.PageLoader {
                 { text: qsTr("Url"),        criteria: "mrl"  }
             ]
 
-            BrowseDeviceView {
+            contentItem: BrowseDeviceView {
                 id: viewDevice
 
-                anchors.fill: parent
-
                 displayMarginBeginning: root.displayMarginBeginning
                 displayMarginEnd: root.displayMarginEnd
 


=====================================
modules/gui/qt/network/qml/BrowseHomeDisplay.qml
=====================================
@@ -120,14 +120,9 @@ Widgets.PageExt {
         text: qsTr("No network shares found")
     }
 
-    Flickable {
+    contentItem: Flickable {
         id: flickable
 
-        anchors.fill: parent
-
-        anchors.leftMargin: root.leftPadding
-        anchors.rightMargin: root.rightPadding
-
         T.ScrollBar.vertical: Widgets.ScrollBarExt { }
 
         flickableDirection: Flickable.AutoFlickIfNeeded


=====================================
modules/gui/qt/network/qml/BrowseTreeDisplay.qml
=====================================
@@ -62,11 +62,9 @@ Widgets.PageExt {
         onHomeButtonClicked: (reason) => root.homeButtonClicked(reason)
     }
 
-    MainViewLoader {
+    contentItem: MainViewLoader {
         id: loader
 
-        anchors.fill: parent
-
         isSearchable: true
 
         sortModel: [


=====================================
modules/gui/qt/network/qml/DiscoverUrlDisplay.qml
=====================================
@@ -44,8 +44,7 @@ Widgets.PageExt {
         searchField.forceActiveFocus(reason);
     }
 
-    FocusScope {
-        anchors.fill: parent
+    contentItem: FocusScope {
         focus: true
 
         Column {


=====================================
modules/gui/qt/network/qml/ServicesManage.qml
=====================================
@@ -29,7 +29,7 @@ Widgets.PageExt {
 
     title: qsTr("Install services")
 
-    Widgets.ListViewExt {
+    contentItem: Widgets.ListViewExt {
         id: servicesView
 
         // required by g_root to indicate view with 'grid' or 'list' mode
@@ -38,9 +38,6 @@ Widgets.PageExt {
 
         property var pagePrefix: []
 
-        anchors.fill: parent
-
-
         model: ServicesDiscoveryModel {
             id: discoveryModel
 


=====================================
modules/gui/qt/network/qml/ServicesSources.qml
=====================================
@@ -42,12 +42,10 @@ Widgets.PageExt {
         grid.positionViewAtBeginningAnimated()
     }
 
-    Widgets.ExpandGridItemView {
+    contentItem: Widgets.ExpandGridItemView {
         //settings
         id: grid
 
-        anchors.fill: parent
-
         focus: true
 
         basePictureWidth: VLCStyle.gridCover_network_width


=====================================
modules/gui/qt/widgets/qml/PageExt.qml
=====================================
@@ -30,16 +30,12 @@ T.Page {
     //path of the current page loader
     property var pagePrefix: []
 
-    //note that T.Page introduce an intermediate Item, so to access our delegate,
-    //we need to use contentChildren[0] rather than contentItem
-    readonly property Item _firstChild: contentChildren[0] ?? null
-
     //indicates whether the subview support grid/list mode
-    property bool hasGridListMode: _firstChild?.hasGridListMode ?? false
+    property bool hasGridListMode: contentItem?.hasGridListMode ?? false
 
-    property bool isSearchable: _firstChild?.isSearchable ?? false
+    property bool isSearchable: contentItem?.isSearchable ?? false
 
-    property var sortModel: _firstChild?.sortModel ?? null
+    property var sortModel: contentItem?.sortModel ?? null
 
     //property is *not* readOnly, a PageLoader may define a localMenuDelegate common for its subviews (music, video)
     property SortMenu sortMenu: null
@@ -91,15 +87,15 @@ T.Page {
         value: root.hasGridListMode
     }
 
-    on_FirstChildChanged: {
-        if (!_firstChild)
+    onContentItemChanged: {
+        if (!contentItem)
             return
-        _firstChild.Navigation.parentItem = root
-        _firstChild.Navigation.upItem = root.header
+        contentItem.Navigation.parentItem = root
+        contentItem.Navigation.upItem = root.header
     }
 
     function positionContentAtBeginning() {
-        _firstChild?.positionContentAtBeginning?.()
+        contentItem?.positionContentAtBeginning?.()
     }
 
     implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
@@ -124,10 +120,10 @@ T.Page {
         Navigation.downAction: function() {
             if (typeof root.setCurrentItemFocus === "function")
                 root.setCurrentItemFocus(Qt.TabFocusReason)
-            else if (typeof root._firstChild?.setCurrentItemFocus === "function")
-             root._firstChild.setCurrentItemFocus(Qt.TabFocusReason)
-            else if (root._firstChild)
-                root._firstChild.forceActiveFocus(Qt.TabFocusReason)
+            else if (typeof root.contentItem?.setCurrentItemFocus === "function")
+             root.contentItem.setCurrentItemFocus(Qt.TabFocusReason)
+            else if (root.contentItem)
+                root.contentItem.forceActiveFocus(Qt.TabFocusReason)
         }
     }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c3002b8be928ab02c7eb6f03cef297b663203464

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c3002b8be928ab02c7eb6f03cef297b663203464
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list