Add a maximumWidth to the ActionButton

In case the text is too long, it can exceed the limits of the container. This is an optional flag that will work only in case it's set up.

Contributes to CURA-6412.
This commit is contained in:
Diego Prado Gesto 2019-03-22 17:10:42 +01:00
parent 6611ab7d17
commit a793a06b60
2 changed files with 7 additions and 1 deletions

View file

@ -40,6 +40,10 @@ Button
// we elide the text to the right so the text will be cut off with the three dots at the end.
property var fixedWidthMode: false
// This property is used when the space for the button is limited. In case the button needs to grow with the text,
// but it can exceed a maximum, then this value have to be set.
property int maximumWidth: 0
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("action_button").height
@ -73,7 +77,7 @@ Button
renderType: Text.NativeRendering
height: parent.height
anchors.verticalCenter: parent.verticalCenter
width: fixedWidthMode ? button.width - button.leftPadding - button.rightPadding : undefined
width: fixedWidthMode ? button.width - button.leftPadding - button.rightPadding : ((maximumWidth != 0 && contentWidth > maximumWidth) ? maximumWidth : undefined)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight