From 0db1f1034b164b783ff395afc87e7cdc1e13a183 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 9 Jul 2021 16:47:51 +0200 Subject: [PATCH] Add header, and make popup grow to its contents It was quite a hassle to allow the column to grow to the size of its contents. For some reason, things update the size to 0. And the size updates again once the pop-up actually gets opened for the first time, because then the column actually gets populated lazily. Contributes to issue CURA-8008. --- plugins/PrepareStage/PrepareMenu.qml | 38 ++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 219979407b..1916a5813d 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -1,7 +1,7 @@ // Copyright (c) 2021 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.7 +import QtQuick 2.9 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.3 @@ -99,11 +99,39 @@ Item sourceSize.height: height } - contentItem: Rectangle + contentItem: Item { - width: 100 - height: 100 - color: "red" + id: popup + width: openProviderColumn.width + height: openProviderColumn.height + + Column + { + 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: + { + popup.height = childrenRect.height + popup.width = childrenRect.width + } + onPositioningComplete: + { + popup.height = childrenRect.height + popup.width = childrenRect.width + } + + Label + { + text: catalog.i18nc("@menu:header", "Open file") + color: UM.Theme.getColor("text_medium") + font: UM.Theme.getFont("medium") + renderType: Text.NativeRendering + + width: contentWidth + height: contentHeight + } + } } }