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>2022-05-09 12:54:28 +0300
committerJaime van Kessel <nallath@gmail.com>2022-05-09 15:22:38 +0300
commitf483f04763ebbb119397c8bfdb00c3893d95e6fa (patch)
tree6368a12b3d1dd1c9961cd55d106b4e55888b8c72
parent763b40b8ec489a50cec23b77e8dda9022426dcb7 (diff)
Set the width of model loading drop-down to the max of all elements
Then set the elements to be equal to that width, so they fill the complete width of the drop-down. Contributes to issue CURA-9143.
-rw-r--r--plugins/PrepareStage/PrepareMenu.qml28
1 files changed, 18 insertions, 10 deletions
diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml
index d6bff1792e..42c3c8dde6 100644
--- a/plugins/PrepareStage/PrepareMenu.qml
+++ b/plugins/PrepareStage/PrepareMenu.qml
@@ -106,26 +106,34 @@ Item
{
id: openProviderColumn
- //The column doesn't automatically listen to its children rect if the children change internally, so we need to explicitly update the size.
- onChildrenRectChanged:
+ // Automatically set the width to fit the widest MenuItem
+ // Based on https://martin.rpdev.net/2018/03/13/qt-quick-controls-2-automatically-set-the-width-of-menus.html
+ function setWidth()
{
- popup.implicitHeight = childrenRect.height
- popup.implicitWidth = childrenRect.width
- }
- onPositioningComplete:
- {
- popup.implicitHeight = childrenRect.height
- popup.implicitWidth = childrenRect.width
+ var result = 0;
+ var padding = 0;
+ for (var i = 0; i < fileProviderRepeater.count; ++i) {
+ var item = fileProviderRepeater.itemAt(i);
+ if (item.hasOwnProperty("implicitWidth"))
+ {
+ var itemWidth = item.implicitWidth;
+ result = Math.max(itemWidth, result);
+ padding = Math.max(item.padding, padding);
+ }
+ }
+ return result + padding * 2;
}
+ width: setWidth()
Repeater
{
+ id: fileProviderRepeater
model: prepareMenu.fileProviderModel
delegate: Button
{
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
- width: contentItem.width + leftPadding + rightPadding
+ width: openProviderColumn.width
height: UM.Theme.getSize("action_button").height
hoverEnabled: true