[vlc-commits] [Git][videolan/vlc][master] 5 commits: qml: refactor MusicAllArtists view in separate file

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Jul 30 08:24:59 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
6bdc64f4 by Prince Gupta at 2021-07-30T08:03:16+00:00
qml: refactor MusicAllArtists view in separate file

- - - - -
712e5f2d by Prince Gupta at 2021-07-30T08:03:16+00:00
qml/MusicArtistsAlbums: fix identation

- - - - -
e0e7911a by Prince Gupta at 2021-07-30T08:03:16+00:00
qml: use AnimatedBackground in Artist list

- - - - -
b23f655d by Prince Gupta at 2021-07-30T08:03:16+00:00
qml/MusicArtistsAlbums: support drag to playlist of Music Artists

- - - - -
fe12285f by Prince Gupta at 2021-07-30T08:03:16+00:00
qml: implement drag support in MusicTrackListDisplay

replaces drag support from MusicTracksDisplay. This way it can be reused
in places where MusicTrackListDisplay is used like in expand delegates

- - - - -


8 changed files:

- modules/gui/qt/Makefile.am
- + modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
- modules/gui/qt/vlc.qrc
- po/POTFILES.in


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -690,6 +690,7 @@ libqt_plugin_la_QML = \
 	gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml \
 	gui/qt/medialibrary/qml/MusicArtist.qml \
 	gui/qt/medialibrary/qml/MusicArtistsAlbums.qml \
+	gui/qt/medialibrary/qml/MusicAllArtists.qml \
 	gui/qt/medialibrary/qml/MusicArtistsDisplay.qml \
 	gui/qt/medialibrary/qml/MusicDisplay.qml \
 	gui/qt/medialibrary/qml/MusicGenres.qml \


=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -0,0 +1,253 @@
+/*****************************************************************************
+ * Copyright (C) 2021 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+import QtQuick.Controls 2.4
+import QtQuick 2.11
+import QtQml.Models 2.2
+import QtQuick.Layouts 1.3
+
+import org.videolan.medialib 0.1
+import org.videolan.vlc 0.1
+
+import "qrc:///util/" as Util
+import "qrc:///widgets/" as Widgets
+import "qrc:///main/" as MainInterface
+import "qrc:///style/"
+
+FocusScope {
+    id: root
+
+    readonly property int currentIndex: view.currentItem.currentIndex
+    property int initialIndex: 0
+    property alias model: artistModel
+
+    onInitialIndexChanged: resetFocus()
+
+    function requestArtistAlbumView() {
+        console.assert(false, "must be reimplemented")
+    }
+
+    function resetFocus() {
+        if (artistModel.count === 0)
+            return
+
+        var initialIndex = root.initialIndex
+        if (initialIndex >= artistModel.count)
+            initialIndex = 0
+        selectionModel.select(artistModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
+        if (view.currentItem) {
+            view.currentItem.currentIndex = initialIndex
+            view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
+        }
+    }
+
+    function _onNavigationCancel() {
+        if (view.currentItem.currentIndex <= 0) {
+            root.Navigation.defaultNavigationCancel()
+        } else {
+            view.currentItem.currentIndex = 0;
+            view.currentItem.positionViewAtIndex(0, ItemView.Contain);
+        }
+    }
+
+    MLArtistModel {
+        id: artistModel
+        ml: medialib
+
+        onCountChanged: {
+            if (artistModel.count > 0 && !selectionModel.hasSelection) {
+                root.resetFocus()
+            }
+        }
+    }
+
+    Util.SelectableDelegateModel {
+        id: selectionModel
+        model: artistModel
+    }
+
+    ArtistContextMenu {
+        id: contextMenu
+        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 getSelectedInputItem() {
+            return artistModel.getItemsForIndexes(selectionModel.selectedIndexes);
+        }
+    }
+
+    Component {
+        id: gridComponent
+
+        MainInterface.MainGridView {
+            id: artistGrid
+
+            anchors.fill: parent
+            topMargin: VLCStyle.margin_large
+            delegateModel: selectionModel
+            model: artistModel
+            focus: true
+            cellWidth: VLCStyle.colWidth(1)
+            cellHeight: VLCStyle.gridItem_music_height
+
+            Navigation.parentItem: root
+            Navigation.cancelAction: root._onNavigationCancel
+
+            onSelectAll: selectionModel.selectAll()
+            onSelectionUpdated: selectionModel.updateSelection( keyModifiers, oldIndex, newIndex )
+            onActionAtIndex: {
+                if (selectionModel.selectedIndexes.length > 1) {
+                    medialib.addAndPlay( artistModel.getIdsForIndexes( selectionModel.selectedIndexes ) )
+                } else {
+                    view.currentItem.currentIndex = index
+                    requestArtistAlbumView()
+                    medialib.addAndPlay( artistModel.getIdForIndex(index) )
+                }
+            }
+
+            Widgets.GridShadows {
+                id: shadows
+
+                leftPadding: (VLCStyle.colWidth(1) - shadows.coverWidth) / 2 // GridItem's rect is horizontally centered
+                coverWidth: VLCStyle.artistGridCover_radius
+                coverHeight: VLCStyle.artistGridCover_radius
+                coverRadius: VLCStyle.artistGridCover_radius
+            }
+
+            delegate: AudioGridItem {
+                id: gridItem
+
+                title: model.name || i18n.qtr("Unknown artist")
+                subtitle: model.nb_tracks > 1 ? i18n.qtr("%1 songs").arg(model.nb_tracks) : i18n.qtr("%1 song").arg(model.nb_tracks)
+                pictureRadius: VLCStyle.artistGridCover_radius
+                pictureHeight: VLCStyle.artistGridCover_radius
+                pictureWidth: VLCStyle.artistGridCover_radius
+                playCoverBorderWidth: VLCStyle.dp(3, VLCStyle.scale)
+                titleMargin: VLCStyle.margin_xlarge
+                playIconSize: VLCStyle.play_cover_small
+                textAlignHCenter: true
+                width: VLCStyle.colWidth(1)
+                dragItem: artistsDragItem
+                unselectedUnderlay: shadows.unselected
+                selectedUnderlay: shadows.selected
+
+
+                onItemClicked: artistGrid.leftClickOnItem(modifier, index)
+
+                onItemDoubleClicked: root.requestArtistAlbumView(model)
+
+                onContextMenuButtonClicked: {
+                    artistGrid.rightClickOnItem(index)
+                    contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
+                }
+            }
+        }
+    }
+
+
+    Component {
+        id: tableComponent
+
+        MainInterface.MainTableView {
+            id: artistTable
+
+            readonly property int _nbCols: VLCStyle.gridColumnsForWidth(artistTable.availableRowWidth)
+
+            anchors.fill: parent
+            selectionDelegateModel: selectionModel
+            model: artistModel
+            focus: true
+            headerColor: VLCStyle.colors.bg
+            dragItem: artistsDragItem
+            rowHeight: VLCStyle.tableCoverRow_height
+            headerTopPadding: VLCStyle.margin_normal
+
+            Navigation.parentItem: root
+            Navigation.cancelAction: root._onNavigationCancel
+
+            onActionForSelection: {
+                if (selection.length > 1) {
+                    medialib.addAndPlay( artistModel.getIdsForIndexes( selection ) )
+                } else if ( selection.length === 1) {
+                    requestArtistAlbumView()
+                    medialib.addAndPlay( artistModel.getIdForIndex( selection[0] ) )
+                }
+            }
+
+            sortModel:  [
+                { isPrimary: true, criteria: "name", width: VLCStyle.colWidth(Math.max(artistTable._nbCols - 1, 1)), text: i18n.qtr("Name"), headerDelegate: tableColumns.titleHeaderDelegate, colDelegate: tableColumns.titleDelegate },
+                { criteria: "nb_tracks", width: VLCStyle.colWidth(1), text: i18n.qtr("Tracks") }
+            ]
+
+            onItemDoubleClicked: {
+                root.requestArtistAlbumView(model)
+            }
+            onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, menuParent.mapToGlobal(0,0))
+            onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
+
+            Widgets.TableColumns {
+                id: tableColumns
+            }
+        }
+    }
+
+    Widgets.StackViewExt {
+        id: view
+
+        anchors.fill: parent
+        visible: artistModel.count > 0
+        focus: artistModel.count > 0
+        initialItem: mainInterface.gridView ? gridComponent : tableComponent
+    }
+
+    Connections {
+        target: mainInterface
+        onGridViewChanged: {
+            if (mainInterface.gridView) {
+                view.replace(gridComponent)
+            } else {
+                view.replace(tableComponent)
+            }
+        }
+    }
+
+    EmptyLabel {
+        anchors.fill: parent
+        visible: artistModel.count === 0
+        focus: artistModel.count === 0
+        text: i18n.qtr("No artists found\nPlease try adding sources, by going to the Network tab")
+        Navigation.parentItem: root
+        cover: VLCStyle.noArtArtistCover
+    }
+}


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -97,151 +97,185 @@ FocusScope {
         focus: visible
         anchors.fill: parent
 
-    Rectangle {
-        width: artistList.width
-        height: artistList.height
-        color: VLCStyle.colors.bgAlt
-        opacity: .8
-    }
+        Rectangle {
+            width: artistList.width
+            height: artistList.height
+            color: VLCStyle.colors.bgAlt
+            opacity: .8
+        }
 
-    Row {
-        anchors.fill: parent
+        Row {
+            anchors.fill: parent
+
+            Widgets.KeyNavigableListView {
+                id: artistList
+
+                spacing: 4
+                model: artistModel
+                currentIndex: -1
+                z: 1
+                height: parent.height
+                width: Helpers.clamp(root.width / resizeHandle.widthFactor,
+                                     VLCStyle.colWidth(1) + VLCStyle.column_margin_width,
+                                     root.width * .5)
+
+                focus: true
+                displayMarginEnd: miniPlayer.height // to get blur effect while scrolling in mainview
+                Navigation.parentItem: root
+                Navigation.rightItem: albumSubView
+                Navigation.cancelAction: function() {
+                    if (artistList.currentIndex <= 0)
+                        root.Navigation.defaultNavigationCancel()
+                    else
+                        artistList.currentIndex = 0;
+                }
 
-        Widgets.KeyNavigableListView {
-            id: artistList
-
-            spacing: 4
-            model: artistModel
-            currentIndex: -1
-            z: 1
-            height: parent.height
-            width: Helpers.clamp(root.width / resizeHandle.widthFactor,
-                                 VLCStyle.colWidth(1) + VLCStyle.column_margin_width,
-                                 root.width * .5)
-
-            focus: true
-            displayMarginEnd: miniPlayer.height // to get blur effect while scrolling in mainview
-            Navigation.parentItem: root
-            Navigation.rightItem: albumSubView
-            Navigation.cancelAction: function() {
-                if (artistList.currentIndex <= 0)
-                    root.Navigation.defaultNavigationCancel()
-                else
-                    artistList.currentIndex = 0;
-            }
+                header: Widgets.SubtitleLabel {
+                    text: i18n.qtr("Artists")
+                    font.pixelSize: VLCStyle.fontSize_large
+                    leftPadding: VLCStyle.margin_normal
+                    bottomPadding: VLCStyle.margin_small
+                    topPadding: VLCStyle.margin_xlarge
+                }
 
-            header: Widgets.SubtitleLabel {
-                text: i18n.qtr("Artists")
-                font.pixelSize: VLCStyle.fontSize_large
-                leftPadding: VLCStyle.margin_normal
-                bottomPadding: VLCStyle.margin_small
-                topPadding: VLCStyle.margin_xlarge
-            }
+                delegate: Widgets.AnimatedBackground {
+                    id: item
 
-            delegate: Rectangle {
-                id: item
+                    property bool _highlighted: mouseArea.containsMouse || this.activeFocus
 
-                property bool _highlighted: mouseArea.containsMouse || this.activeFocus
+                    height: VLCStyle.play_cover_small + (VLCStyle.margin_xsmall * 2)
+                    width: artistList.width
+                    active: false
+                    backgroundColor: _highlighted ? VLCStyle.colors.bgHover : "transparent"
+                    foregroundColor: _highlighted ? VLCStyle.colors.bgHoverText : VLCStyle.colors.text
 
-                height: VLCStyle.play_cover_small + (VLCStyle.margin_xsmall * 2)
-                width: artistList.width
-                color: _highlighted ? VLCStyle.colors.bgHover : "transparent"
+                    Widgets.CurrentIndicator {
+                       visible: item.ListView.isCurrentItem
+                    }
 
-                Widgets.CurrentIndicator {
-                   visible: item.ListView.isCurrentItem
-                }
+                    RowLayout {
+                        spacing: VLCStyle.margin_xsmall
+                        anchors {
+                            fill: parent
+                            leftMargin: VLCStyle.margin_normal
+                            rightMargin: VLCStyle.margin_normal
+                            topMargin: VLCStyle.margin_xsmall
+                            bottomMargin: VLCStyle.margin_xsmall
+                        }
 
-                RowLayout {
-                    spacing: VLCStyle.margin_xsmall
-                    anchors {
-                        fill: parent
-                        leftMargin: VLCStyle.margin_normal
-                        rightMargin: VLCStyle.margin_normal
-                        topMargin: VLCStyle.margin_xsmall
-                        bottomMargin: VLCStyle.margin_xsmall
-                    }
+                        RoundImage {
+                            source: model.cover || VLCStyle.noArtArtistSmall
+                            height: VLCStyle.play_cover_small
+                            width: VLCStyle.play_cover_small
+                            radius: VLCStyle.play_cover_small
 
-                    RoundImage {
-                        source: model.cover || VLCStyle.noArtArtistSmall
-                        height: VLCStyle.play_cover_small
-                        width: VLCStyle.play_cover_small
-                        radius: VLCStyle.play_cover_small
+                            Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
 
-                        Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
+                            Rectangle {
+                                anchors.fill: parent
+                                color: "transparent"
+                                radius: VLCStyle.play_cover_small
+                                border.width: VLCStyle.dp(1, VLCStyle.scale)
+                                border.color: !_highlighted ? VLCStyle.colors.roundPlayCoverBorder : VLCStyle.colors.accent
+                            }
+                        }
 
-                        Rectangle {
-                            anchors.fill: parent
-                            color: "transparent"
-                            radius: VLCStyle.play_cover_small
-                            border.width: VLCStyle.dp(1, VLCStyle.scale)
-                            border.color: !_highlighted ? VLCStyle.colors.roundPlayCoverBorder : VLCStyle.colors.accent
+                        Widgets.ListLabel {
+                            text: model.name || i18n.qtr("Unknown artist")
+                            color: item.foregroundColor
+
+                            Layout.fillWidth: true
+                            Layout.fillHeight: true
                         }
                     }
 
-                    Widgets.ListLabel {
-                        text: model.name || i18n.qtr("Unknown artist")
-                        color: _highlighted ? VLCStyle.colors.bgHoverText : VLCStyle.colors.text
+                    MouseArea {
+                        id: mouseArea
 
-                        Layout.fillWidth: true
-                        Layout.fillHeight: true
-                    }
-                }
+                        anchors.fill: parent
+                        hoverEnabled: true
 
-                MouseArea {
-                    id: mouseArea
+                        onClicked: {
+                            selectionModel.updateSelection( mouse.modifiers , artistList.currentIndex, index)
+                            artistList.currentIndex = index
+                            artistList.forceActiveFocus()
+                        }
 
-                    anchors.fill: parent
-                    hoverEnabled: true
+                        onDoubleClicked: {
+                            if (mouse.buttons === Qt.LeftButton)
+                                medialib.addAndPlay( model.id )
+                            else
+                                albumSubView.forceActiveFocus()
+                        }
 
-                    onClicked: {
-                        selectionModel.updateSelection( mouse.modifiers , artistList.currentIndex, index)
-                        artistList.currentIndex = index
-                        artistList.forceActiveFocus()
-                    }
+                        drag.axis: Drag.XAndYAxis
+                        drag.target: Widgets.DragItem {
+                            function updateComponents(maxCovers) {
+                                return {
+                                    covers: [{artwork: model.cover || VLCStyle.noArtArtistSmall}],
+                                    title: model.name || i18n.qtr("Unknown artist"),
+                                    count: 1
+                                }
+                            }
+
+                            function getSelectedInputItem() {
+                                return artistModel.getItemsForIndexes([artistModel.index(index, 0)])
+                            }
+                        }
+
+                        drag.onActiveChanged: {
+                            var dragItem = drag.target
 
-                    onDoubleClicked: {
-                        if (mouse.buttons === Qt.LeftButton)
-                            medialib.addAndPlay( model.id )
-                        else
-                            albumSubView.forceActiveFocus()
+                            if (!drag.active)
+                                dragItem.Drag.drop()
+
+                            dragItem.Drag.active = drag.active
+                        }
+
+                        onPositionChanged: {
+                            if (drag.active) {
+                                var pos = drag.target.parent.mapFromItem(item, mouseX, mouseY)
+                                drag.target.x = pos.x + 12
+                                drag.target.y = pos.y + 12
+                            }
+                        }
                     }
                 }
-            }
 
-            Behavior on width {
-                SmoothedAnimation {
-                    easing.type: Easing.InSine
-                    duration: VLCStyle.ms10
+                Behavior on width {
+                    SmoothedAnimation {
+                        easing.type: Easing.InSine
+                        duration: VLCStyle.ms10
+                    }
                 }
-            }
 
-            Widgets.HorizontalResizeHandle {
-                id: resizeHandle
+                Widgets.HorizontalResizeHandle {
+                    id: resizeHandle
 
-                anchors {
-                    top: parent.top
-                    bottom: parent.bottom
-                    right: parent.right
+                    anchors {
+                        top: parent.top
+                        bottom: parent.bottom
+                        right: parent.right
 
-                    rightMargin: -(width / 2)
+                        rightMargin: -(width / 2)
+                    }
+                    sourceWidth: root.width
+                    targetWidth: artistList.width
                 }
-                sourceWidth: root.width
-                targetWidth: artistList.width
             }
-        }
 
-        MusicArtist {
-            id: albumSubView
+            MusicArtist {
+                id: albumSubView
 
-            height: parent.height
-            width: root.width - artistList.width
-            focus: true
-            initialIndex: root.initialAlbumIndex
-            Navigation.parentItem: root
-            Navigation.leftItem: artistList
+                height: parent.height
+                width: root.width - artistList.width
+                focus: true
+                initialIndex: root.initialAlbumIndex
+                Navigation.parentItem: root
+                Navigation.leftItem: artistList
+            }
         }
     }
-    }
 
     EmptyLabel {
         anchors.fill: parent


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
=====================================
@@ -37,7 +37,7 @@ Widgets.PageLoader {
     defaultPage: "all"
     pageModel: [{
         name: "all",
-        component: artistGridComponent
+        component: allArtistsComponent
     }, {
         name: "albums",
         component: artistAlbumsComponent
@@ -59,240 +59,20 @@ Widgets.PageLoader {
     }
 
     Component {
-        id: artistGridComponent
+        id: allArtistsComponent
 
-        FocusScope {
-            id: artistAllView
+        MusicAllArtists {
+            onCurrentIndexChanged: _updateArtistsAllHistory(currentIndex)
 
-            readonly property int currentIndex: view.currentItem.currentIndex
-            property int initialIndex: 0
-            property alias model: artistModel
-
-            onCurrentIndexChanged: {
-                _updateArtistsAllHistory(currentIndex)
-            }
-
-            onInitialIndexChanged: resetFocus()
-
-            function showAlbumView() {
-                history.push([ "mc", "music", "artists", "albums", { initialIndex: artistAllView.currentIndex } ])
-            }
-
-            function resetFocus() {
-                if (artistModel.count === 0) {
-                    return
-                }
-                var initialIndex = artistAllView.initialIndex
-                if (initialIndex >= artistModel.count)
-                    initialIndex = 0
-                selectionModel.select(artistModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
-                if (view.currentItem) {
-                    view.currentItem.currentIndex = initialIndex
-                    view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
-                }
-            }
-
-            function _onNavigationCancel() {
-                if (view.currentItem.currentIndex <= 0) {
-                    artistAllView.Navigation.defaultNavigationCancel()
-                } else {
-                    view.currentItem.currentIndex = 0;
-                    view.currentItem.positionViewAtIndex(0, ItemView.Contain);
-                }
-            }
-
-            MLArtistModel {
-                id: artistModel
-                ml: medialib
-
-                onCountChanged: {
-                    if (artistModel.count > 0 && !selectionModel.hasSelection) {
-                        artistAllView.resetFocus()
-                    }
-                }
-            }
-
-            Util.SelectableDelegateModel {
-                id: selectionModel
-                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 getSelectedInputItem() {
-                    return artistModel.getItemsForIndexes(selectionModel.selectedIndexes);
-                }
-            }
-
-            ArtistContextMenu {
-                id: contextMenu
-                model: artistModel
-            }
-
-            Component {
-                id: gridComponent
-
-                MainInterface.MainGridView {
-                    id: artistGrid
-
-                    anchors.fill: parent
-                    topMargin: VLCStyle.margin_large
-                    delegateModel: selectionModel
-                    model: artistModel
-                    focus: true
-                    cellWidth: VLCStyle.colWidth(1)
-                    cellHeight: VLCStyle.gridItem_music_height
-
-                    Navigation.parentItem: root
-                    Navigation.cancelAction: artistAllView._onNavigationCancel
-
-                    onSelectAll: selectionModel.selectAll()
-                    onSelectionUpdated: selectionModel.updateSelection( keyModifiers, oldIndex, newIndex )
-                    onActionAtIndex: {
-                        if (selectionModel.selectedIndexes.length > 1) {
-                            medialib.addAndPlay( artistModel.getIdsForIndexes( selectionModel.selectedIndexes ) )
-                        } else {
-                            view.currentItem.currentIndex = index
-                            showAlbumView()
-                            medialib.addAndPlay( artistModel.getIdForIndex(index) )
-                        }
-                    }
-
-                    Widgets.GridShadows {
-                        id: shadows
-
-                        leftPadding: (VLCStyle.colWidth(1) - shadows.coverWidth) / 2 // GridItem's rect is horizontally centered
-                        coverWidth: VLCStyle.artistGridCover_radius
-                        coverHeight: VLCStyle.artistGridCover_radius
-                        coverRadius: VLCStyle.artistGridCover_radius
-                    }
-
-                    delegate: AudioGridItem {
-                        id: gridItem
-
-                        title: model.name || i18n.qtr("Unknown artist")
-                        subtitle: model.nb_tracks > 1 ? i18n.qtr("%1 songs").arg(model.nb_tracks) : i18n.qtr("%1 song").arg(model.nb_tracks)
-                        pictureRadius: VLCStyle.artistGridCover_radius
-                        pictureHeight: VLCStyle.artistGridCover_radius
-                        pictureWidth: VLCStyle.artistGridCover_radius
-                        playCoverBorderWidth: VLCStyle.dp(3, VLCStyle.scale)
-                        titleMargin: VLCStyle.margin_xlarge
-                        playIconSize: VLCStyle.play_cover_small
-                        textAlignHCenter: true
-                        width: VLCStyle.colWidth(1)
-                        dragItem: artistsDragItem
-                        unselectedUnderlay: shadows.unselected
-                        selectedUnderlay: shadows.selected
-
-
-                        onItemClicked: artistGrid.leftClickOnItem(modifier, index)
-
-                        onItemDoubleClicked: artistAllView.showAlbumView(model)
-
-                        onContextMenuButtonClicked: {
-                            artistGrid.rightClickOnItem(index)
-                            contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
-                        }
-                    }
-                }
-            }
-
-
-
-            Component {
-                id: tableComponent
-
-                MainInterface.MainTableView {
-                    id: artistTable
-
-                    readonly property int _nbCols: VLCStyle.gridColumnsForWidth(artistTable.availableRowWidth)
-
-                    anchors.fill: parent
-                    selectionDelegateModel: selectionModel
-                    model: artistModel
-                    focus: true
-                    headerColor: VLCStyle.colors.bg
-                    dragItem: artistsDragItem
-                    rowHeight: VLCStyle.tableCoverRow_height
-                    headerTopPadding: VLCStyle.margin_normal
-
-                    Navigation.parentItem: root
-                    Navigation.cancelAction: artistAllView._onNavigationCancel
-
-                    onActionForSelection: {
-                        if (selection.length > 1) {
-                            medialib.addAndPlay( artistModel.getIdsForIndexes( selection ) )
-                        } else {
-                            showAlbumView()
-                            medialib.addAndPlay( artistModel.getIdForIndex(index) )
-                        }
-                    }
-
-                    sortModel:  [
-                        { isPrimary: true, criteria: "name", width: VLCStyle.colWidth(Math.max(artistTable._nbCols - 1, 1)), text: i18n.qtr("Name"), headerDelegate: tableColumns.titleHeaderDelegate, colDelegate: tableColumns.titleDelegate },
-                        { criteria: "nb_tracks", width: VLCStyle.colWidth(1), text: i18n.qtr("Tracks") }
-                    ]
-
-                    onItemDoubleClicked: {
-                        artistAllView.showAlbumView(model)
-                    }
-                    onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, menuParent.mapToGlobal(0,0))
-                    onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
-
-                    Widgets.TableColumns {
-                        id: tableColumns
-                    }
-                }
-            }
-
-            Widgets.StackViewExt {
-                id: view
-
-                anchors.fill: parent
-                visible: artistModel.count > 0
-                focus: artistModel.count > 0
-                initialItem: mainInterface.gridView ? gridComponent : tableComponent
-            }
-
-            Connections {
-                target: mainInterface
-                onGridViewChanged: {
-                    if (mainInterface.gridView) {
-                        view.replace(gridComponent)
-                    } else {
-                        view.replace(tableComponent)
-                    }
-                }
-            }
-
-            EmptyLabel {
-                anchors.fill: parent
-                visible: artistModel.count === 0
-                focus: artistModel.count === 0
-                text: i18n.qtr("No artists found\nPlease try adding sources, by going to the Network tab")
-                Navigation.parentItem: root
-                cover: VLCStyle.noArtArtistCover
+            function requestArtistAlbumView() /* override */ {
+                history.push([ "mc", "music", "artists", "albums", { initialIndex: currentIndex } ])
             }
         }
     }
 
     Component {
         id: artistAlbumsComponent
-        /* List View */
+
         MusicArtistsAlbums {
 
             Navigation.parentItem: root


=====================================
modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
=====================================
@@ -71,6 +71,26 @@ Widgets.KeyNavigableTableView {
     onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, menuParent.mapToGlobal(0,0))
     onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
 
+    dragItem: Widgets.DragItem {
+
+        function updateComponents(maxCovers) {
+          var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
+            return model.getDataAt(x.row)
+          })
+          var title = items.map(function (item){ return item.title}).join(", ")
+          var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtCover}})
+          return {
+            covers: covers,
+            title: title,
+            count: selectionModel.selectedIndexes.length
+          }
+        }
+
+        function getSelectedInputItem() {
+            return model.getItemsForIndexes(selectionModel.selectedIndexes);
+        }
+
+    }
 
     Widgets.TableColumns {
         id: tableColumns


=====================================
modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
=====================================
@@ -26,38 +26,18 @@ import "qrc:///main/" as MainInterface
 
 FocusScope {
     id: root
+
     property alias sortModel: tracklistdisplay_id.sortModel
     property alias model: tracklistdisplay_id.model
     property alias selectionModel: tracklistdisplay_id.selectionDelegateModel
     readonly property bool isViewMultiView: false
 
-    Widgets.DragItem {
-        id: trackDragItem
-
-        function updateComponents(maxCovers) {
-          var items = selectionModel.selectedIndexes.slice(0, maxCovers).map(function (x){
-            return model.getDataAt(x.row)
-          })
-          var title = items.map(function (item){ return item.title}).join(", ")
-          var covers = items.map(function (item) { return {artwork: item.cover || VLCStyle.noArtCover}})
-          return {
-            covers: covers,
-            title: title,
-            count: selectionModel.selectedIndexes.length
-          }
-        }
-
-        function getSelectedInputItem() {
-            return model.getItemsForIndexes(selectionModel.selectedIndexes);
-        }
-    }
-
     MusicTrackListDisplay {
         id: tracklistdisplay_id
+
         anchors.fill: parent
         visible: model.count > 0
         focus: model.count > 0
-        dragItem: trackDragItem
         headerTopPadding: VLCStyle.margin_normal
         Navigation.parentItem: root
         Navigation.cancelAction: function() {


=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -290,6 +290,7 @@
         <file alias="MusicAlbumsGridExpandDelegate.qml">medialibrary/qml/MusicAlbumsGridExpandDelegate.qml</file>
         <file alias="MusicArtist.qml">medialibrary/qml/MusicArtist.qml</file>
         <file alias="MusicArtistsAlbums.qml">medialibrary/qml/MusicArtistsAlbums.qml</file>
+        <file alias="MusicAllArtists.qml">medialibrary/qml/MusicAllArtists.qml</file>
         <file alias="MusicArtistsDisplay.qml">medialibrary/qml/MusicArtistsDisplay.qml</file>
         <file alias="MusicGenresDisplay.qml">medialibrary/qml/MusicGenresDisplay.qml</file>
         <file alias="MusicPlaylistsDisplay.qml">medialibrary/qml/MusicPlaylistsDisplay.qml</file>


=====================================
po/POTFILES.in
=====================================
@@ -828,6 +828,7 @@ modules/gui/qt/medialibrary/qml/MusicAlbums.qml
 modules/gui/qt/medialibrary/qml/MusicAlbumsDisplay.qml
 modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
 modules/gui/qt/medialibrary/qml/MusicArtist.qml
+modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
 modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
 modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
 modules/gui/qt/medialibrary/qml/MusicDisplay.qml



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8bf4d27263fe957c91655aa0724116830d665c87...fe12285fa6378fff640599043a7f187e09feb988

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8bf4d27263fe957c91655aa0724116830d665c87...fe12285fa6378fff640599043a7f187e09feb988
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list