Viewer2D: Update list of loaded node's outputs when they are en/dis-abled

When a node with viewable output attributes is loaded, the combo box  of
the 2D Viewer lists these attributes. As some of these attributes are
enabled or disabled, they need to be added or removed from that list,
without needing to load another node first, or to unload the node.

This commit connects the signal that is emitted when an output attribute
with a viewable output is enabled or disabled to the slot that reloads
the currently loaded node (and thus updates the list).
This commit is contained in:
Candice Bentéjac 2023-03-07 09:19:50 +01:00 committed by Loïc Vital
parent 349f488fbd
commit 2b232b0c85
2 changed files with 11 additions and 3 deletions

View file

@ -184,7 +184,7 @@ FocusScope {
var hasImageOutputAttr = false;
for (var i = 0; i < node.attributes.count; i++) {
var attr = node.attributes.at(i);
if (attr.isOutput && attr.desc.semantic == "image") {
if (attr.isOutput && attr.desc.semantic === "image" && attr.enabled) {
hasImageOutputAttr = true;
break;
}
@ -280,7 +280,7 @@ FocusScope {
// store attr name for output attributes that represent images
for (var i = 0; i < displayedNode.attributes.count; i++) {
var attr = displayedNode.attributes.at(i);
if (attr.isOutput && attr.desc.semantic == "image") {
if (attr.isOutput && attr.desc.semantic === "image" && attr.enabled) {
names.push(attr.name);
}
}
@ -300,6 +300,10 @@ FocusScope {
}
}
Connections {
target: displayedNode
onOutputAttrEnabledChanged: tryLoadNode(displayedNode)
}
// context menu
property Component contextMenu: Menu {
MenuItem {
@ -1193,7 +1197,7 @@ FocusScope {
property var names: ["gallery"]
property string name: names[currentIndex]
model: names.map(n => (n == "gallery") ? "Image Gallery" : displayedNode.attributes.get(n).label)
model: names.map(n => (n === "gallery") ? "Image Gallery" : displayedNode.attributes.get(n).label)
enabled: count > 1
FontMetrics {