[GraphEditor] AttributeEditor: fix dynamic setting of attributes' height

By setting the height on the "onLoaded" event, no height update was
possible unless the component was unloaded (which happens when "active"
gets set to false) first and then reloaded (which happens when "active"
gets set to true). If an attribute was to be hidden (by unchecking the
"advanced attributes" checkbox, for example), its content was effectively
hidden, but as its height was not being updated, a blank block remained
in its place.

Similarly, for attributes that are filled with a lot of content after
being initialized (ChoiceParams, for example), the height was set once
at the attribute's initialization but never updated afterwards.
This commit is contained in:
Candice Bentéjac 2023-01-27 11:08:58 +01:00
parent 091346cbb8
commit 6fdbf66607

View file

@ -34,8 +34,14 @@ ListView {
onDoubleClicked: root.attributeDoubleClicked(mouse, attr)
}
onLoaded: {
height: item ? item.implicitHeight : -spacing // compensate for spacing if item is hidden
onActiveChanged: height = active ? item.implicitHeight : -spacing
Connections {
target: item
function onImplicitHeightChanged() {
// Handles cases where an attribute is created and its height is then updated as it is filled
height = item.implicitHeight
}
}
}