[vlc-devel] [PATCH 12/12] qml: Create VideoGroupsDisplay

Benjamin Arnaud benjamin.arnaud at videolabs.io
Wed Apr 14 08:05:59 UTC 2021


---
 modules/gui/qt/Makefile.am                    |   1 +
 .../gui/qt/medialibrary/qml/VideoDisplay.qml  |   6 +-
 .../medialibrary/qml/VideoGroupsDisplay.qml   | 117 ++++++++++++++++++
 modules/gui/qt/vlc.qrc                        |   1 +
 po/POTFILES.in                                |   1 +
 5 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 modules/gui/qt/medialibrary/qml/VideoGroupsDisplay.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index a114d469e7..432d295fe6 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -689,6 +689,7 @@ libqt_plugin_la_QML = \
 	gui/qt/medialibrary/qml/VideoDisplay.qml \
 	gui/qt/medialibrary/qml/VideoAll.qml \
 	gui/qt/medialibrary/qml/VideoAllDisplay.qml \
+	gui/qt/medialibrary/qml/VideoGroupsDisplay.qml \
 	gui/qt/medialibrary/qml/PlaylistMediaList.qml \
 	gui/qt/medialibrary/qml/PlaylistMedia.qml \
 	gui/qt/medialibrary/qml/PlaylistMediaDelegate.qml \
diff --git a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
index 791b91ad1c..014564c7e7 100644
--- a/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoDisplay.qml
@@ -67,7 +67,11 @@ Widgets.PageLoader {
             name: "all",
             displayText: i18n.qtr("All"),
             url: "qrc:///medialibrary/VideoAllDisplay.qml"
-        }, {
+        },{
+            name: "groups",
+            displayText: i18n.qtr("Groups"),
+            url: "qrc:///medialibrary/VideoGroupsDisplay.qml"
+        },{
             name: "playlists",
             displayText: i18n.qtr("Playlists"),
             url: "qrc:///medialibrary/VideoPlaylistsDisplay.qml"
diff --git a/modules/gui/qt/medialibrary/qml/VideoGroupsDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoGroupsDisplay.qml
new file mode 100644
index 0000000000..a418f870e3
--- /dev/null
+++ b/modules/gui/qt/medialibrary/qml/VideoGroupsDisplay.qml
@@ -0,0 +1,117 @@
+/*****************************************************************************
+ * Copyright (C) 2021 VLC authors and VideoLAN
+ *
+ * Authors: Benjamin Arnaud <bunjee at omega.gg>
+ *
+ * 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 _updateHistoryAll(index) {
+        history.update(["mc", "video", "groups", "all", { "initialIndex": index }]);
+    }
+
+    function _updateHistoryList(list) {
+        history.update(["mc", "video", "groups", "list", {
+                            "initialIndex": list.currentIndex,
+                            "initialId"   : list.parentId,
+                            "initialName" : list.name
+                        }]);
+    }
+
+    //---------------------------------------------------------------------------------------------
+    // Childs
+    //---------------------------------------------------------------------------------------------
+
+    Component {
+        id: componentAll
+
+        MediaGroupList {
+            anchors.fill: parent
+
+            onCurrentIndexChanged: _updateHistoryAll(currentIndex)
+
+            onShowList: history.push(["mc", "video", "groups", "list",
+                                      { parentId: model.id, name: model.name }])
+        }
+    }
+
+    Component {
+        id: componentList
+
+        MediaGroupDisplay {
+            id: list
+
+            anchors.fill: parent
+
+            onCurrentIndexChanged: _updateHistoryList(list)
+            onParentIdChanged    : _updateHistoryList(list)
+            onNameChanged        : _updateHistoryList(list)
+        }
+    }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 9a61953294..25bfe532b9 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -277,6 +277,7 @@
         <file alias="VideoDisplay.qml">medialibrary/qml/VideoDisplay.qml</file>
         <file alias="VideoAll.qml">medialibrary/qml/VideoAll.qml</file>
         <file alias="VideoAllDisplay.qml">medialibrary/qml/VideoAllDisplay.qml</file>
+        <file alias="VideoGroupsDisplay.qml">medialibrary/qml/VideoGroupsDisplay.qml</file>
         <file alias="PlaylistMediaList.qml">medialibrary/qml/PlaylistMediaList.qml</file>
         <file alias="PlaylistMedia.qml">medialibrary/qml/PlaylistMedia.qml</file>
         <file alias="PlaylistMediaDelegate.qml">medialibrary/qml/PlaylistMediaDelegate.qml</file>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index dc7845e457..00a6e62aab 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -840,6 +840,7 @@ modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
 modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
 modules/gui/qt/medialibrary/qml/VideoAll.qml
 modules/gui/qt/medialibrary/qml/VideoAllDisplay.qml
+modules/gui/qt/medialibrary/qml/VideoGroupsDisplay.qml
 modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
 modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
 modules/gui/qt/medialibrary/qml/PlaylistMediaDelegate.qml
-- 
2.25.1



More information about the vlc-devel mailing list