mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-03 08:48:40 +02:00
[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
This commit is contained in:
parent
8c2a7bba0f
commit
091346cbb8
18 changed files with 99 additions and 97 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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})
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue