[vlc-devel] [PATCH 9/9] qml: add a toobar below the playlist view

Pierre Lamot pierre at videolabs.io
Mon Nov 18 18:15:42 CET 2019


---
 modules/gui/qt/Makefile.am                    |   1 +
 .../gui/qt/qml/playlist/PlaylistListView.qml  |  20 ++-
 .../gui/qt/qml/playlist/PlaylistToolbar.qml   | 126 ++++++++++++++++++
 modules/gui/qt/vlc.qrc                        |   1 +
 4 files changed, 147 insertions(+), 1 deletion(-)
 create mode 100644 modules/gui/qt/qml/playlist/PlaylistToolbar.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index e4a97a205f..8be23583cc 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -650,6 +650,7 @@ libqt_plugin_la_QML = \
 	gui/qt/qml/mediacenter/VideoGridItem.qml \
 	gui/qt/qml/playlist/PlaylistListView.qml \
 	gui/qt/qml/playlist/PlaylistMainView.qml \
+	gui/qt/qml/playlist/PlaylistToolbar.qml \
 	gui/qt/qml/playlist/PLItem.qml \
 	gui/qt/qml/playlist/PLItemFooter.qml \
 	gui/qt/qml/playlist/PlaylistMenu.qml \
diff --git a/modules/gui/qt/qml/playlist/PlaylistListView.qml b/modules/gui/qt/qml/playlist/PlaylistListView.qml
index 0926ed920a..4def3617cd 100644
--- a/modules/gui/qt/qml/playlist/PlaylistListView.qml
+++ b/modules/gui/qt/qml/playlist/PlaylistListView.qml
@@ -17,6 +17,7 @@
  *****************************************************************************/
 import QtQuick 2.11
 import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.3
 import QtQml.Models 2.2
 
 import org.videolan.vlc 0.1
@@ -112,10 +113,16 @@ Utils.NavigableFocusScope {
         }
     }
 
+    ColumnLayout {
+        anchors.fill: parent
+
+
     Utils.KeyNavigableListView {
         id: view
 
-        anchors.fill: parent
+        Layout.fillWidth: true
+        Layout.fillHeight: true
+
         focus: true
 
         model: root.plmodel
@@ -313,6 +320,17 @@ Utils.NavigableFocusScope {
         }
     }
 
+    PlaylistToolbar {
+        Layout.fillWidth: true
+
+        leftPadding: root.leftPadding
+        rightPadding: root.rightPadding
+        navigationParent: root
+        navigationUpItem: view
+    }
+
+    }
+
     Keys.priority: Keys.AfterItem
     Keys.forwardTo: view
     Keys.onPressed: defaultKeyAction(event, 0)
diff --git a/modules/gui/qt/qml/playlist/PlaylistToolbar.qml b/modules/gui/qt/qml/playlist/PlaylistToolbar.qml
new file mode 100644
index 0000000000..dfc7de9662
--- /dev/null
+++ b/modules/gui/qt/qml/playlist/PlaylistToolbar.qml
@@ -0,0 +1,126 @@
+/*****************************************************************************
+ * 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 org.videolan.vlc 0.1
+
+import "qrc:///utils/" as Utils
+import "qrc:///utils/KeyHelper.js" as KeyHelper
+import "qrc:///style/"
+
+Utils.NavigableFocusScope {
+    id: playlistToolbar
+
+    property int leftPadding: 0
+    property int rightPadding: 0
+    height: VLCStyle.heightBar_normal
+
+    Rectangle {
+        anchors.fill: parent
+        color: VLCStyle.colors.banner
+
+        RowLayout {
+            anchors {
+                fill: parent
+                leftMargin: playlistToolbar.leftPadding
+                rightMargin: playlistToolbar.rightPadding
+            }
+
+            spacing: VLCStyle.margin_normal
+
+            Utils.IconToolButton {
+                id: loop
+                Layout.alignment: Qt.AlignHCenter
+                //Layout.minimumWidth: VLCStyle.icon_normal * 2
+                size: VLCStyle.icon_normal
+                iconText: (mainPlaylistController.repeatMode === PlaylistControllerModel.PLAYBACK_REPEAT_CURRENT)
+                          ? VLCIcons.repeat_one
+                          : VLCIcons.repeat_all
+                checked: mainPlaylistController.repeatMode !== PlaylistControllerModel.PLAYBACK_REPEAT_NONE
+                onClicked: mainPlaylistController.toggleRepeatMode()
+                focusPolicy: Qt.NoFocus
+            }
+
+            Utils.IconToolButton {
+                id: shuffle
+                Layout.alignment: Qt.AlignHCenter
+                //Layout.minimumWidth: VLCStyle.icon_normal * 2
+                size: VLCStyle.icon_normal
+                iconText: VLCIcons.shuffle_on
+                onClicked: mainPlaylistController.shuffle()
+                focusPolicy: Qt.NoFocus
+            }
+
+            Label {
+                Layout.fillWidth: true
+                Layout.alignment: Qt.AlignHCenter
+                horizontalAlignment: Text.AlignHCenter
+                text: (view.mode === "select")
+                        ? qsTr("Select tracks (%1)").arg(plmodel.selectedCount)
+                    : (view.mode === "move")
+                        ? qsTr("Move tracks (%1)").arg(plmodel.selectedCount)
+                    : qsTr("%1 tracks").arg(plmodel.count)
+                font.pixelSize: VLCStyle.fontSize_normal
+                color: VLCStyle.colors.text
+                elide: Text.ElideRight
+            }
+
+            Utils.SortControl {
+                id: sort
+                Layout.alignment: Qt.AlignHCenter
+                //Layout.minimumWidth: VLCStyle.icon_normal * 2
+                popupAlignment: Qt.AlignRight | Qt.AlignTop
+
+                model: ListModel {
+                    ListElement { text: qsTr("Tile");             criteria: PlaylistControllerModel.SORT_KEY_TITLE}
+                    ListElement { text: qsTr("Duration");         criteria: PlaylistControllerModel.SORT_KEY_DURATION}
+                    ListElement { text: qsTr("Artist");           criteria: PlaylistControllerModel.SORT_KEY_ARTIST}
+                    ListElement { text: qsTr("Album");            criteria: PlaylistControllerModel.SORT_KEY_ALBUM}
+                    ListElement { text: qsTr("Genre");            criteria: PlaylistControllerModel.SORT_KEY_GENRE}
+                    ListElement { text: qsTr("Date");             criteria: PlaylistControllerModel.SORT_KEY_DATE}
+                    ListElement { text: qsTr("Track number");     criteria: PlaylistControllerModel.SORT_KEY_TRACK_NUMBER}
+                    ListElement { text: qsTr("URL");              criteria: PlaylistControllerModel.SORT_KEY_URL}
+                    ListElement { text: qsTr("Rating");           criteria: PlaylistControllerModel.SORT_KEY_RATIN}
+                }
+                textRole: "text"
+
+                listWidth: VLCStyle.widthSortBox
+                onSortSelected: {
+                    mainPlaylistController.sort(modelData.criteria, PlaylistControllerModel.SORT_ORDER_ASC)
+                }
+
+                Keys.priority: Keys.AfterItem
+                Keys.onPressed: defaultKeyAction(event, 0)
+                navigationParent: playlistToolbar
+            }
+
+            Utils.IconToolButton {
+                id: clear
+                Layout.alignment: Qt.AlignHCenter
+                //Layout.minimumWidth: VLCStyle.icon_normal * 2
+                size: VLCStyle.icon_normal
+                iconText: VLCIcons.playlist_clear
+                onClicked: mainPlaylistController.clear()
+                focusPolicy: Qt.NoFocus
+            }
+        }
+    }
+}
+
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 77b7315059..60d8c79190 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -244,6 +244,7 @@
         <file alias="PlaylistMenu.qml">qml/playlist/PlaylistMenu.qml</file>
         <file alias="PLItemFooter.qml">qml/playlist/PLItemFooter.qml</file>
         <file alias="PlaylistMainView.qml">qml/playlist/PlaylistMainView.qml</file>
+        <file alias="PlaylistToolbar.qml">qml/playlist/PlaylistToolbar.qml</file>
     </qresource>
     <qresource prefix="/menus">
         <file alias="AudioMenu.qml">qml/menus/AudioMenu.qml</file>
-- 
2.17.1



More information about the vlc-devel mailing list