From d2c26c3c84b95721acb34160f985f942f96aaa6c Mon Sep 17 00:00:00 2001 From: Yann Lanthony Date: Tue, 28 Nov 2017 11:05:05 +0100 Subject: [PATCH] [ui] GraphEditor: add readOnly mode * disable node/edge edition * make GraphEditor readOnly when graph is being computed --- meshroom/ui/qml/AttributePin.qml | 2 ++ meshroom/ui/qml/GraphEditor.qml | 7 ++++--- meshroom/ui/qml/Node.qml | 5 +++++ meshroom/ui/qml/main.qml | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/meshroom/ui/qml/AttributePin.qml b/meshroom/ui/qml/AttributePin.qml index 0980ac55..2bd24afe 100755 --- a/meshroom/ui/qml/AttributePin.qml +++ b/meshroom/ui/qml/AttributePin.qml @@ -9,6 +9,7 @@ Row { property var nodeItem property var attribute + property bool readOnly: false // position of the anchor for attaching and edge to this attribute pin readonly property point edgeAnchorPos: Qt.point(edgeAnchor.x + edgeAnchor.width/2, @@ -88,6 +89,7 @@ Row { id: connectMA drag.target: dragTarget drag.threshold: 0 + enabled: !root.readOnly anchors.fill: parent onReleased: dragTarget.Drag.drop() } diff --git a/meshroom/ui/qml/GraphEditor.qml b/meshroom/ui/qml/GraphEditor.qml index a68779c7..4e87195a 100755 --- a/meshroom/ui/qml/GraphEditor.qml +++ b/meshroom/ui/qml/GraphEditor.qml @@ -9,7 +9,7 @@ Item { id: root property variant graph: null - + property bool readOnly: false property variant selectedNode: null property int nodeWidth: 140 @@ -80,14 +80,14 @@ Item { property var dstAnchor: dst.nodeItem.mapFromItem(dst, dst.edgeAnchorPos.x, dst.edgeAnchorPos.y) edge: object - color: containsMouse ? palette.highlight : palette.text + color: containsMouse && !readOnly ? palette.highlight : palette.text opacity: 0.7 point1x: src.nodeItem.x + srcAnchor.x point1y: src.nodeItem.y + srcAnchor.y point2x: dst.nodeItem.x + dstAnchor.x point2y: dst.nodeItem.y + dstAnchor.y onPressed: { - if(event.button == Qt.RightButton) + if(!root.readOnly && event.button == Qt.RightButton) _reconstruction.removeEdge(edge) } } @@ -104,6 +104,7 @@ Item { delegate: Node { node: object width: root.nodeWidth + readOnly: root.readOnly onAttributePinCreated: registerAttributePin(attribute, pin) diff --git a/meshroom/ui/qml/Node.qml b/meshroom/ui/qml/Node.qml index 42dfc7b6..14eb572d 100755 --- a/meshroom/ui/qml/Node.qml +++ b/meshroom/ui/qml/Node.qml @@ -6,6 +6,7 @@ import QtGraphicalEffects 1.0 Item { id: root property variant node: object + property bool readOnly: false property color baseColor: "#607D8B" property color shadowColor: "black" @@ -30,6 +31,7 @@ Item { id: nodeMenu MenuItem { text: "Compute" + enabled: !root.readOnly onTriggered: _reconstruction.execute(node) } MenuItem { @@ -39,6 +41,7 @@ Item { MenuSeparator {} MenuItem { text: "Delete" + enabled: !root.readOnly onTriggered: _reconstruction.removeNode(node) } } @@ -133,6 +136,7 @@ Item { id: inPin nodeItem: root attribute: object + readOnly: root.readOnly Component.onCompleted: attributePinCreated(attribute, inPin) onChildPinCreated: attributePinCreated(childAttribute, inPin) } @@ -155,6 +159,7 @@ Item { id: outPin nodeItem: root attribute: object + readOnly: root.readOnly Component.onCompleted: attributePinCreated(object, outPin) } } diff --git a/meshroom/ui/qml/main.qml b/meshroom/ui/qml/main.qml index c6458e45..9c6846ff 100755 --- a/meshroom/ui/qml/main.qml +++ b/meshroom/ui/qml/main.qml @@ -280,6 +280,7 @@ ApplicationWindow { graph: _reconstruction.graph Layout.fillHeight: true Layout.fillWidth: true + readOnly: _reconstruction.computing } } Item {