[vlc-commits] qml: add drag and drop support in MusicArtistDisplay

Prince Gupta git at videolan.org
Thu Dec 10 09:34:55 UTC 2020


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Fri Nov 13 14:22:30 2020 +0530| [1dec7db7039130c621caffaac199487ba3e05e54] | committer: Pierre Lamot

qml: add drag and drop support in MusicArtistDisplay

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1dec7db7039130c621caffaac199487ba3e05e54
---

 .../qt/medialibrary/qml/MusicArtistsDisplay.qml    | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
index 48ff1b7a03..1e5d3797cd 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
@@ -107,6 +107,27 @@ Widgets.PageLoader {
                 model: artistModel
             }
 
+            Widgets.DragItem {
+                id: artistsDragItem
+
+                function updateComponents(maxCovers) {
+                  var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
+                    return artistModel.getDataAt(x.row)
+                  })
+                  var title = items.map(function (item){ return item.name}).join(", ")
+                  var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtArtistSmall}})
+                  return {
+                    covers: covers,
+                    title: title,
+                    count: selectionModel.selectedIndexes.length
+                  }
+                }
+
+                function insertIntoPlaylist(index) {
+                    medialib.insertIntoPlaylist(index, artistModel.getIdsForIndexes(selectionModel.selectedIndexes))
+                }
+            }
+
             ArtistContextMenu {
                 id: contextMenu
                 model: artistModel
@@ -152,6 +173,7 @@ Widgets.PageLoader {
                         playIconSize: VLCStyle.play_cover_small
                         textHorizontalAlignment: Text.AlignHCenter
                         width: VLCStyle.colWidth(1)
+                        dragItem: artistsDragItem
 
                         onItemClicked: artistGrid.leftClickOnItem(modifier, index)
 
@@ -181,6 +203,7 @@ Widgets.PageLoader {
                     focus: true
                     headerColor: VLCStyle.colors.bg
                     navigationParent: root
+                    dragItem: artistsDragItem
 
                     onActionForSelection: {
                         if (selection.length > 1) {



More information about the vlc-commits mailing list