Commit bc8c2e2c authored by Nate Graham's avatar Nate Graham 💤
Browse files

Use more standard button code

This commit simplifies the button code for Elisa in the following ways:
- Use ToolButtons rather than flat Buttons for controls than want to
  look like ToolButtons. This is possible now that our QQC2 style shows
  ToolButton focus correctly.
- Remove hardcoded custom button sizes and let them be their natural
  size so they adjust with the scale factor and font size properly.
- Make HeaderFooterToolbar a bit smaller to fit the new noew-smaller
  ToolButtons.
- Redo the custom contentItem for the sort button to work properly with
  standardized buttons.
parent 9f7d6ba1
Pipeline #48446 canceled with stage
......@@ -30,12 +30,6 @@ FocusScope {
property color shadow
property color highlight
}
Item {
id: elisaTheme
property int delegateToolButtonSize: 34
}
}
Item {
......
......@@ -41,8 +41,6 @@ Item {
property int tooltipRadius: 3
property int shadowOffset: 2
property int delegateToolButtonSize: 34
property int mediaPlayerControlHeight: 42
property real mediaPlayerControlOpacity: 0.6
property int volumeSliderWidth: 100
......
......@@ -11,24 +11,13 @@ import QtQuick.Controls 2.3
import org.kde.kirigami 2.5 as Kirigami
import org.kde.elisa 1.0
Button {
id: flatButtonWithToolTip
ToolButton {
Keys.onReturnPressed: clicked()
Accessible.onPressAction: clicked()
activeFocusOnTab: true
Keys.onReturnPressed: flatButtonWithToolTip.clicked()
Accessible.onPressAction: flatButtonWithToolTip.clicked()
flat: true
display: AbstractButton.IconOnly
icon.width: Kirigami.Units.iconSizes.smallMedium
icon.height: Kirigami.Units.iconSizes.smallMedium
implicitWidth: icon.width + Kirigami.Units.largeSpacing * 2
implicitHeight: icon.height + Kirigami.Units.largeSpacing * 2
ToolTip.visible: hovered && flatButtonWithToolTip.text.length > 0
ToolTip.visible: hovered && text.length > 0
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: flatButtonWithToolTip.text
ToolTip.text: text
}
......@@ -147,9 +147,6 @@ FocusScope {
Keys.onEnterPressed: clicked()
visible: showDetailsButton && (trackUrl.toString().substring(0, 7) === 'file://')
width: elisaTheme.delegateToolButtonSize
height: elisaTheme.delegateToolButtonSize
}
Button {
id: detailsButton
......@@ -180,9 +177,6 @@ FocusScope {
Keys.onReturnPressed: clicked()
Keys.onEnterPressed: clicked()
visible: showDetailsButton
width: elisaTheme.delegateToolButtonSize
height: elisaTheme.delegateToolButtonSize
}
Button {
......@@ -206,9 +200,6 @@ FocusScope {
Keys.onEnterPressed: replaceAndPlay()
visible: showPlayButton
width: elisaTheme.delegateToolButtonSize
height: elisaTheme.delegateToolButtonSize
}
Button {
......@@ -231,9 +222,6 @@ FocusScope {
Keys.onEnterPressed: enqueue()
visible: showEnqueueButton
width: elisaTheme.delegateToolButtonSize
height: elisaTheme.delegateToolButtonSize
}
}
}
......
......@@ -27,7 +27,7 @@ Rectangle {
// Spacing of content items. Defaults to Kirigami.Units.smallSpacing
property alias contentLayoutSpacing: contentLayout.spacing
implicitHeight: Math.round(Kirigami.Units.gridUnit * 2.5)
implicitHeight: Math.round(Kirigami.Units.gridUnit * 2)
color: myPalette.window
......
......@@ -111,8 +111,7 @@ ColumnLayout {
objectName: 'sortMenuButton'
visible: enableSorting && !showCreateRadioButton
display: AbstractButton.TextOnly
icon.name: "view-sort"
onClicked: {
sortMenu.sortOrder = navigationBar.sortOrder
sortMenu.open()
......@@ -122,22 +121,24 @@ ColumnLayout {
// that opens a dropdown menu
// TODO: Port more fully to Kirigami so we get this for free
contentItem: RowLayout {
spacing: Kirigami.Units.largeSpacing
Label {
Kirigami.Icon {
implicitWidth: Kirigami.Units.iconSizes.smallMedium
implicitHeight: Kirigami.Units.iconSizes.smallMedium
Layout.leftMargin: Kirigami.Units.largeSpacing
source: "view-sort"
}
Label {
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 {
Kirigami.Icon {
implicitWidth: Kirigami.Units.iconSizes.small
implicitHeight: Kirigami.Units.iconSizes.small
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
source: "arrow-down"
}
}
......
......@@ -223,9 +223,6 @@ FocusScope {
anchors.centerIn: parent
FlatButtonWithToolTip {
implicitHeight: playListEntry.height
implicitWidth: playListEntry.height
visible: playListEntry.fileName.toString().substring(0, 7) === 'file://'
enabled: isValid
......@@ -241,9 +238,6 @@ FocusScope {
id: infoButton
objectName: 'infoButton'
implicitHeight: playListEntry.height
implicitWidth: playListEntry.height
enabled: isValid
text: i18nc("Show track metadata", "View Details")
......@@ -263,9 +257,6 @@ FocusScope {
id: playPauseButton
objectName: 'playPauseButton'
implicitHeight: playListEntry.height
implicitWidth: playListEntry.height
enabled: isValid
scale: LayoutMirroring.enabled ? -1 : 1 // We can mirror the symmetrical pause icon
......@@ -284,9 +275,6 @@ FocusScope {
id: removeButton
objectName: 'removeButton'
implicitHeight: playListEntry.height
implicitWidth: playListEntry.height
text: i18nc("Remove current track from play list", "Remove")
icon.name: "error"
onClicked: playListEntry.removeFromPlaylist(playListEntry.index)
......
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