[vlc-devel] [PATCH 16/17] qml: Create MusicPlaylistsDisplay

Benjamin Arnaud benjamin.arnaud at videolabs.io
Fri Feb 19 10:25:40 UTC 2021


---
 modules/gui/qt/Makefile.am                    |   1 +
 .../qml/MusicPlaylistsDisplay.qml             | 115 ++++++++++++++++++
 modules/gui/qt/vlc.qrc                        |   1 +
 po/POTFILES.in                                |   1 +
 4 files changed, 118 insertions(+)
 create mode 100644 modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 1869d8adb4..3508c9e561 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -660,6 +660,7 @@ libqt_plugin_la_QML = \
 	gui/qt/medialibrary/qml/MusicDisplay.qml \
 	gui/qt/medialibrary/qml/MusicGenres.qml \
 	gui/qt/medialibrary/qml/MusicGenresDisplay.qml \
+	gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml \
 	gui/qt/medialibrary/qml/MusicTrackListDisplay.qml \
 	gui/qt/medialibrary/qml/MusicTracksDisplay.qml \
 	gui/qt/medialibrary/qml/UrlListDisplay.qml \
diff --git a/modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml
new file mode 100644
index 0000000000..312e0c65e3
--- /dev/null
+++ b/modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * Copyright (C) 2019 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          2.11
+import QtQuick.Controls 2.4
+import QtQuick.Layouts  1.3
+import QtQml.Models     2.2
+
+import org.videolan.medialib 0.1
+
+import "qrc:///widgets/" as Widgets
+import "qrc:///style/"
+
+Widgets.PageLoader {
+    id: root
+
+    //---------------------------------------------------------------------------------------------
+    // Aliases
+    //---------------------------------------------------------------------------------------------
+
+    property bool isViewMultiView: true
+
+    property variant model
+    property variant sortModel
+
+    //---------------------------------------------------------------------------------------------
+    // Settings
+    //---------------------------------------------------------------------------------------------
+
+    defaultPage: "all"
+
+    pageModel: [{
+        name: "all",
+        component: componentAll
+    }, {
+        name: "list",
+        component: componentList
+    }]
+
+    //---------------------------------------------------------------------------------------------
+    // Events
+    //---------------------------------------------------------------------------------------------
+
+    onCurrentItemChanged: {
+        model     = currentItem.model;
+        sortModel = currentItem.sortModel;
+
+        isViewMultiView = (currentItem.isViewMultiView === undefined
+                           ||
+                           currentItem.isViewMultiView);
+    }
+
+    //---------------------------------------------------------------------------------------------
+    // Functions
+    //---------------------------------------------------------------------------------------------
+    // Private
+
+    function _updateHistoryList(index) {
+        history.update(["mc", "music", "playlists", "all", { "initialIndex": index }]);
+    }
+
+    function _updateHistoryPlaylist(playlist) {
+        history.update(["mc", "music", "playlists", "list", {
+                            "initialIndex": playlist.currentIndex,
+                            "initialId"   : playlist.parentId,
+                            "initialName" : playlist.name
+                        }]);
+    }
+
+    //---------------------------------------------------------------------------------------------
+    // Childs
+    //---------------------------------------------------------------------------------------------
+
+    Component {
+        id: componentAll
+
+        PlaylistMediaList {
+            anchors.fill: parent
+
+            onCurrentIndexChanged: _updateHistoryList(currentIndex)
+
+            onShowList: history.push(["mc", "music", "playlists", "list",
+                                      { parentId: model.id, name: model.name }])
+        }
+    }
+
+    Component {
+        id: componentList
+
+        PlaylistMediaDisplay {
+            id: playlist
+
+            anchors.fill: parent
+
+            onCurrentIndexChanged: _updateHistoryPlaylist(playlist)
+            onParentIdChanged    : _updateHistoryPlaylist(playlist)
+            onNameChanged        : _updateHistoryPlaylist(playlist)
+        }
+    }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 006f6b89a4..5f0321eb35 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -282,6 +282,7 @@
         <file alias="MusicArtistsAlbums.qml">medialibrary/qml/MusicArtistsAlbums.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>
         <file alias="MusicTracksDisplay.qml">medialibrary/qml/MusicTracksDisplay.qml</file>
         <file alias="MusicTrackListDisplay.qml">medialibrary/qml/MusicTrackListDisplay.qml</file>
         <file alias="ArtistTopBanner.qml">medialibrary/qml/ArtistTopBanner.qml</file>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1d21a038c9..ad8c6a6981 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -818,6 +818,7 @@ modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
 modules/gui/qt/medialibrary/qml/MusicDisplay.qml
 modules/gui/qt/medialibrary/qml/MusicGenres.qml
 modules/gui/qt/medialibrary/qml/MusicGenresDisplay.qml
+modules/gui/qt/medialibrary/qml/MusicPlaylistsDisplay.qml
 modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
 modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
 modules/gui/qt/medialibrary/qml/UrlListDisplay.qml
-- 
2.25.1



More information about the vlc-devel mailing list