[core/ui] Modifiable label and description of node available

This commit is contained in:
Aurore LAFAURIE 2024-04-25 17:03:33 +02:00
parent bb8b544550
commit 55c657dc1d
2 changed files with 27 additions and 3 deletions

View file

@ -68,6 +68,7 @@ class Attribute(BaseObject):
self._label = attributeDesc.label
self._enabled = True
self._validValue = True
self._description = attributeDesc.description
# invalidation value for output attributes
self._invalidationValue = ""
@ -212,6 +213,21 @@ class Attribute(BaseObject):
self.valueChanged.emit()
self.validValueChanged.emit()
def _set_label(self, label):
if self._label == label:
return
self._label = label
self.labelChanged.emit()
def _get_description(self):
return self._description
def _set_description(self, desc):
if self._description == desc:
return
self._description = desc
self.descriptionChanged.emit()
def upgradeValue(self, exportedValue):
self._set_value(exportedValue)
@ -364,14 +380,22 @@ class Attribute(BaseObject):
fullName = Property(str, getFullName, constant=True)
fullNameToNode = Property(str, getFullNameToNode, constant=True)
fullNameToGraph = Property(str, getFullNameToGraph, constant=True)
label = Property(str, getLabel, constant=True)
labelChanged = Signal()
label = Property(str, getLabel, _set_label, notify=labelChanged)
fullLabel = Property(str, getFullLabel, constant=True)
fullLabelToNode = Property(str, getFullLabelToNode, constant=True)
fullLabelToGraph = Property(str, getFullLabelToGraph, constant=True)
type = Property(str, getType, constant=True)
baseType = Property(str, getType, constant=True)
isReadOnly = Property(bool, _isReadOnly, constant=True)
# description of the attribute
descriptionChanged = Signal()
description = Property(str, _get_description, _set_description, notify=descriptionChanged)
# definition of the attribute
desc = Property(desc.Attribute, lambda self: self.attributeDesc, constant=True)
valueChanged = Signal()
value = Property(Variant, _get_value, _set_value, notify=valueChanged)
valueStr = Property(Variant, getValueStr, notify=valueChanged)

View file

@ -78,7 +78,7 @@ RowLayout {
var tooltip = ""
if (!object.validValue && object.desc.errorMessage !== "")
tooltip += "<i><b>Error: </b>" + Format.plainToHtml(object.desc.errorMessage) + "</i><br><br>"
tooltip += "<b>" + object.desc.name + "</b><br>" + Format.plainToHtml(object.desc.description)
tooltip += "<b>" + object.desc.name + "</b><br>" + Format.plainToHtml(object.description)
return tooltip
}
visible: parameterMA.containsMouse
@ -208,7 +208,7 @@ RowLayout {
Component {
id: pushButton_component
Button {
text: attribute.desc.label
text: attribute.label
enabled: root.editable
onClicked: {
attribute.clicked()