Calculate implicitWidth of both button and toolbutton properly

This commit is contained in:
David Edmundson 2014-05-21 21:15:18 +02:00
parent 8b86279298
commit b06fe8301c
2 changed files with 7 additions and 5 deletions

View File

@ -94,12 +94,12 @@ Item {
/**
* Smallest width this button can be to show all the contents
*/
property real minimumWidth: icon.width + label.paintedWidth + surfaceNormal.margins.left + surfaceNormal.margins.right + ((icon.valid) ? surfaceNormal.margins.left : 0)
property real minimumWidth: icon.width + label.implicitWidth + surfaceNormal.margins.left + surfaceNormal.margins.right + ((icon.valid) ? surfaceNormal.margins.left : 0)
/**
* Smallest height this button can be to show all the contents
*/
property real minimumHeight: Math.max(units.iconSizes.small, label.paintedHeight) + surfaceNormal.margins.top + surfaceNormal.margins.bottom
property real minimumHeight: Math.max(units.iconSizes.small, label.implicitHeight) + surfaceNormal.margins.top + surfaceNormal.margins.bottom
/**
* This signal is emitted when the button is clicked.
@ -243,7 +243,6 @@ Item {
Label {
id: label
width: parent.width - icon.width - parent.spacing
height: parent.height
color: theme.buttonTextColor
@ -251,6 +250,8 @@ Item {
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
MouseArea {

View File

@ -87,12 +87,12 @@ Item {
//icon + label + left margin + right margin + spacing between icon and text
//here it assumesleft margin = right top = bottom, why?
// because the right and bottom margins can be disabled, so they would return 0, but their actual size is still needed for size hints
property real minimumWidth: Math.max(units.iconSizes.small, height) + label.paintedWidth + delegate.margins.left + delegate.margins.left + ((icon.valid) ? delegate.margins.left : 0)
property real minimumWidth: Math.max(units.iconSizes.small, height) + label.implicitWidth + delegate.margins.left + delegate.margins.left + ((icon.valid) ? delegate.margins.left : 0)
/**
* The smallest height this button can be to show all the contents
*/
property real minimumHeight: Math.max(units.iconSizes.small, label.paintedHeight) + delegate.margins.top + delegate.margins.top
property real minimumHeight: Math.max(units.iconSizes.small, label.implicitHeight) + delegate.margins.top + delegate.margins.top
LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft)
LayoutMirroring.childrenInherit: true
@ -371,6 +371,7 @@ Item {
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}