[ui] GraphEditor: fix some readOnly regarding CompatibilityNodes

This commit is contained in:
Fabien Castan 2021-01-22 14:30:33 +01:00
parent 382e350bcd
commit 078120696a
4 changed files with 14 additions and 4 deletions

View file

@ -93,6 +93,9 @@ class Attribute(BaseObject):
def getType(self):
return self.attributeDesc.__class__.__name__
def _isReadOnly(self):
return not self._isOutput and self.node.isCompatibilityNode
def getBaseType(self):
return self.getType()
@ -262,6 +265,7 @@ class Attribute(BaseObject):
label = Property(str, getLabel, constant=True)
type = Property(str, getType, constant=True)
baseType = Property(str, getType, constant=True)
isReadOnly = Property(bool, _isReadOnly, constant=True)
desc = Property(desc.Attribute, lambda self: self.attributeDesc, constant=True)
valueChanged = Signal()
value = Property(Variant, _get_value, _set_value, notify=valueChanged)

View file

@ -865,6 +865,9 @@ class BaseNode(BaseObject):
fusedStatus.merge(node.fusedStatus)
return fusedStatus
def _isCompatibilityNode(self):
return False
@property
def globalExecMode(self):
return self._chunks.at(0).execModeName
@ -1031,6 +1034,7 @@ class BaseNode(BaseObject):
fusedStatus = Property(StatusData, getFusedStatus, notify=globalStatusChanged)
elapsedTime = Property(float, lambda self: self.getFusedStatus().elapsedTime, notify=globalStatusChanged)
recursiveElapsedTime = Property(float, lambda self: self.getRecursiveFusedStatus().elapsedTime, notify=globalStatusChanged)
isCompatibilityNode = Property(bool, lambda self: self._isCompatibilityNode(), constant=True) # need lambda to evaluate the virtual function
globalExecModeChanged = Signal()
globalExecMode = Property(str, globalExecMode.fget, notify=globalExecModeChanged)
@ -1167,6 +1171,9 @@ class CompatibilityNode(BaseNode):
for i in range(self.splitCount)
])
def _isCompatibilityNode(self):
return True
@staticmethod
def attributeDescFromValue(attrName, value, isOutput):
"""

View file

@ -222,7 +222,7 @@ Item {
id: edgeMenu
property var currentEdge: null
MenuItem {
enabled: edgeMenu.currentEdge && !edgeMenu.currentEdge.dst.node.locked
enabled: edgeMenu.currentEdge && !edgeMenu.currentEdge.dst.node.locked && !edgeMenu.currentEdge.dst.isReadOnly
text: "Remove"
onTriggered: uigraph.removeEdge(edgeMenu.currentEdge)
}

View file

@ -270,8 +270,6 @@ Item {
height: childrenRect.height
anchors.horizontalCenter: parent.horizontalCenter
enabled: !root.isCompatibilityNode
Column {
id: attributesColumn
width: parent.width
@ -311,6 +309,7 @@ Item {
id: inputs
width: parent.width
spacing: 3
Repeater {
model: node ? node.attributes : undefined
delegate: Loader {
@ -326,7 +325,7 @@ Item {
property real globalX: root.x + nodeAttributes.x + inputs.x + inputLoader.x + inPin.x
property real globalY: root.y + nodeAttributes.y + inputs.y + inputLoader.y + inPin.y
readOnly: root.readOnly
readOnly: root.readOnly || root.isCompatibilityNode
Component.onCompleted: attributePinCreated(attribute, inPin)
Component.onDestruction: attributePinDeleted(attribute, inPin)
onPressed: root.pressed(mouse)