[vlc-commits] [Git][videolan/vlc][master] 18 commits: qml: expose `itemAtIndex()` in `TableViewExt`

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Nov 13 04:43:01 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0f2d2eff by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose `itemAtIndex()` in `TableViewExt`

- - - - -
e19d7ff6 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose `itemAtIndex()` in `ExpandGridView`

- - - - -
4c9c9b4e by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose `itemAtIndex()` in `MainViewLoader`

- - - - -
9a03e865 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose the texture provider in `GridItem`

- - - - -
36c8f0ea by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose the texture provider in `PlaylistDelegate`

- - - - -
ff3a3944 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose the texture provider in `MediaCover`

- - - - -
4e351b9c by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose the texture provider in `TableColumns`

- - - - -
1d85e323 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: expose the texture provider in `TableViewDelegateExt`

- - - - -
bc6e1f2e by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: introduce possibility of using texture provider in `DragItem`

- - - - -
97304f42 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: enable texture reusing in `MLDragItem`

- - - - -
934c6328 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: enable texture reusing in playlist drag item

- - - - -
2e63c21d by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: enable texture reusing in artwork info widget drag item

- - - - -
4560f3c8 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: enable texture reusing in `BrowseTreeDisplay` drag item

- - - - -
78810a6b by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: provide the index and view to the expand delegate in `ExpandGridView`

- - - - -
57407680 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: reuse texture in grid view expansion

- - - - -
e02cd99a by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: reuse texture in `ArtistTopBanner`

- - - - -
0434bcaf by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: fix default condition of image loading in `ImageExt`

If `textureProviderItem` is overridden but set to null,
the `ShaderEffect` is going to use the default `Image`
as the texture provider. In that case, `Image` should
load the image.

- - - - -
80868d09 by Fatih Uzunoglu at 2025-11-13T04:11:38+00:00
qml: add note regarding setting `textureProviderItem` null in `ImageExt`

- - - - -


26 changed files:

- modules/gui/qt/maininterface/qml/MainViewLoader.qml
- modules/gui/qt/medialibrary/qml/ArtistTopBanner.qml
- modules/gui/qt/medialibrary/qml/MediaView.qml
- modules/gui/qt/medialibrary/qml/MusicAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
- modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicGenres.qml
- modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/network/qml/BrowseTreeDisplay.qml
- modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
- modules/gui/qt/playlist/qml/PlaylistDelegate.qml
- modules/gui/qt/playlist/qml/PlaylistPane.qml
- modules/gui/qt/widgets/qml/DragItem.qml
- modules/gui/qt/widgets/qml/ExpandGridView.qml
- modules/gui/qt/widgets/qml/GridItem.qml
- modules/gui/qt/widgets/qml/ImageExt.qml
- modules/gui/qt/widgets/qml/MLDragItem.qml
- modules/gui/qt/widgets/qml/MediaCover.qml
- modules/gui/qt/widgets/qml/TableColumns.qml
- modules/gui/qt/widgets/qml/TableViewDelegateExt.qml
- modules/gui/qt/widgets/qml/TableViewExt.qml


Changes:

=====================================
modules/gui/qt/maininterface/qml/MainViewLoader.qml
=====================================
@@ -115,6 +115,8 @@ Loader {
     property alias initialItem: root.sourceComponent
     property alias currentItem: root.item
 
+    readonly property var itemAtIndex: currentItem?.itemAtIndex
+
     // Navigation
 
     // handle cancelAction, if currentIndex is set reset it to 0


=====================================
modules/gui/qt/medialibrary/qml/ArtistTopBanner.qml
=====================================
@@ -159,6 +159,7 @@ FocusScope {
             Widgets.ImageExt {
                 id: roundImage
                 source: root.artist.id ? (root.artist.cover || VLCStyle.noArtArtist) : "" // do not load the fallback image during initialization
+                textureProviderItem: background
                 sourceSize: Qt.size(width * eDPR, height * eDPR)
                 anchors.fill: parent
                 radius: VLCStyle.cover_normal


=====================================
modules/gui/qt/medialibrary/qml/MediaView.qml
=====================================
@@ -100,7 +100,7 @@ MainViewLoader {
     Widgets.MLDragItem {
         id: dragItemId
 
-        mlModel: root.model
+        view: root.currentItem
 
         coverRole: "small_cover"
 


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -82,7 +82,7 @@ MainViewLoader {
     Widgets.MLDragItem {
         id: albumDragItem
 
-        mlModel: albumModelId
+        view: root.currentItem
         indexes: indexesFlat ? selectionModel.selectedIndexesFlat
                              : selectionModel.selectedIndexes
         indexesFlat: !!selectionModel.selectedIndexesFlat


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
=====================================
@@ -33,6 +33,9 @@ FocusScope {
 
     property var model
 
+    property int index
+    property Item view // can not use `ItemView` because of `ExpandGridView`
+
     property var headerFocusScope
     property var enqueueActionBtn
     property var playActionBtn
@@ -130,6 +133,8 @@ FocusScope {
                     : VLCStyle.noArtAlbumCover
                 sourceSize: Qt.size(width * eDPR, height * eDPR)
                 backgroundColor: theme.bg.primary
+                textureProviderItem: root.view?.itemAtIndex(root.index)?.artworkTextureProvider ?? null
+
 
                 readonly property real eDPR: MainCtx.effectiveDevicePixelRatio(Window.window)
 


=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -91,7 +91,7 @@ MainViewLoader {
     Widgets.MLDragItem {
         id: artistsDragItem
 
-        mlModel: artistModel
+        view: root.currentItem
         indexes: indexesFlat ? selectionModel.selectedIndexesFlat
                              : selectionModel.selectedIndexes
         indexesFlat: !!selectionModel.selectedIndexesFlat


=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -389,7 +389,8 @@ FocusScope {
     Widgets.MLDragItem {
         id: albumDragItem
 
-        mlModel: albumModel
+        view: (root._currentView instanceof Widgets.TableViewExt) ? root._currentView?.headerItem?.albumsListView
+                                                                  : root._currentView
         indexes: indexesFlat ? albumSelectionModel.selectedIndexesFlat
                              : albumSelectionModel.selectedIndexes
         indexesFlat: !!albumSelectionModel.selectedIndexesFlat
@@ -614,7 +615,7 @@ FocusScope {
             Widgets.MLDragItem {
                 id: tableDragItem
 
-                mlModel: trackModel
+                view: tableView_id
 
                 indexes: indexesFlat ? tableView_id.selectionModel.selectedIndexesFlat
                                      : tableView_id.selectionModel.selectedIndexes


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -290,7 +290,7 @@ FocusScope {
             Widgets.MLDragItem {
                 id: musicArtistDragItem
 
-                mlModel: artistModel
+                view: artistList
 
                 indexes: indexesFlat ? selectionModel.selectedIndexesFlat
                                      : selectionModel.selectedIndexes


=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -91,7 +91,7 @@ MainViewLoader {
     Widgets.MLDragItem {
         id: genreDragItem
 
-        mlModel: genreModel
+        view: root.currentItem
 
         indexes: indexesFlat ? selectionModel.selectedIndexesFlat
                              : selectionModel.selectedIndexes


=====================================
modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
=====================================
@@ -195,7 +195,7 @@ Widgets.TableViewExt {
                              : root.selectionModel.selectedIndexes
         indexesFlat: !!root.selectionModel.selectedIndexesFlat
 
-        mlModel: model
+        view: root
     }
 
     Widgets.MLTableColumns {


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -178,7 +178,7 @@ FocusScope {
     Widgets.MLDragItem {
         id: dragItem
 
-        mlModel: model
+        view: view
 
         indexes: indexesFlat ? view.selectionModel.selectedIndexesFlat
                              : view.selectionModel.selectedIndexes


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
=====================================
@@ -254,7 +254,7 @@ MainViewLoader {
 
         objectName: "PlaylistMediaListDragItem"
 
-        mlModel: model
+        view: root.currentItem
 
         indexes: indexesFlat ? root.selectionModel.selectedIndexesFlat
                              : root.selectionModel.selectedIndexes


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -125,7 +125,7 @@ MainViewLoader {
     Widgets.MLDragItem {
         id: dragItem
 
-        mlModel: root.model
+        view: root.currentItem
 
         indexes: indexesFlat ? selectionModel.selectedIndexesFlat
                              : selectionModel.selectedIndexes


=====================================
modules/gui/qt/network/qml/BrowseTreeDisplay.qml
=====================================
@@ -114,7 +114,8 @@ MainViewLoader {
 
             return {
                 artwork: data.artwork,
-                fallback: fallbackImage
+                fallback: fallbackImage,
+                textureProvider: root.currentItem.itemAtIndex(index)?.artworkTextureProvider
             }
         }
 


=====================================
modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
=====================================
@@ -98,6 +98,10 @@ AbstractButton {
     Widgets.DragItem {
         id: dragItem
 
+        getTextureProvider: function() {
+            return root.contentItem?.image
+        }
+
         onRequestData: (_, resolve, reject) => {
             resolve([{
                 "title": Player.title,
@@ -149,6 +153,8 @@ AbstractButton {
     contentItem: RowLayout {
         spacing: VLCStyle.margin_xsmall
 
+        property alias image: coverImage
+
         Image {
             id: coverImage
 


=====================================
modules/gui/qt/playlist/qml/PlaylistDelegate.qml
=====================================
@@ -48,6 +48,8 @@ T.Control {
                                                       dropAreaLayout.dragPosition.x,
                                                       dropAreaLayout.dragPosition.y)
 
+    readonly property Image artworkTextureProvider: contentItem?.artworkTextureProvider ?? null
+
     // Model roles:
     required property int index
     required property bool isCurrent
@@ -148,6 +150,8 @@ T.Control {
     contentItem: RowLayout {
         spacing: 0
 
+        property alias artworkTextureProvider: artwork
+
         Item {
             id: artworkItem
 


=====================================
modules/gui/qt/playlist/qml/PlaylistPane.qml
=====================================
@@ -73,6 +73,8 @@ T.Pane {
     Widgets.DragItem {
         id: dragItem
 
+        view: root.listView
+
         onRequestData: (indexes, resolve, reject) => {
             resolve(indexes.map((index) => {
                 const item = root.model.itemAt(index)


=====================================
modules/gui/qt/widgets/qml/DragItem.qml
=====================================
@@ -52,6 +52,24 @@ Item {
     // function(index, data) - returns cover for the index in the model in the form {artwork: <string> (file-name), fallback: <string> (file-name)}
     property var coverProvider: null
 
+    // Optional, for now used by the default `getTextureProvider()`.
+    // Mandatory for `MLDragItem`, as `MLDragItem` retrieves the model through the view.
+    property Item view // can not use `ItemView` because of `ExpandGridView`
+
+    // Optional, function that takes index and returns the texture provider:
+    property var getTextureProvider: function(index) {
+        // Texture provider is not going to be available at all times, particularly
+        // for the cases when the item is not available in the view (large model,
+        // select all case)
+
+        // FIXME: `call(null, index)` is to prevent the following warning:
+        //         > Calling C++ methods with 'this' objects different from the one they
+        //         > were retrieved from is broken, due to historical reasons. The original
+        //         > object is used as 'this' object. You can allow the given 'this' object
+        //         > to be used by setting 'pragma NativeMethodBehavior: AcceptThisObject'
+        return dragItem.view?.itemAtIndex.call(null, index)?.artworkTextureProvider ?? null
+    }
+
     // string => role
     property string coverRole: "cover"
 
@@ -188,7 +206,8 @@ Item {
         else
             return {
                 artwork: data[dragItem.coverRole] || dragItem.defaultCover,
-                fallback: dragItem.defaultCover
+                fallback: dragItem.defaultCover,
+                textureProvider: dragItem.getTextureProvider ? dragItem.getTextureProvider(index) : null
             }
     }
 
@@ -481,6 +500,8 @@ Item {
                 radius: coverRepeater.count > 1 ? dragItem.coverSize : 0.0
                 source: modelData.artwork ?? ""
                 sourceSize: dragItem.imageSourceSize ?? Qt.size(width * eDPR, height * eDPR)
+                textureProviderItem: modelData?.textureProvider ?? null
+
                 backgroundColor: theme.bg.primary
                 borderWidth: VLCStyle.dp(1, VLCStyle.scale)
                 borderColor: theme.border


=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -610,6 +610,8 @@ FocusScope {
         return _idChildrenList[i]
     }
 
+    readonly property var itemAtIndex: _getItem
+
     function _setItem(id, item) {
         const i = id - _currentRange[0]
         _idChildrenList[i] = item
@@ -762,6 +764,7 @@ FocusScope {
         }
 
         if (expandIndex >= iMin && expandIndex < iMax) {
+            expandItem.index = expandIndex
             expandItem.model = model.getDataAt(expandIndex)
         }
     }
@@ -1067,6 +1070,8 @@ FocusScope {
             root.expandIndex = root._newExpandIndex
             if (root.expandIndex === -1)
                 return
+            expandItem.index = expandIndex
+            expandItem.view = root
             expandItem.model = model.getDataAt(root.expandIndex)
             /* We must also start the expand animation here since the expandItem implicitHeight is not
                changed if it had the same height at previous opening. */


=====================================
modules/gui/qt/widgets/qml/GridItem.qml
=====================================
@@ -67,6 +67,8 @@ T.ItemDelegate {
     property alias selectedShadow: selectedShadow
     property alias unselectedShadow: unselectedShadow
 
+    property alias artworkTextureProvider: picture.textureProvider
+
     // Signals
 
     signal playClicked


=====================================
modules/gui/qt/widgets/qml/ImageExt.qml
=====================================
@@ -74,12 +74,17 @@ Item {
     //          in that case the texture provider item should provide a subset of `Image`'s
     //          interface, that is, provide `status` and `implicitWidth`/`implicitHeight` that
     //          reflect the texture size.
+    // NOTE:    If `textureProviderItem` is set to `null`, the default `Image` is going to be
+    //          used as fallback. For that reason, it is recommended to keep providing the
+    //          `source` url if there is a possibility of `textureProviderItem` being `null`
+    //          as long as it is applicable (not all texture providers may be sourced from
+    //          a source url, or the source url may also be lost and not tracked anymore).
     property Item textureProviderItem: sourceTextureProviderItem
 
     // NOTE:    If the texture provider used does not require `ImageExt` to load the image, this
     //          should be disabled.
     // WARNING: In non-RHI mode, this setting is not respected.
-    property bool loadImages: (textureProviderItem === image)
+    property bool loadImages: (shaderEffect.source === image)
 
     // Padding represents how much the content is shrunk. For now this is a readonly property.
     // Currently it only takes the `softEdgeMax` into calculation, as that's what the shader


=====================================
modules/gui/qt/widgets/qml/MLDragItem.qml
=====================================
@@ -27,16 +27,18 @@ import VLC.MediaLibrary
 DragItem {
     id: root
 
-    required property MLBaseModel mlModel
-
     // string => role for medialib id, data[id] will be pass to Medialib::mlInputItem for SharedInputItem
     property string mlIDRole: "id"
 
     onRequestData: (indexes, resolve, reject) =>  {
+        console.assert(root.view)
+        console.assert(root.view.model)
+        console.assert(root.view.model.getData)
+        console.assert(root.view.model.getDataFlat)
         if (indexesFlat)
-            mlModel.getDataFlat(indexes, resolve)
+            root.view.model.getDataFlat(indexes, resolve)
         else
-            mlModel.getData(indexes, resolve)
+            root.view.model.getData(indexes, resolve)
     }
 
     onRequestInputItems: (indexes, data, resolve, reject) => {


=====================================
modules/gui/qt/widgets/qml/MediaCover.qml
=====================================
@@ -73,6 +73,8 @@ Item {
 
     property alias fillMode: image.fillMode
 
+    readonly property Item textureProvider: fallbackImage.visible ? fallbackImage.textureProviderItem : image.textureProviderItem
+
     // Signals
 
     signal playIconClicked(var point)


=====================================
modules/gui/qt/widgets/qml/TableColumns.qml
=====================================
@@ -93,6 +93,8 @@ Item {
     property Component titleDelegate: TableRowDelegate {
         id: titleDel
 
+        property alias artworkTextureProvider: cover.textureProvider
+
         RowLayout {
             anchors.fill: parent
             spacing: VLCStyle.margin_normal


=====================================
modules/gui/qt/widgets/qml/TableViewDelegateExt.qml
=====================================
@@ -62,6 +62,8 @@ T.Control {
 
     property int _contextMenuRequestID: -1
 
+    property Item artworkTextureProvider
+
     signal rightClick(Item menuParent, var menuModel, point globalMousePos)
     signal itemDoubleClicked(var index, var model)
 
@@ -249,6 +251,9 @@ T.Control {
                             delegate: delegate
                         }
                     )
+                    if (item.artworkTextureProvider) {
+                        delegate.artworkTextureProvider = Qt.binding(() => item.artworkTextureProvider)
+                    }
                 }
                 Component.onDestruction: {
                     item?.destroy()


=====================================
modules/gui/qt/widgets/qml/TableViewExt.qml
=====================================
@@ -188,6 +188,8 @@ FocusScope {
 
     property alias reuseItems: view.reuseItems
 
+    readonly property var itemAtIndex: view.itemAtIndex
+
     // Signals
 
     //forwarded from subview



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2101c1258b171a75178e19a3f8bc1c6bab4000cf...80868d09a4f093185697b430a1710f8625ed28d2

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2101c1258b171a75178e19a3f8bc1c6bab4000cf...80868d09a4f093185697b430a1710f8625ed28d2
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