From 091346cbb8b83a3919df8907c973e5da88503121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Fri, 27 Jan 2023 11:00:51 +0100 Subject: [PATCH] [qml] Optimize QML files and fix syntax warnings This commit addresses warnings that were raised by QtCreator's linter: - IDs declared more than once - variables declared more than once in the same scope - type coercions - variables declared as "var" when their type is known - unclosed "case" in switch-case --- .../qml/GraphEditor/AttributeItemDelegate.qml | 2 +- meshroom/ui/qml/GraphEditor/AttributePin.qml | 12 +++---- meshroom/ui/qml/GraphEditor/Edge.qml | 2 +- meshroom/ui/qml/GraphEditor/GraphEditor.qml | 33 ++++++++++--------- meshroom/ui/qml/GraphEditor/Node.qml | 18 +++++----- meshroom/ui/qml/GraphEditor/TaskManager.qml | 22 ++++++------- .../ui/qml/Utils/SortFilterDelegateModel.qml | 2 +- meshroom/ui/qml/Viewer/ColorCheckerViewer.qml | 4 +-- .../ui/qml/Viewer/FeaturesInfoOverlay.qml | 8 ++--- meshroom/ui/qml/Viewer/FloatImage.qml | 2 +- meshroom/ui/qml/Viewer/ImageMetadataView.qml | 10 +++--- meshroom/ui/qml/Viewer/PanoramaViewer.qml | 33 +++++++++---------- meshroom/ui/qml/Viewer/Viewer2D.qml | 18 +++++----- .../qml/Viewer3D/DefaultCameraController.qml | 7 ++-- meshroom/ui/qml/Viewer3D/Inspector3D.qml | 4 +-- meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml | 2 +- meshroom/ui/qml/Viewer3D/Viewer3D.qml | 8 ++--- meshroom/ui/qml/main.qml | 9 ++--- 18 files changed, 99 insertions(+), 97 deletions(-) diff --git a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml index ee674764..497e3390 100644 --- a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml +++ b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml @@ -68,7 +68,7 @@ RowLayout { property Component menuComp: Menu { id: paramMenu - property bool isFileAttribute: attribute.type == "File" + property bool isFileAttribute: attribute.type === "File" property bool isFilepath: isFileAttribute && Filepath.isFile(attribute.evalValue) MenuItem { diff --git a/meshroom/ui/qml/GraphEditor/AttributePin.qml b/meshroom/ui/qml/GraphEditor/AttributePin.qml index 07fab760..effdf920 100755 --- a/meshroom/ui/qml/GraphEditor/AttributePin.qml +++ b/meshroom/ui/qml/GraphEditor/AttributePin.qml @@ -86,11 +86,11 @@ RowLayout { // Check if attributes are compatible to create a valid connection if( root.readOnly // cannot connect on a read-only attribute || drag.source.objectName != inputDragTarget.objectName // not an edge connector - || drag.source.baseType != inputDragTarget.baseType // not the same base type - || drag.source.nodeItem == inputDragTarget.nodeItem // connection between attributes of the same node + || drag.source.baseType !== inputDragTarget.baseType // not the same base type + || drag.source.nodeItem === inputDragTarget.nodeItem // connection between attributes of the same node || (drag.source.isList && !inputDragTarget.isList) // connection between a list and a simple attribute || (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children - || drag.source.connectorType == "input" // refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin) + || drag.source.connectorType === "input" // refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin) ) { // Refuse attributes connection @@ -235,11 +235,11 @@ RowLayout { onEntered: { // Check if attributes are compatible to create a valid connection if( drag.source.objectName != outputDragTarget.objectName // not an edge connector - || drag.source.baseType != outputDragTarget.baseType // not the same base type - || drag.source.nodeItem == outputDragTarget.nodeItem // connection between attributes of the same node + || drag.source.baseType !== outputDragTarget.baseType // not the same base type + || drag.source.nodeItem === outputDragTarget.nodeItem // connection between attributes of the same node || (!drag.source.isList && outputDragTarget.isList) // connection between a list and a simple attribute || (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children - || drag.source.connectorType == "output" // refuse to connect an output pin on another one + || drag.source.connectorType === "output" // refuse to connect an output pin on another one ) { // Refuse attributes connection diff --git a/meshroom/ui/qml/GraphEditor/Edge.qml b/meshroom/ui/qml/GraphEditor/Edge.qml index c31e8af1..1feef3e1 100644 --- a/meshroom/ui/qml/GraphEditor/Edge.qml +++ b/meshroom/ui/qml/GraphEditor/Edge.qml @@ -41,7 +41,7 @@ Shape { startY: root.startY fillColor: "transparent" strokeColor: "#3E3E3E" - strokeStyle: edge != undefined && ((edge.src != undefined && edge.src.isOutput) || edge.dst == undefined) ? ShapePath.SolidLine : ShapePath.DashLine + strokeStyle: edge !== undefined && ((edge.src !== undefined && edge.src.isOutput) || edge.dst === undefined) ? ShapePath.SolidLine : ShapePath.DashLine strokeWidth: 1 // final visual width of this path (never below 1) readonly property real visualWidth: Math.max(strokeWidth, 1) diff --git a/meshroom/ui/qml/GraphEditor/GraphEditor.qml b/meshroom/ui/qml/GraphEditor/GraphEditor.qml index 0fc630ce..e73b1383 100755 --- a/meshroom/ui/qml/GraphEditor/GraphEditor.qml +++ b/meshroom/ui/qml/GraphEditor/GraphEditor.qml @@ -67,10 +67,11 @@ Item { /// Duplicate a node and optionally all the following ones function duplicateNode(duplicateFollowingNodes) { + var nodes if (duplicateFollowingNodes) { - var nodes = uigraph.duplicateNodesFrom(uigraph.selectedNodes) + nodes = uigraph.duplicateNodesFrom(uigraph.selectedNodes) } else { - var nodes = uigraph.duplicateNodes(uigraph.selectedNodes) + nodes = uigraph.duplicateNodes(uigraph.selectedNodes) } uigraph.clearNodeSelection() uigraph.selectedNode = nodes[0] @@ -93,7 +94,7 @@ Item { var finalPosition = undefined var centerPosition = false if (mouseArea.containsMouse) { - if (uigraph.hoveredNode != null) { + if (uigraph.hoveredNode !== null) { var node = nodeDelegate(uigraph.hoveredNode) finalPosition = Qt.point(node.mousePosition.x + node.x, node.mousePosition.y + node.y) } else { @@ -124,7 +125,7 @@ Item { fit(); } else if (event.key === Qt.Key_Delete) { - if (event.modifiers == Qt.AltModifier) { + if (event.modifiers === Qt.AltModifier) { uigraph.removeNodesFrom(uigraph.selectedNodes); } else { @@ -132,15 +133,15 @@ Item { } } else if (event.key === Qt.Key_D) { - duplicateNode(event.modifiers == Qt.AltModifier); + duplicateNode(event.modifiers === Qt.AltModifier); } - else if (event.key === Qt.Key_C && event.modifiers == Qt.ControlModifier) { + else if (event.key === Qt.Key_C && event.modifiers === Qt.ControlModifier) { copyNodes(); } - else if (event.key === Qt.Key_V && event.modifiers == Qt.ControlModifier) { + else if (event.key === Qt.Key_V && event.modifiers === Qt.ControlModifier) { pasteNodes(); } - else if (event.key == Qt.Key_Tab) { + else if (event.key === Qt.Key_Tab) { event.accepted = true; if (mouseArea.containsMouse) { newNodeMenu.spawnPosition = mouseArea.mapToItem(draggable, mouseArea.mouseX, mouseArea.mouseY); @@ -329,7 +330,7 @@ Item { Repeater { id: nodeMenuRepeater - model: searchBar.text != "" ? Object.values(newNodeMenu.menuKeys) : undefined + model: searchBar.text !== "" ? Object.values(newNodeMenu.menuKeys) : undefined // create Menu items from available items delegate: menuItemDelegateComponent @@ -337,7 +338,7 @@ Item { // Dynamically add the menu categories Instantiator { - model: !(searchBar.text != "") ? Object.keys(newNodeMenu.parseCategories()).sort() : undefined + model: !(searchBar.text !== "") ? Object.keys(newNodeMenu.parseCategories()).sort() : undefined onObjectAdded: newNodeMenu.insertMenu(index+1, object ) // add sub-menu under the search bar onObjectRemoved: newNodeMenu.removeMenu(object) @@ -392,10 +393,10 @@ Item { delegate: Edge { property var src: root._attributeToDelegate[edge.src] property var dst: root._attributeToDelegate[edge.dst] - property bool isValidEdge: src != undefined && dst != undefined + property bool isValidEdge: src !== undefined && dst !== undefined visible: isValidEdge - property bool inFocus: containsMouse || (edgeMenu.opened && edgeMenu.currentEdge == edge) + property bool inFocus: containsMouse || (edgeMenu.opened && edgeMenu.currentEdge === edge) edge: object color: edge.dst === root.edgeAboutToBeRemoved ? "red" : inFocus ? activePalette.highlight : activePalette.text @@ -408,7 +409,7 @@ Item { onPressed: { const canEdit = !edge.dst.node.locked - if(event.button == Qt.RightButton) + if(event.button === Qt.RightButton) { if(canEdit && (event.modifiers & Qt.AltModifier)) { uigraph.removeEdge(edge) @@ -600,7 +601,7 @@ Item { onAttributePinDeleted: unregisterAttributePin(attribute, pin) onPressed: { - if (mouse.button == Qt.LeftButton) { + if (mouse.button === Qt.LeftButton) { if (mouse.modifiers & Qt.ControlModifier && !(mouse.modifiers & Qt.AltModifier)) { if (mainSelected && selected) { // left clicking a selected node twice with control will deselect it @@ -617,7 +618,7 @@ Item { } else if (!mainSelected && !selected) { uigraph.clearNodeSelection() } - } else if (mouse.button == Qt.RightButton) { + } else if (mouse.button === Qt.RightButton) { if (!mainSelected && !selected) { uigraph.clearNodeSelection() } @@ -663,7 +664,7 @@ Item { // update all selected nodes positions with this node that is being dragged for (var i = 0; i < nodeRepeater.count; i++) { var otherNode = nodeRepeater.itemAt(i) - if (uigraph.selectedNodes.contains(otherNode.node) && otherNode.node != node) { + if (uigraph.selectedNodes.contains(otherNode.node) && otherNode.node !== node) { otherNode.x = otherNode.node.x + (x - node.x) otherNode.y = otherNode.node.y + (y - node.y) } diff --git a/meshroom/ui/qml/GraphEditor/Node.qml b/meshroom/ui/qml/GraphEditor/Node.qml index ff2c5220..774189b9 100755 --- a/meshroom/ui/qml/GraphEditor/Node.qml +++ b/meshroom/ui/qml/GraphEditor/Node.qml @@ -100,8 +100,8 @@ Item { function isFileAttributeBaseType(attribute) { // ATM, only File attributes are meant to be connected // TODO: review this if we want to connect something else - return attribute.type == "File" - || (attribute.type == "ListAttribute" && attribute.desc.elementDesc.type == "File") + return attribute.type === "File" + || (attribute.type === "ListAttribute" && attribute.desc.elementDesc.type === "File") } // Used to generate list of node's label sharing the same uid @@ -480,22 +480,22 @@ Item { width: parent.width sourceComponent: AttributePin { - id: inPin + id: inParamsPin nodeItem: root - property real globalX: root.x + nodeAttributes.x + inputParamsRect.x + paramLoader.x + inPin.x - property real globalY: root.y + nodeAttributes.y + inputParamsRect.y + paramLoader.y + inPin.y + property real globalX: root.x + nodeAttributes.x + inputParamsRect.x + paramLoader.x + inParamsPin.x + property real globalY: root.y + nodeAttributes.y + inputParamsRect.y + paramLoader.y + inParamsPin.y height: isFullyActive ? childrenRect.height : 0 Behavior on height { PropertyAnimation {easing.type: Easing.Linear} } visible: (height == childrenRect.height) attribute: object readOnly: root.readOnly || object.isReadOnly - Component.onCompleted: attributePinCreated(attribute, inPin) - Component.onDestruction: attributePinDeleted(attribute, inPin) + Component.onCompleted: attributePinCreated(attribute, inParamsPin) + Component.onDestruction: attributePinDeleted(attribute, inParamsPin) onPressed: root.pressed(mouse) onEdgeAboutToBeRemoved: root.edgeAboutToBeRemoved(input) - onChildPinCreated: attributePinCreated(childAttribute, inPin) - onChildPinDeleted: attributePinDeleted(childAttribute, inPin) + onChildPinCreated: attributePinCreated(childAttribute, inParamsPin) + onChildPinDeleted: attributePinDeleted(childAttribute, inParamsPin) } } } diff --git a/meshroom/ui/qml/GraphEditor/TaskManager.qml b/meshroom/ui/qml/GraphEditor/TaskManager.qml index 74707937..a5735ba1 100644 --- a/meshroom/ui/qml/GraphEditor/TaskManager.qml +++ b/meshroom/ui/qml/GraphEditor/TaskManager.qml @@ -164,9 +164,9 @@ Item { Layout.preferredHeight: parent.height horizontalAlignment: Label.AlignHCenter verticalAlignment: Label.AlignVCenter - color: object == uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text + color: object === uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text background: Rectangle { - color: object == uigraph.selectedNode ? Colors.sysPalette.text : bgColor + color: object === uigraph.selectedNode ? Colors.sysPalette.text : bgColor } MouseArea { @@ -182,9 +182,9 @@ Item { Layout.preferredHeight: parent.height horizontalAlignment: Label.AlignHCenter verticalAlignment: Label.AlignVCenter - color: object == uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text + color: object === uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text background: Rectangle { - color: object == uigraph.selectedNode ? Colors.sysPalette.text : bgColor + color: object === uigraph.selectedNode ? Colors.sysPalette.text : bgColor } MouseArea { @@ -200,9 +200,9 @@ Item { Layout.preferredHeight: parent.height horizontalAlignment: Label.AlignHCenter verticalAlignment: Label.AlignVCenter - color: object == uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text + color: object === uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text background: Rectangle { - color: object == uigraph.selectedNode ? Colors.sysPalette.text : bgColor + color: object === uigraph.selectedNode ? Colors.sysPalette.text : bgColor } MouseArea { @@ -218,9 +218,9 @@ Item { Layout.preferredHeight: parent.height horizontalAlignment: Label.AlignHCenter verticalAlignment: Label.AlignVCenter - color: object == uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text + color: object === uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text background: Rectangle { - color: object == uigraph.selectedNode ? Colors.sysPalette.text : bgColor + color: object === uigraph.selectedNode ? Colors.sysPalette.text : bgColor } MouseArea { @@ -236,9 +236,9 @@ Item { Layout.preferredHeight: parent.height horizontalAlignment: Label.AlignHCenter verticalAlignment: Label.AlignVCenter - color: object == uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text + color: object === uigraph.selectedNode ? Colors.sysPalette.window : Colors.sysPalette.text background: Rectangle { - color: object == uigraph.selectedNode ? Colors.sysPalette.text : bgColor + color: object === uigraph.selectedNode ? Colors.sysPalette.text : bgColor } MouseArea { @@ -271,7 +271,7 @@ Item { color: Colors.getChunkColor(object, {"NONE": bgColor}) radius: 3 border.width: 2 - border.color: chunkList.node == uigraph.selectedNode ? Colors.sysPalette.text : Colors.getChunkColor(object, {"NONE": bgColor}) + border.color: chunkList.node === uigraph.selectedNode ? Colors.sysPalette.text : Colors.getChunkColor(object, {"NONE": bgColor}) } diff --git a/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml b/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml index aacb01a9..adfd4217 100644 --- a/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml +++ b/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml @@ -70,7 +70,7 @@ DelegateModel { function find(value, roleName) { for(var i = 0; i < filteredItems.count; ++i) { - if(modelData(filteredItems.get(i), roleName) == value) + if(modelData(filteredItems.get(i), roleName) === value) return i } return -1 diff --git a/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml b/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml index f0cce3a1..c173b0da 100644 --- a/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml +++ b/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml @@ -74,8 +74,8 @@ Item { for (var i = 0; i < root.json.checkers.length; i++) { // Only load ccheckers for the current view var checker = root.json.checkers[i] - if (checker.viewId == viewId || - checker.imagePath == currentImagePath) { + if (checker.viewId === viewId || + checker.imagePath === currentImagePath) { var cpt = Qt.createComponent("ColorCheckerEntity.qml"); var obj = cpt.createObject(root, { diff --git a/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml b/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml index 0460f24b..ced49055 100644 --- a/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml +++ b/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml @@ -163,14 +163,14 @@ FloatingPane { editable: true textFromValue: function(value, locale) { - if (value == -1) return "No Limit"; - if (value == 0) return "Disable"; + if (value === -1) return "No Limit"; + if (value === 0) return "Disable"; return value; } valueFromText: function(text, locale) { - if (text == "No Limit") return -1; - if (text == "Disable") return 0; + if (text === "No Limit") return -1; + if (text === "Disable") return 0; return Number.fromLocaleString(locale, text); } diff --git a/meshroom/ui/qml/Viewer/FloatImage.qml b/meshroom/ui/qml/Viewer/FloatImage.qml index a6c91cfc..611b4e57 100644 --- a/meshroom/ui/qml/Viewer/FloatImage.qml +++ b/meshroom/ui/qml/Viewer/FloatImage.qml @@ -63,7 +63,7 @@ AliceVision.FloatImageViewer { property int pointsNumber: (surface.subdivisions + 1) * (surface.subdivisions + 1); property int index: 0; - property var idView: 0; + property int idView: 0; clearBeforeLoad: true diff --git a/meshroom/ui/qml/Viewer/ImageMetadataView.qml b/meshroom/ui/qml/Viewer/ImageMetadataView.qml index e878be4f..82d86e8e 100644 --- a/meshroom/ui/qml/Viewer/ImageMetadataView.qml +++ b/meshroom/ui/qml/Viewer/ImageMetadataView.qml @@ -45,7 +45,7 @@ FloatingPane { function getGPSCoordinates(metadata) { // GPS data available - if(metadata && metadata["GPS:Longitude"] != undefined && metadata["GPS:Latitude"] != undefined) + if(metadata && metadata["GPS:Longitude"] !== undefined && metadata["GPS:Latitude"] !== undefined) { var latitude = gpsMetadataToCoordinates(metadata["GPS:Latitude"], metadata["GPS:LatitudeRef"]) var longitude = gpsMetadataToCoordinates(metadata["GPS:Longitude"], metadata["GPS:LongitudeRef"]) @@ -79,11 +79,11 @@ FloatingPane { var entry = {} // split on ":" to get group and key var i = key.lastIndexOf(":") - if(i == -1) + if(i === -1) { i = key.lastIndexOf("/") } - if(i != -1) + if(i !== -1) { entry["group"] = key.substr(0, i) entry["key"] = key.substr(i+1) @@ -190,7 +190,7 @@ FloatingPane { sortRole: "raw" filters: [{role: "raw", value: searchBar.text}] delegate: RowLayout { - width: parent.width + width: parent ? parent.width : 0 Label { text: key leftPadding: 6 @@ -289,7 +289,7 @@ FloatingPane { anchors.right: parent.right anchors.top: parent.top padding: 2 - visible: map.center != coordinates + visible: map.center !== coordinates ToolButton { font.family: MaterialIcons.fontFamily diff --git a/meshroom/ui/qml/Viewer/PanoramaViewer.qml b/meshroom/ui/qml/Viewer/PanoramaViewer.qml index 6287c35f..6978a1ed 100644 --- a/meshroom/ui/qml/Viewer/PanoramaViewer.qml +++ b/meshroom/ui/qml/Viewer/PanoramaViewer.qml @@ -28,7 +28,7 @@ AliceVision.PanoramaViewer { } } - property var readyToLoad: Image.Null + property int readyToLoad: Image.Null property int subdivisionsPano: 12 @@ -42,7 +42,7 @@ AliceVision.PanoramaViewer { property bool cropFisheyePano: false - property var idSelected : -1 + property int idSelected : -1 onIsHighlightableChanged:{ for (var i = 0; i < repeater.model; ++i) { @@ -53,26 +53,26 @@ AliceVision.PanoramaViewer { property alias containsMouse: mouseAreaPano.containsMouse property bool isRotating: false - property var lastX : 0 - property var lastY: 0 + property double lastX : 0 + property double lastY: 0 - property var xStart : 0 - property var yStart : 0 + property double xStart : 0 + property double yStart : 0 - property var previous_yaw: 0; - property var previous_pitch: 0; - property var previous_roll: 0; + property double previous_yaw: 0; + property double previous_pitch: 0; + property double previous_roll: 0; property double yaw: 0; property double pitch: 0; property double roll: 0; - property var activeNode: _reconstruction.activeNodes.get('SfMTransform').node + property var activeNode: _reconstruction.activeNodes.get('SfMTransform').node; // Yaw and Pitch in Degrees from SfMTransform node sliders - property int yawNode: activeNode.attribute("manualTransform.manualRotation.y").value; - property int pitchNode: activeNode.attribute("manualTransform.manualRotation.x").value; - property int rollNode: activeNode.attribute("manualTransform.manualRotation.z").value; + property double yawNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.y").value : 0; + property double pitchNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.x").value : 0; + property double rollNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.z").value : 0; //Convert angle functions function toDegrees(radians){ @@ -137,9 +137,7 @@ AliceVision.PanoramaViewer { // Rotate Panorama if (isRotating && isEditable) { - var nx = Math.max(0, mouse.x) var nx = Math.min(width - 1, mouse.x) - var ny = Math.max(0, mouse.y) var ny = Math.min(height - 1, mouse.y) var xoffset = nx - lastX; @@ -156,17 +154,18 @@ AliceVision.PanoramaViewer { var end_pt = Qt.vector2d(latitude_end, longitude_end) var previous_euler = Qt.vector3d(previous_yaw, previous_pitch, previous_roll) + var result if (mouse.modifiers & Qt.ControlModifier) { - var result = Transformations3DHelper.updatePanoramaInPlane(previous_euler, start_pt, end_pt) + result = Transformations3DHelper.updatePanoramaInPlane(previous_euler, start_pt, end_pt) root.pitch = result.x root.yaw = result.y root.roll = result.z } else { - var result = Transformations3DHelper.updatePanorama(previous_euler, start_pt, end_pt) + result = Transformations3DHelper.updatePanorama(previous_euler, start_pt, end_pt) root.pitch = result.x root.yaw = result.y root.roll = result.z diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index 89025252..8cfa5e88 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -99,7 +99,7 @@ FocusScope { // slots Keys.onPressed: { - if(event.key == Qt.Key_F) { + if(event.key === Qt.Key_F) { root.fit(); event.accepted = true; } @@ -147,7 +147,7 @@ FocusScope { // make sure the image is ready for use if(!imgContainer.image) return; - if(imgContainer.image.status != Image.Ready) + if(imgContainer.image.status !== Image.Ready) return; // for Exif orientation tags 5 to 8, a 90 degrees rotation is applied @@ -225,7 +225,7 @@ FocusScope { return ""; for (var i = 0; i < node.attributes.count; i++) { var attr = node.attributes.at(i); - if (attr.name == attrName) { + if (attr.name === attrName) { let path = String(attr.value) for (var key in patterns) { if (patterns.hasOwnProperty(key)) { @@ -333,7 +333,7 @@ FocusScope { { return null; } - if(floatImageViewerLoader.item.containsMouse == false) + if(floatImageViewerLoader.item.containsMouse === false) { return null; } @@ -389,9 +389,9 @@ FocusScope { orientationTag: imgContainer.orientationTag xOrigin: imgContainer.width / 2 yOrigin: imgContainer.height / 2 - property var fittedOnce: false - property var previousWidth: 0 - property var previousHeight: 0 + property bool fittedOnce: false + property int previousWidth: 0 + property int previousHeight: 0 onHeightChanged: { /* Image size is not updated through a single signal with the floatImage viewer, unlike * the simple QML image viewer: instead of updating straight away the width and height to x and @@ -404,7 +404,7 @@ FocusScope { * group has already been auto-fitted. If we change the group of images (when another project is * opened, for example, and the images have a different size), then another auto-fit needs to be * performed */ - if ((!fittedOnce && imgContainer.image.status == Image.Ready && imgContainer.image.height > 0) || + if ((!fittedOnce && imgContainer.image && imgContainer.image.status === Image.Ready && imgContainer.image.height > 0) || (fittedOnce && ((width > 1 && previousWidth != width) || (height > 1 && previousHeight != height)))) { fit(); fittedOnce = true; @@ -1135,7 +1135,7 @@ FocusScope { font.pointSize: 11 Layout.minimumWidth: 0 checkable: true - enabled: activeNode && activeNode.isComputed && _reconstruction.selectedViewId != -1 + enabled: activeNode && activeNode.isComputed && _reconstruction.selectedViewId !== -1 checked: false visible: activeNode onEnabledChanged: { diff --git a/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml b/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml index 0f884a33..e4aa175a 100644 --- a/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml +++ b/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml @@ -63,10 +63,11 @@ Entity { currentPosition.x = mouse.x; currentPosition.y = mouse.y; - const dt = 0.02 + const dt = 0.02; + var d; if(panning) { // translate - var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03; + d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03; var tx = axisMX.value * root.translateSpeed * d; var ty = axisMY.value * root.translateSpeed * d; mouseHandler.hasMoved = true; @@ -80,7 +81,7 @@ Entity { return; } if(zooming) { // zoom with alt + RMD - var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.1; + d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.1; var tz = axisMX.value * root.translateSpeed * d; mouseHandler.hasMoved = true; root.camera.translate(Qt.vector3d(0, 0, tz).times(dt), Camera.DontTranslateViewCenter) diff --git a/meshroom/ui/qml/Viewer3D/Inspector3D.qml b/meshroom/ui/qml/Viewer3D/Inspector3D.qml index d8794e8e..60b14c9b 100644 --- a/meshroom/ui/qml/Viewer3D/Inspector3D.qml +++ b/meshroom/ui/qml/Viewer3D/Inspector3D.qml @@ -344,12 +344,12 @@ FloatingPane { text: model.label opacity: model.valid ? 1.0 : 0.6 elide: Text.ElideMiddle - font.weight: mediaListView.currentIndex == index ? Font.DemiBold : Font.Normal + font.weight: mediaListView.currentIndex === index ? Font.DemiBold : Font.Normal background: Rectangle { Connections { target: mediaLibrary function onLoadRequest(idx) { - if(idx == index) + if(idx === index) focusAnim.restart() } } diff --git a/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml b/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml index 74136665..108c22ab 100644 --- a/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml +++ b/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml @@ -39,7 +39,7 @@ Entity { return for(var i=0; i < entity.components.length; ++i) { - if(entity.components[i].toString().indexOf(type) != -1) + if(entity.components[i].toString().indexOf(type) !== -1) { //entity.components[i].enabled = false; Scene3DHelper.removeComponent(entity, entity.components[i]); diff --git a/meshroom/ui/qml/Viewer3D/Viewer3D.qml b/meshroom/ui/qml/Viewer3D/Viewer3D.qml index 588b583e..e8be4706 100644 --- a/meshroom/ui/qml/Viewer3D/Viewer3D.qml +++ b/meshroom/ui/qml/Viewer3D/Viewer3D.qml @@ -88,7 +88,7 @@ FocusScope { ] Keys.onPressed: { - if (event.key == Qt.Key_F) { + if (event.key === Qt.Key_F) { resetCameraPosition(); } else if(Qt.Key_1 <= event.key && event.key < Qt.Key_1 + Viewer3DSettings.renderModes.length) @@ -168,7 +168,7 @@ FocusScope { focus: scene3D.activeFocus onMousePressed: { scene3D.forceActiveFocus() - if(mouse.button == Qt.LeftButton) + if(mouse.button === Qt.LeftButton) { if(!doubleClickTimer.running) doubleClickTimer.restart() @@ -179,7 +179,7 @@ FocusScope { onMouseReleased: { if(moving) return - if(!moved && mouse.button == Qt.RightButton) + if(!moved && mouse.button === Qt.RightButton) { contextMenu.popup() } @@ -260,7 +260,7 @@ FocusScope { ] onPressed: { - if(pick.button == Qt.LeftButton) + if(pick.button === Qt.LeftButton) { mainCamera.viewCenter = pick.worldIntersection; } diff --git a/meshroom/ui/qml/main.qml b/meshroom/ui/qml/main.qml index 80dc4c20..f4f49b67 100644 --- a/meshroom/ui/qml/main.qml +++ b/meshroom/ui/qml/main.qml @@ -120,7 +120,7 @@ ApplicationWindow { { saveFileDialog.open() function _callbackWrapper(rc) { - if(rc == Platform.Dialog.Accepted) + if(rc === Platform.Dialog.Accepted) fireCallback() saveFileDialog.closed.disconnect(_callbackWrapper) } @@ -277,6 +277,7 @@ ApplicationWindow { case "Compatibility Issue": { close() compatibilityManager.open() + break } default: close() } @@ -577,7 +578,7 @@ ApplicationWindow { Menu { id: newPipelineMenu title: "New Pipeline" - enabled: newPipelineMenuItems.model != undefined && newPipelineMenuItems.model.length > 0 + enabled: newPipelineMenuItems.model !== undefined && newPipelineMenuItems.model.length > 0 property int maxWidth: 1000 property int fullWidth: { var result = 0; @@ -621,7 +622,7 @@ ApplicationWindow { Menu { id: openRecentMenu title: "Open Recent" - enabled: recentFilesMenuItems.model != undefined && recentFilesMenuItems.model.length > 0 + enabled: recentFilesMenuItems.model !== undefined && recentFilesMenuItems.model.length > 0 property int maxWidth: 1000 property int fullWidth: { var result = 0; @@ -961,7 +962,7 @@ ApplicationWindow { // 3D viewer for (var i = 0; i < node.attributes.count; i++) { var attr = node.attributes.at(i) - if(attr.isOutput && attr.desc.semantic != "image" && workspaceView.viewIn3D(attr, mouse)) + if(attr.isOutput && attr.desc.semantic !== "image" && workspaceView.viewIn3D(attr, mouse)) break; } }