[vlc-devel] [PATCH 45/55] qml: refactor PlaylistToolbar

Fatih Uzunoglu fuzun54 at outlook.com
Thu Jan 7 21:36:58 UTC 2021


---
 .../gui/qt/playlist/qml/PlaylistToolbar.qml   | 181 +++++++++---------
 1 file changed, 94 insertions(+), 87 deletions(-)

diff --git a/modules/gui/qt/playlist/qml/PlaylistToolbar.qml b/modules/gui/qt/playlist/qml/PlaylistToolbar.qml
index 9d7ca00c20..3522bc8120 100644
--- a/modules/gui/qt/playlist/qml/PlaylistToolbar.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistToolbar.qml
@@ -25,112 +25,119 @@ import "qrc:///widgets/" as Widgets
 import "qrc:///util/KeyHelper.js" as KeyHelper
 import "qrc:///style/"
 
-Widgets.NavigableFocusScope {
-    id: playlistToolbar
 
-    property int leftPadding: 0
-    property int rightPadding: 0
+RowLayout {
+    id: rowLayout
+
     height: VLCStyle.heightBar_normal
+    spacing: VLCStyle.margin_normal
 
-    property VLCColors colors: VLCStyle.colors
+    Item {
+        Layout.fillWidth: true
+        implicitHeight: childrenRect.height
 
-    Rectangle {
-        anchors.fill: parent
-        color: colors.banner
+        Widgets.IconToolButton {
+            id: loop
 
-        RowLayout {
-            anchors {
-                fill: parent
-                leftMargin: playlistToolbar.leftPadding
-                rightMargin: playlistToolbar.rightPadding
-            }
+            anchors.centerIn: parent
 
-            spacing: VLCStyle.margin_normal
-
-            Widgets.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
-
-                color: colors.buttonText
-                colorDisabled: colors.textInactive
-            }
+            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
 
-            Widgets.IconToolButton {
-                id: shuffle
-                Layout.alignment: Qt.AlignHCenter
-                //Layout.minimumWidth: VLCStyle.icon_normal * 2
-                enabled: !mainPlaylistController.empty
-                size: VLCStyle.icon_normal
-                iconText: VLCIcons.shuffle_on
-                onClicked: mainPlaylistController.shuffle()
-                focusPolicy: Qt.NoFocus
-
-                color: colors.buttonText
-                colorDisabled: colors.textInactive
-            }
+            color: colors.buttonText
+            colorDisabled: colors.textInactive
+        }
+    }
 
-            Widgets.SortControl {
-                id: sort
-                Layout.alignment: Qt.AlignHCenter
-                //Layout.minimumWidth: VLCStyle.icon_normal * 2
-                enabled: !mainPlaylistController.empty
-                popupAlignment: Qt.AlignRight | Qt.AlignTop
 
-                focusPolicy: Qt.NoFocus
+    Item {
+        Layout.fillWidth: true
+        implicitHeight: childrenRect.height
 
-                model: mainPlaylistController.sortKeyTitleList
-                textRole: "title"
-                criteriaRole: "key"
+        Widgets.IconToolButton {
+            id: shuffle
 
-                onSortSelected: {
-                    mainPlaylistController.sortKey = type
-                }
+            anchors.centerIn: parent
 
-                onSortOrderSelected: {
-                    if (type === Qt.AscendingOrder)
-                        mainPlaylistController.sortOrder = PlaylistControllerModel.SORT_ORDER_ASC
-                    else if (type === Qt.DescendingOrder)
-                        mainPlaylistController.sortOrder = PlaylistControllerModel.SORT_ORDER_DESC
+            enabled: mainPlaylistController.count > 1
+            size: VLCStyle.icon_normal
+            iconText: VLCIcons.shuffle_on
+            onClicked: mainPlaylistController.shuffle()
+            focusPolicy: Qt.NoFocus
 
-                    mainPlaylistController.sort()
-                }
+            color: colors.buttonText
+            colorDisabled: colors.textInactive
+        }
+    }
 
-                colors: playlistToolbar.colors
+    Item {
+        Layout.fillWidth: true
+        implicitHeight: childrenRect.height
 
-                sortOrder: {
-                    if (mainPlaylistController.sortOrder === PlaylistControllerModel.SORT_ORDER_ASC) {
-                        Qt.AscendingOrder
-                    }
-                    else if (mainPlaylistController.sortOrder === PlaylistControllerModel.SORT_ORDER_DESC) {
-                        Qt.DescendingOrder
-                    }
-                }
+        Widgets.SortControl {
+            id: sort
+
+            anchors.centerIn: parent
+
+            enabled: mainPlaylistController.count > 1
+            popupAlignment: Qt.AlignRight | Qt.AlignTop
+
+            focusPolicy: Qt.NoFocus
+
+            model: mainPlaylistController.sortKeyTitleList
+            textRole: "title"
+            criteriaRole: "key"
 
-                sortKey: mainPlaylistController.sortKey
+            onSortSelected: {
+                mainPlaylistController.sortKey = type
             }
 
-            Widgets.IconToolButton {
-                id: clear
-                Layout.alignment: Qt.AlignHCenter
-                //Layout.minimumWidth: VLCStyle.icon_normal * 2
-                size: VLCStyle.icon_normal
-                enabled: !mainPlaylistController.empty
-                iconText: VLCIcons.playlist_clear
-                onClicked: mainPlaylistController.clear()
-                focusPolicy: Qt.NoFocus
-
-                color: colors.buttonText
-                colorDisabled: colors.textInactive
+            onSortOrderSelected: {
+                if (type === Qt.AscendingOrder)
+                    mainPlaylistController.sortOrder = PlaylistControllerModel.SORT_ORDER_ASC
+                else if (type === Qt.DescendingOrder)
+                    mainPlaylistController.sortOrder = PlaylistControllerModel.SORT_ORDER_DESC
+
+                mainPlaylistController.sort()
+            }
+
+            colors: root.colors
+
+            sortOrder: {
+                if (mainPlaylistController.sortOrder === PlaylistControllerModel.SORT_ORDER_ASC) {
+                    Qt.AscendingOrder
+                }
+                else if (mainPlaylistController.sortOrder === PlaylistControllerModel.SORT_ORDER_DESC) {
+                    Qt.DescendingOrder
+                }
             }
+
+            sortKey: mainPlaylistController.sortKey
         }
     }
-}
 
+    Item {
+        Layout.fillWidth: true
+        implicitHeight: childrenRect.height
+
+        Widgets.IconToolButton {
+            id: clear
+
+            anchors.centerIn: parent
+
+            size: VLCStyle.icon_normal
+            enabled: !mainPlaylistController.empty
+            iconText: VLCIcons.playlist_clear
+            onClicked: mainPlaylistController.clear()
+            focusPolicy: Qt.NoFocus
+
+            color: colors.buttonText
+            colorDisabled: colors.textInactive
+        }
+    }
+}
-- 
2.27.0



More information about the vlc-devel mailing list