[vlc-commits] [Git][videolan/vlc][master] 3 commits: qml: add missing required property

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Feb 23 15:11:35 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
8f7d4ad0 by Prince Gupta at 2025-02-23T14:58:17+00:00
qml: add missing required property

- - - - -
84c4974f by Prince Gupta at 2025-02-23T14:58:17+00:00
qml: support context menu click in artist list view

- - - - -
9ab6e688 by Prince Gupta at 2025-02-23T14:58:17+00:00
qml: fix initial selection and optimize selection handling in artist list view

- - - - -


1 changed file:

- modules/gui/qt/medialibrary/qml/MusicArtist.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -193,6 +193,7 @@ FocusScope {
                             id: gridItem
 
                             required property var model
+                            required property int index
 
                             y: selectedBorderWidth
 
@@ -211,6 +212,11 @@ FocusScope {
                             textAlignHCenter: true
                             dragItem: albumDragItem
 
+                            // updates to selection is manually handled for optimization purpose
+                            Component.onCompleted: _updateSelected()
+
+                            onIndexChanged: _updateSelected()
+
                             onPlayClicked: play()
                             onItemDoubleClicked: play()
 
@@ -223,16 +229,33 @@ FocusScope {
                             Connections {
                                 target: albumsList.selectionModel
 
-                                function onSelectionChanged() {
-                                    gridItem.selected = albumsList.selectionModel.isSelected(index)
+                                function onSelectionChanged(selected, deselected) {
+                                    const idx = albumModel.index(gridItem.index, 0)
+                                    const findInSelection = s => s.find(range => range.contains(idx)) !== undefined
+
+                                    // NOTE: we only get diff of the selection
+                                    if (findInSelection(selected))
+                                        gridItem.selected = true
+                                    else if (findInSelection(deselected))
+                                        gridItem.selected = false
                                 }
                             }
 
+                            onContextMenuButtonClicked: (_, globalMousePos) => {
+                                albumSelectionModel.updateSelection( Qt.NoModifier , albumsList.currentIndex, index )
+                                contextMenu.popup(albumSelectionModel.selectedIndexes
+                                                  , globalMousePos)
+                            }
+
                             function play() {
                                 if ( model.id !== undefined ) {
                                     MediaLib.addAndPlay( model.id )
                                 }
                             }
+
+                            function _updateSelected() {
+                                selected = albumSelectionModel.isRowSelected(gridItem.index)
+                            }
                         }
 
                         onActionAtIndex: (index) => { albumModel.addAndPlay( new Array(index) ) }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/62dc35f62b62637add0b845a8ddbfeb5d885977c...9ab6e688c7a4b30f3f97e908e905386c32e1a707

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/62dc35f62b62637add0b845a8ddbfeb5d885977c...9ab6e688c7a4b30f3f97e908e905386c32e1a707
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