Fix vertical alignment of text in player controls toolbar

This commit is contained in:
Bart De Vries 2023-11-28 14:54:44 +01:00
parent 74f52e6171
commit bce24aa9c6
2 changed files with 7 additions and 16 deletions

View File

@ -59,7 +59,6 @@ FocusScope {
RowLayout { RowLayout {
id: playerControlToolBar id: playerControlToolBar
property int iconSize: Kirigami.Units.gridUnit
anchors.fill: parent anchors.fill: parent
anchors.topMargin: Kirigami.Units.largeSpacing anchors.topMargin: Kirigami.Units.largeSpacing
@ -148,11 +147,7 @@ FocusScope {
} }
Controls.ToolButton { Controls.ToolButton {
id: playbackRateButton id: playbackRateButton
contentItem: Controls.Label { text: AudioManager.playbackRate.toFixed(2) + "x"
text: AudioManager.playbackRate.toFixed(2) + "x"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
checkable: true checkable: true
checked: playbackRateMenu.visible checked: playbackRateMenu.visible
onClicked: { onClicked: {
@ -162,7 +157,6 @@ FocusScope {
playbackRateMenu.popup(playbackRateButton, 0, playbackRateButton.height); playbackRateMenu.popup(playbackRateButton, 0, playbackRateButton.height);
} }
} }
Layout.alignment: Qt.AlignHCenter
padding: 0 padding: 0
implicitWidth: playButton.width * 1.5 implicitWidth: playButton.width * 1.5
implicitHeight: playButton.height implicitHeight: playButton.height
@ -177,12 +171,14 @@ FocusScope {
id: currentPositionLabel id: currentPositionLabel
text: AudioManager.formattedPosition text: AudioManager.formattedPosition
visible: !playerControlToolBar.tooNarrowAudioLabels visible: !playerControlToolBar.tooNarrowAudioLabels
Layout.alignment: Qt.AlignVCenter
} }
Controls.Slider { Controls.Slider {
id: durationSlider id: durationSlider
enabled: AudioManager.entry && AudioManager.PlaybackState != AudioManager.StoppedState && AudioManager.canPlay enabled: AudioManager.entry && AudioManager.PlaybackState != AudioManager.StoppedState && AudioManager.canPlay
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
padding: 0 padding: 0
from: 0 from: 0
to: AudioManager.duration / 1000 to: AudioManager.duration / 1000
@ -197,6 +193,8 @@ FocusScope {
Layout.preferredHeight: endLabel.implicitHeight Layout.preferredHeight: endLabel.implicitHeight
Layout.preferredWidth: endLabel.implicitWidth Layout.preferredWidth: endLabel.implicitWidth
Layout.rightMargin: Kirigami.Units.largeSpacing Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.alignment: Qt.AlignVCenter
Controls.Label { Controls.Label {
id: endLabel id: endLabel
anchors.right: parent.right anchors.right: parent.right
@ -204,7 +202,6 @@ FocusScope {
text: (SettingsManager.toggleRemainingTime) ? text: (SettingsManager.toggleRemainingTime) ?
"-" + AudioManager.formattedLeftDuration "-" + AudioManager.formattedLeftDuration
: AudioManager.formattedDuration : AudioManager.formattedDuration
} }
MouseArea { MouseArea {

View File

@ -452,13 +452,7 @@ Kirigami.Page {
// left section // left section
Controls.Button { Controls.Button {
id: playbackRateButton id: playbackRateButton
// Use contentItem and a Label because using plain "text" text: AudioManager.playbackRate.toFixed(2) + "x"
// does not rescale automatically if the text changes
contentItem: Controls.Label {
text: AudioManager.playbackRate.toFixed(2) + "x"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
checkable: true checkable: true
checked: playbackRateMenu.visible checked: playbackRateMenu.visible
onClicked: { onClicked: {
@ -470,7 +464,7 @@ Kirigami.Page {
} }
flat: true flat: true
padding: 0 padding: 0
implicitWidth: playButton.width implicitWidth: playButton.width * 1.5
implicitHeight: playButton.height implicitHeight: playButton.height
} }