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

The sort button now display the selected sort role

parent 645550df
......@@ -137,15 +137,20 @@ ColumnLayout {
onClicked: showArtist()
},
FlatButtonWithToolTip {
id: sortMenuButton
objectName: 'sortMenuButton'
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"
onClicked: {
sortMenu.sortOrder = navigationBar.sortOrder
sortMenu.open()
}
Layout.preferredWidth: textSize.width + Kirigami.Units.smallSpacing * 2
SortMenu {
id: sortMenu
......@@ -153,6 +158,13 @@ ColumnLayout {
onSortRoleChanged: if (viewManager) viewManager.sortRoleChanged(sortRole)
}
TextMetrics {
id: textSize
text: sortMenuButton.text
font: sortMenuButton.font
}
},
FlatButtonWithToolTip {
objectName: 'showFilterButton'
......
......@@ -11,6 +11,7 @@ Menu {
id: sortMenu
property int sortRole
property string sortRoleName
property var sortRoles
property var sortRoleNames
property var sortOrder
......@@ -27,6 +28,7 @@ Menu {
if (sortRoles[i] === sortMenu.sortRole && sortMenu.sortOrderNames.length >= (i * 2 + 1)) {
ascendingSortOrder.text = sortMenu.sortOrderNames[i * 2]
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