From 1015ea448a76efd213319a8f18e09cf1402888d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Thu, 13 Oct 2022 14:57:24 +0200 Subject: [PATCH] [ui] Add an icon and tooltip on a node's header if it has a comment 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. --- meshroom/core/node.py | 10 ++++++++++ meshroom/ui/qml/GraphEditor/Node.qml | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/meshroom/core/node.py b/meshroom/core/node.py index 8a1eac5c..3ff0c6ca 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -541,6 +541,15 @@ class BaseNode(BaseObject): 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): """ @@ -1104,6 +1113,7 @@ class BaseNode(BaseObject): 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() diff --git a/meshroom/ui/qml/GraphEditor/Node.qml b/meshroom/ui/qml/GraphEditor/Node.qml index 6ddd30d1..85b9563f 100755 --- a/meshroom/ui/qml/GraphEditor/Node.qml +++ b/meshroom/ui/qml/GraphEditor/Node.qml @@ -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 != "" } } @@ -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 + } + } } } }