Skip to content

Commit

Permalink
[ui] Add an icon and tooltip on a node's header if it has a comment
Browse files Browse the repository at this point in the history
If the "Comments" internal attribute is filled, add a corresponding
icon in the node's header, as well as a tooltip that contains the
comment.
  • Loading branch information
cbentejac committed Oct 13, 2022
1 parent 0ff15ab commit 5399c4d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,15 @@ def getColor(self):
return self.internalAttribute("color").value.strip()
return ""

def getComment(self):
"""
Returns:
str: the comments on the node if they exist, empty string otherwise
"""
if self.hasInternalAttribute("comment"):
return self.internalAttribute("comment").value
return ""

@Slot(str, result=str)
def nameToLabel(self, name):
"""
Expand Down Expand Up @@ -1083,6 +1092,7 @@ def canBeCanceled(self):
name = Property(str, getName, constant=True)
label = Property(str, getLabel, constant=True)
color = Property(str, getColor, constant=True)
comment = Property(str, getComment, constant=True)
nodeType = Property(str, nodeType.fget, constant=True)
documentation = Property(str, getDocumentation, constant=True)
positionChanged = Signal()
Expand Down
26 changes: 26 additions & 0 deletions meshroom/ui/qml/GraphEditor/Node.qml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Item {
onInternalAttributesChanged: {
nodeLabel.text = node ? node.label : ""
background.color = (node.color === "" ? Qt.lighter(activePalette.base, 1.4) : node.color)
nodeCommentTooltip.text = node ? node.comment : ""
nodeComment.visible = node.comment != ""
}
}

Expand Down Expand Up @@ -258,6 +260,30 @@ Item {
palette.text: "red"
ToolTip.text: "Locked"
}

MaterialLabel {
id: nodeComment
visible: node.comment != ""
text: MaterialIcons.comment
padding: 2
font.pointSize: 7

ToolTip {
id: nodeCommentTooltip
parent: header
visible: nodeCommentMA.containsMouse && nodeComment.visible
text: node.comment
implicitWidth: 400 // Forces word-wrap for long comments but the tooltip will be bigger than needed for short comments
delay: 300
}

MouseArea {
// If the node header is hovered, comments may be displayed
id: nodeCommentMA
anchors.fill: parent
hoverEnabled: true
}
}
}
}
}
Expand Down

0 comments on commit 5399c4d

Please sign in to comment.