Commit c3f0f379 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

The sort button now display the selected sort role

parent 645550df
...@@ -137,15 +137,20 @@ ColumnLayout { ...@@ -137,15 +137,20 @@ ColumnLayout {
onClicked: showArtist() onClicked: showArtist()
}, },
FlatButtonWithToolTip { FlatButtonWithToolTip {
id: sortMenuButton
objectName: 'sortMenuButton' objectName: 'sortMenuButton'
visible: enableSorting && !showCreateRadioButton visible: enableSorting && !showCreateRadioButton
text: i18nc("Sort By Menu", "Sort By") text: (sortMenu.sortRoleName !== "" ? sortMenu.sortRoleName : i18nc("Sort By Menu Title with no sort selected", "Sort"))
display: AbstractButton.TextOnly
icon.name: "view-sort" icon.name: "view-sort"
onClicked: { onClicked: {
sortMenu.sortOrder = navigationBar.sortOrder sortMenu.sortOrder = navigationBar.sortOrder
sortMenu.open() sortMenu.open()
} }
Layout.preferredWidth: textSize.width + Kirigami.Units.smallSpacing * 2
SortMenu { SortMenu {
id: sortMenu id: sortMenu
...@@ -153,6 +158,13 @@ ColumnLayout { ...@@ -153,6 +158,13 @@ ColumnLayout {
onSortRoleChanged: if (viewManager) viewManager.sortRoleChanged(sortRole) onSortRoleChanged: if (viewManager) viewManager.sortRoleChanged(sortRole)
} }
TextMetrics {
id: textSize
text: sortMenuButton.text
font: sortMenuButton.font
}
}, },
FlatButtonWithToolTip { FlatButtonWithToolTip {
objectName: 'showFilterButton' objectName: 'showFilterButton'
......
...@@ -11,6 +11,7 @@ Menu { ...@@ -11,6 +11,7 @@ Menu {
id: sortMenu id: sortMenu
property int sortRole property int sortRole
property string sortRoleName
property var sortRoles property var sortRoles
property var sortRoleNames property var sortRoleNames
property var sortOrder property var sortOrder
...@@ -27,6 +28,7 @@ Menu { ...@@ -27,6 +28,7 @@ Menu {
if (sortRoles[i] === sortMenu.sortRole && sortMenu.sortOrderNames.length >= (i * 2 + 1)) { if (sortRoles[i] === sortMenu.sortRole && sortMenu.sortOrderNames.length >= (i * 2 + 1)) {
ascendingSortOrder.text = sortMenu.sortOrderNames[i * 2] ascendingSortOrder.text = sortMenu.sortOrderNames[i * 2]
descendingSortOrder.text = sortMenu.sortOrderNames[i * 2 + 1] descendingSortOrder.text = sortMenu.sortOrderNames[i * 2 + 1]
sortMenu.sortRoleName = sortMenu.sortRoleNames[i]
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment