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.
This commit is contained in:
Ghostkeeper 2021-07-09 16:47:51 +02:00
parent 5bc3848301
commit 0db1f1034b
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,7 +1,7 @@
// Copyright (c) 2021 Ultimaker B.V. // Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher. // 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.Layouts 1.1
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
@ -99,11 +99,39 @@ Item
sourceSize.height: height sourceSize.height: height
} }
contentItem: Rectangle contentItem: Item
{ {
width: 100 id: popup
height: 100 width: openProviderColumn.width
color: "red" 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
}
}
} }
} }