Commit 31566981 authored by Nate Graham's avatar Nate Graham
Browse files

Re-make sort menu button's content item to fix all sizing issues

If we're going to fake a specific look with this button for now, we need
to create a totally custom content item rather than using some but not
all of the button's built-in content items.
parent 13a8034c
Pipeline #34725 passed with stage
in 13 minutes and 23 seconds
......@@ -28,7 +28,7 @@ Button {
implicitWidth: icon.width + Kirigami.Units.largeSpacing * 2
implicitHeight: icon.height + Kirigami.Units.largeSpacing * 2
ToolTip.visible: hovered
ToolTip.visible: hovered && flatButtonWithToolTip.text.length > 0
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: flatButtonWithToolTip.text
}
......@@ -108,14 +108,10 @@ ColumnLayout {
},
FlatButtonWithToolTip {
id: sortMenuButton
Layout.preferredWidth: implicitContentWidth
objectName: 'sortMenuButton'
visible: enableSorting && !showCreateRadioButton
text: if (sortMenu.sortRoleName !== "") {
i18nc("Sort By Menu Title with no sort selected", "Sort: %1", sortMenu.sortRoleName)
} else {
i18nc("Sort By Menu Title with no sort selected", "Sort")
}
display: AbstractButton.TextOnly
icon.name: "view-sort"
onClicked: {
......@@ -123,20 +119,29 @@ ColumnLayout {
sortMenu.open()
}
indicator: Image {
source: 'image://icon/arrow-down'
width: Kirigami.Units.iconSizes.small
height: Kirigami.Units.iconSizes.small
sourceSize.width: width
sourceSize.height: height
anchors.right: sortMenuButton.right
anchors.verticalCenter: sortMenuButton.verticalCenter
anchors.rightMargin: Kirigami.Units.largeSpacing
// Custom content item for now to replicate the look of a button
// that opens a dropdown menu
// TODO: Port more fully to Kirigami so we get this for free
contentItem: RowLayout {
spacing: Kirigami.Units.largeSpacing
Label {
Layout.leftMargin: Kirigami.Units.largeSpacing
text: if (sortMenu.sortRoleName !== "") {
i18nc("Sort By Menu Title with no sort selected", "Sort: %1", sortMenu.sortRoleName)
} else {
i18nc("Sort By Menu Title with no sort selected", "Sort")
}
}
Image {
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredWidth: Kirigami.Units.iconSizes.small
Layout.preferredHeight: Kirigami.Units.iconSizes.small
source: 'image://icon/arrow-down'
sourceSize.width: width
sourceSize.height: height
}
}
Layout.preferredWidth: textSize.width + implicitIndicatorWidth + Kirigami.Units.largeSpacing * 2
SortMenu {
id: sortMenu
......@@ -144,13 +149,6 @@ ColumnLayout {
onSortRoleChanged: if (viewManager) viewManager.sortRoleChanged(sortRole)
}
TextMetrics {
id: textSize
text: sortMenuButton.text
font: sortMenuButton.font
}
},
FlatButtonWithToolTip {
objectName: 'createRadioButton'
......
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