mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 21:58:59 +08:00
Fix: Using onCompleted would break the binding. So Use a Binding instead
This commit is contained in:
parent
6d56b52913
commit
9d9753cb45
@ -49,15 +49,6 @@ Button
|
|||||||
height: UM.Theme.getSize("action_button").height
|
height: UM.Theme.getSize("action_button").height
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
if(fixedWidthMode){
|
|
||||||
buttonText.width = width - leftPadding - rightPadding
|
|
||||||
} else {
|
|
||||||
buttonText.width = (maximumWidth != 0 && contentWidth > maximumWidth) ? maximumWidth : undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
contentItem: Row
|
contentItem: Row
|
||||||
{
|
{
|
||||||
spacing: UM.Theme.getSize("narrow_margin").width
|
spacing: UM.Theme.getSize("narrow_margin").width
|
||||||
@ -93,12 +84,22 @@ Button
|
|||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
visible: text != ""
|
visible: text != ""
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
// width is set by parent because it depends on button.fixedWidthMode
|
|
||||||
height: parent.height
|
height: parent.height
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
|
||||||
|
Binding
|
||||||
|
{
|
||||||
|
// When settting width directly, an unjust binding loop warning would be triggered,
|
||||||
|
// because button.width is part of this expression.
|
||||||
|
// Using parent.width is fine in fixedWidthMode.
|
||||||
|
target: buttonText
|
||||||
|
property: "width"
|
||||||
|
value: button.fixedWidthMode ? button.width - button.leftPadding - button.rightPadding
|
||||||
|
: ((maximumWidth != 0 && contentWidth > maximumWidth) ? maximumWidth : undefined)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Right side icon. Only displayed if isIconOnRightSide.
|
//Right side icon. Only displayed if isIconOnRightSide.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user