mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-11 21:09:00 +08:00
Allow open file button to resize depending on content items
This re-links the widths, heights and paddings such that we can later change the width of the button depending on its contents. However there is a complication: Buttons automatically change the size of the contents based on the size of the button minus its padding. So making the size of the button in turn depend on its contents causes a binding loop. To get around this binding loop, we need to manually calculate the size of the button, such that the size of the contents ends up exactly right. Contributes to issue CURA-8008.
This commit is contained in:
parent
920e220bdb
commit
ffa89bb1a1
@ -77,24 +77,36 @@ Item
|
||||
Button
|
||||
{
|
||||
id: openFileButton
|
||||
|
||||
//Make the button square if the contents are.
|
||||
leftPadding: topPadding
|
||||
rightPadding: topPadding
|
||||
bottomPadding: topPadding
|
||||
|
||||
height: UM.Theme.getSize("stage_menu").height
|
||||
width: UM.Theme.getSize("stage_menu").height
|
||||
width: openFileIconContainer.width + leftPadding + rightPadding
|
||||
onClicked: Cura.Actions.open.trigger()
|
||||
hoverEnabled: true
|
||||
|
||||
contentItem: Item
|
||||
contentItem: Row
|
||||
{
|
||||
anchors.fill: parent
|
||||
UM.RecolorImage
|
||||
Item
|
||||
{
|
||||
id: buttonIcon
|
||||
anchors.centerIn: parent
|
||||
source: UM.Theme.getIcon("Folder", "medium")
|
||||
width: UM.Theme.getSize("button_icon").width
|
||||
height: UM.Theme.getSize("button_icon").height
|
||||
color: UM.Theme.getColor("icon")
|
||||
id: openFileIconContainer
|
||||
height: parent.height
|
||||
width: height //Square button.
|
||||
|
||||
sourceSize.height: height
|
||||
UM.RecolorImage
|
||||
{
|
||||
id: buttonIcon
|
||||
anchors.centerIn: parent
|
||||
source: UM.Theme.getIcon("Folder", "medium")
|
||||
width: UM.Theme.getSize("button_icon").width
|
||||
height: UM.Theme.getSize("button_icon").height
|
||||
color: UM.Theme.getColor("icon")
|
||||
|
||||
sourceSize.height: height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user