[Button Styles] Fill height and vertical align

Otherwise the Text will never grow below its preferred height as the button grows smaller and will
eventually leak outside at the bottom rather than stay centered.

BUG: 393388

Differential Revision: https://phabricator.kde.org/D12518
This commit is contained in:
Kai Uwe Broulik 2018-04-26 17:04:05 +02:00
parent f16190d89c
commit c9e8e2e717
2 changed files with 6 additions and 2 deletions

View File

@ -71,14 +71,16 @@ QtQuickControlStyle.ButtonStyle {
PlasmaComponents.Label { PlasmaComponents.Label {
id: label id: label
Layout.alignment: Qt.AlignVCenter Layout.fillHeight: true
text: Util.stylizeEscapedMnemonics(Util.toHtmlEscaped(control.text)) text: Util.stylizeEscapedMnemonics(Util.toHtmlEscaped(control.text))
textFormat: Text.StyledText textFormat: Text.StyledText
height: undefined
font: control.font || theme.defaultFont font: control.font || theme.defaultFont
visible: control.text != "" visible: control.text != ""
Layout.fillWidth: true Layout.fillWidth: true
color: theme.buttonTextColor color: theme.buttonTextColor
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight elide: Text.ElideRight
} }

View File

@ -94,7 +94,8 @@ QtQuickControlStyle.ButtonStyle {
PlasmaComponents.Label { PlasmaComponents.Label {
id: label id: label
Layout.minimumWidth: implicitWidth Layout.minimumWidth: implicitWidth
Layout.alignment: Qt.AlignVCenter Layout.fillHeight: true
height: undefined
text: Util.stylizeEscapedMnemonics(Util.toHtmlEscaped(control.text)) text: Util.stylizeEscapedMnemonics(Util.toHtmlEscaped(control.text))
textFormat: Text.StyledText textFormat: Text.StyledText
font: control.font || theme.defaultFont font: control.font || theme.defaultFont
@ -102,6 +103,7 @@ QtQuickControlStyle.ButtonStyle {
Layout.fillWidth: true Layout.fillWidth: true
color: (controlHovered || !flat) && buttonsurfaceChecker.usedPrefix != "toolbutton-hover" ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor color: (controlHovered || !flat) && buttonsurfaceChecker.usedPrefix != "toolbutton-hover" ? theme.buttonTextColor : PlasmaCore.ColorScope.textColor
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight elide: Text.ElideRight
} }