Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2021-07-08 17:24:23 +0300
committerGhostkeeper <rubend@tutanota.com>2021-07-08 18:49:44 +0300
commitffa89bb1a16380c41e05846b7bd2073d6d50f00e (patch)
tree395931fd921bc5d725c061b9cbe861258d5d7f0a /plugins/PrepareStage
parent920e220bdb5fe335f00ac23c7f6a0ec8369598cf (diff)
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.
Diffstat (limited to 'plugins/PrepareStage')
-rw-r--r--plugins/PrepareStage/PrepareMenu.qml36
1 files changed, 24 insertions, 12 deletions
diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml
index 2d3814309e..4e6c37961c 100644
--- a/plugins/PrepareStage/PrepareMenu.qml
+++ b/plugins/PrepareStage/PrepareMenu.qml
@@ -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")
-
- sourceSize.height: height
+ id: openFileIconContainer
+ height: parent.height
+ width: height //Square button.
+
+ 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
+ }
}
}