[vlc-devel] [PATCH 13/27] qml: add sortOrderSelected signal to SortControl

Fatih Uzunoglu fuzun54 at outlook.com
Fri Oct 9 18:56:34 CEST 2020


This signal is needed when parent does not automatically switch sort order if sort key is the same when sortSelected triggered
---
 modules/gui/qt/widgets/qml/SortControl.qml | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/modules/gui/qt/widgets/qml/SortControl.qml b/modules/gui/qt/widgets/qml/SortControl.qml
index 9129b8a6d7..951583075f 100644
--- a/modules/gui/qt/widgets/qml/SortControl.qml
+++ b/modules/gui/qt/widgets/qml/SortControl.qml
@@ -46,7 +46,10 @@ Widgets.NavigableFocusScope {
     property var sortKey : PlaylistControllerModel.SORT_KEY_NONE
     property var sortOrder : undefined
 
+    property bool _intSortOrder : false
+
     signal sortSelected(var modelData)
+    signal sortOrderSelected(var order)
 
     onFocusChanged: {
         if (!focus)
@@ -190,7 +193,24 @@ Widgets.NavigableFocusScope {
 
                 onClicked: {
                     root.currentIndex = index
+
+                    if (root.sortOrder !== undefined) {
+                        var _sortOrder = root.sortOrder
+                        var _sortKey = root.sortKey
+                    }
+
                     root.sortSelected(Array.isArray(root.model) ? modelData : model)
+
+                    if (root.sortOrder !== undefined) {
+                        if (root.sortKey !== _sortKey)
+                            root._intSortOrder = false
+
+                        if (root.sortOrder === _sortOrder) {
+                            root.sortOrderSelected(root._intSortOrder ? PlaylistControllerModel.SORT_ORDER_DESC : PlaylistControllerModel.SORT_ORDER_ASC)
+                            root._intSortOrder = !root._intSortOrder
+                        }
+                    }
+
                     popup.close()
                 }
             }
-- 
2.25.1



More information about the vlc-devel mailing list