[vlc-commits] [Git][videolan/vlc][master] 4 commits: qml: do not change selection within `resetFocus()` in `MusicArtistsAlbums`

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Feb 3 06:36:01 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
978a7308 by Fatih Uzunoglu at 2025-02-03T05:57:43+00:00
qml: do not change selection within `resetFocus()` in `MusicArtistsAlbums`

It does not make sense to adjust selection within `resetFocus()`. This
causes the initial selection to be the first item while normally there
should not be a selection initially.

- - - - -
913454c4 by Fatih Uzunoglu at 2025-02-03T05:57:43+00:00
qml: get rid of `showArtist()` signal in `MusicArtistsAlbums.qml`

It is not clear why such signal exists, it seems that it is
supposed to be a function instead.

Regardless, having such signal is not meaningful because there
is already `currentIndex` which is synchronized with the shown
artist. This synchronization is satisfied by the change handler.

The change handler already needs to adjust the artist id (for
synchronization), making `showArtist()` meaningless.

Currently clicking a delegate does not change the current index.
Views should change the current index when clicking on delegate.

- - - - -
738520b6 by Fatih Uzunoglu at 2025-02-03T05:57:43+00:00
qml: fix emitting a signal without required parameters in `MusicAllArtists.qml`

Functioning of double clicking list view delegate is broken due to "Error:
Insufficient arguments".

At the same time, `currentIndex` should be used instead of the first selected
item when view is requested.

- - - - -
963887b3 by Fatih Uzunoglu at 2025-02-03T05:57:43+00:00
qml: add required property `model` to `MusicArtist` header delegate

This fixes delegate can not be loaded issue with Qt 6.2.

- - - - -


5 changed files:

- modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -42,7 +42,22 @@ MainViewLoader {
     property alias sortOrder: artistModel.sortOrder
     property alias sortCriteria: artistModel.sortCriteria
 
-    signal requestArtistAlbumView(var id, int reason)
+    signal artistAlbumViewRequested(var id, int reason)
+
+    function requestArtistAlbumView(reason: int, id = null) {
+        if (id !== null) {
+            console.assert(id !== undefined)
+            artistAlbumViewRequested(id, reason)
+        } else {
+            // Do not call this function if there is no current item,
+            // and you are not providing an explicit id:
+            console.assert(currentIndex >= 0)
+            // Do not call this function if there is no model:
+            console.assert(root.model)
+            const data = root.model.getDataAt(currentIndex)
+            artistAlbumViewRequested(data.id, reason)
+        }
+    }
 
     isSearchable: true
 
@@ -98,9 +113,7 @@ MainViewLoader {
                     artistModel.addAndPlay( selectionModel.selectedIndexes )
                 } else {
                     currentIndex = index
-                    const sel = selectionModel.selectedIndexes[0]
-                    const model = genreModel.getDataAt(sel)
-                    requestArtistAlbumView(model.id, Qt.TabFocusReason)
+                    root.requestArtistAlbumView(Qt.TabFocusReason)
                 }
             }
 
@@ -126,7 +139,7 @@ MainViewLoader {
 
                 onItemClicked: (modifier) => { artistGrid.leftClickOnItem(modifier, index) }
 
-                onItemDoubleClicked: root.requestArtistAlbumView(model.id, Qt.MouseFocusReason)
+                onItemDoubleClicked: root.requestArtistAlbumView(Qt.MouseFocusReason, model.id)
 
                 onContextMenuButtonClicked: (_, globalMousePos) => {
                     artistGrid.rightClickOnItem(index)
@@ -204,7 +217,9 @@ MainViewLoader {
             sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
                                                                   : _modelMedium
 
-            onItemDoubleClicked: root.requestArtistAlbumView(Qt.MouseFocusReason)
+            onItemDoubleClicked: function(index, model) {
+                root.requestArtistAlbumView(Qt.MouseFocusReason, model.id)
+            }
 
             onContextMenuButtonClicked: (_,_, globalMousePos) => {
                 contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)


=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -192,6 +192,8 @@ FocusScope {
                         delegate: Widgets.GridItem {
                             id: gridItem
 
+                            required property var model
+
                             y: selectedBorderWidth
 
                             width: gridHelper.cellWidth


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
=====================================
@@ -99,7 +99,7 @@ T.ItemDelegate {
 
                 if (!(root.selected && button === Qt.RightButton)) {
                     view.selectionModel.updateSelection(point.modifiers, view.currentIndex, index)
-                    view.showArtist(model.id)
+                    view.currentIndex = root.index
                 }
             }
 
@@ -126,7 +126,7 @@ T.ItemDelegate {
                     if (active) {
                         if (!selected) {
                             view.selectionModel.select(index, ItemSelectionModel.ClearAndSelect)
-                            view.showArtist(model.id)
+                            view.currentIndex = root.index
                         }
 
                         target.Drag.active = true


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -78,8 +78,6 @@ FocusScope {
 
         if (model.count === 0 || initialIndex === -1) return
 
-        selectionModel.select(model.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
-
         artistList.positionViewAtIndex(initialIndex, ItemView.Contain)
 
         artistList.setCurrentItem(initialIndex)
@@ -142,8 +140,6 @@ FocusScope {
 
             property bool _sidebarInitialyPositioned: false
 
-            signal showArtist(var artistid)
-
             model: artistModel
             selectionModel: root.selectionModel
             currentIndex: -1
@@ -168,11 +164,6 @@ FocusScope {
                 root.artistId = model.getDataAt(currentIndex).id
             }
 
-            onShowArtist: (artistId) => {
-                root.artistId = artistId
-            }
-
-
             Widgets.AcrylicBackground {
                 id: artistListBackground
 


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
=====================================
@@ -59,7 +59,7 @@ Widgets.PageLoader {
 
             onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
 
-            onRequestArtistAlbumView: (id, reason) => {
+            onArtistAlbumViewRequested: (id, reason) => {
                 History.push([...root.pagePrefix, "albums"], { artistId: id  }, reason)
             }
         }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/892cf45208f4b96a7d8628ed9952f6b04396cc14...963887b36b42d2ef8513587243c0faad06e19110

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/892cf45208f4b96a7d8628ed9952f6b04396cc14...963887b36b42d2ef8513587243c0faad06e19110
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