use paintedWidth when significative
gets updated before implicitWidth, making the center alignment work better
This commit is contained in:
parent
86ecacf2a4
commit
6b7fa2aaac
@ -97,7 +97,7 @@ Item {
|
|||||||
property alias font: label.font
|
property alias font: label.font
|
||||||
|
|
||||||
//icon + label + left margin + right margin + spacing between icon and text
|
//icon + label + left margin + right margin + spacing between icon and text
|
||||||
property real minimumWidth: icon.width + label.implicitWidth + surfaceNormal.margins.left + surfaceNormal.margins.right + ((icon.valid) ? surfaceNormal.margins.left : 0)
|
property real minimumWidth: icon.width + label.preferredWidth + surfaceNormal.margins.left + surfaceNormal.margins.right + ((icon.valid) ? surfaceNormal.margins.left : 0)
|
||||||
property real minimumHeight: Math.max(icon.height, label.paintedHeight) + surfaceNormal.margins.top + surfaceNormal.margins.bottom
|
property real minimumHeight: Math.max(icon.height, label.paintedHeight) + surfaceNormal.margins.top + surfaceNormal.margins.bottom
|
||||||
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
@ -239,11 +239,13 @@ Item {
|
|||||||
id: label
|
id: label
|
||||||
|
|
||||||
//FIXME: why this is needed?
|
//FIXME: why this is needed?
|
||||||
onPaintedWidthChanged: {
|
onTextChanged: {
|
||||||
icon.anchors.horizontalCenter = label.text.length > 0 ? undefined : icon.parent.horizontalCenter
|
icon.anchors.horizontalCenter = label.text.length > 0 ? undefined : icon.parent.horizontalCenter
|
||||||
icon.anchors.left = label.text.length > 0 ? icon.parent.left : undefined
|
icon.anchors.left = label.text.length > 0 ? icon.parent.left : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property int preferredWidth: button.width < button.implicitWidth ? paintedWidth: paintedWidth
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
Loading…
Reference in New Issue
Block a user