Skip to content

Commit

Permalink
Merge pull request #1839 from alicevision/dev/fixQmlWarnings
Browse files Browse the repository at this point in the history
[ui] Fix all "TypeError" QML warnings
  • Loading branch information
fabiencastan authored Dec 6, 2022
2 parents 67de413 + 02383c6 commit a2f559f
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 90 deletions.
7 changes: 5 additions & 2 deletions meshroom/ui/qml/GraphEditor/CompatibilityManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MessageDialog {
// the UIGraph instance
property var uigraph
// alias to underlying compatibilityNodes model
readonly property var nodesModel: uigraph.graph.compatibilityNodes
readonly property var nodesModel: uigraph ? uigraph.graph.compatibilityNodes : undefined
// the total number of compatibility issues
readonly property int issueCount: (nodesModel != undefined) ? nodesModel.count : 0
// the number of CompatibilityNodes that can be upgraded
Expand Down Expand Up @@ -47,7 +47,10 @@ MessageDialog {

title: "Compatibility issues detected"
text: "This project contains " + issueCount + " node(s) incompatible with the current version of Meshroom."
detailedText: "Project was created with Meshroom " + uigraph.graph.fileReleaseVersion + "."
detailedText: {
let releaseVersion = uigraph ? uigraph.graph.fileReleaseVersion : "0.0"
return "Project was created with Meshroom " + releaseVersion + "."
}

helperText: upgradableCount ?
upgradableCount + " node(s) can be upgraded but this might invalidate already computed data.\n"
Expand Down
4 changes: 2 additions & 2 deletions meshroom/ui/qml/GraphEditor/GraphEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ Item {
MenuItem {
text: "Submit"
enabled: nodeMenu.canComputeNode && nodeMenu.canSubmitOrCompute > 1
visible: uigraph.canSubmit
visible: uigraph ? uigraph.canSubmit : false
height: visible ? implicitHeight : 0
onTriggered: submitRequest(nodeMenu.currentNode)
}
Expand Down Expand Up @@ -759,7 +759,7 @@ Item {
flat: true
model: ['Minimum', 'Maximum']
implicitWidth: 80
currentIndex: uigraph.layout.depthMode
currentIndex: uigraph ? uigraph.layout.depthMode : -1
onActivated: {
uigraph.layout.depthMode = currentIndex
}
Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/GraphEditor/NodeDocumentation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FocusScope {
selectByMouse: true
selectionColor: activePalette.highlight
color: activePalette.text
text: node.documentation
text: node ? node.documentation : ""
wrapMode: TextEdit.Wrap
}
}
Expand Down
4 changes: 2 additions & 2 deletions meshroom/ui/qml/GraphEditor/TaskManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Item {

TextMetrics {
id: nbMetrics
text: root.taskManager.nodes.count
text: root.taskManager ? root.taskManager.nodes.count : "0"
}

TextMetrics {
Expand Down Expand Up @@ -67,7 +67,7 @@ Item {
anchors.fill: parent
ScrollBar.vertical: ScrollBar {}

model: parent.taskManager.nodes
model: parent.taskManager ? parent.taskManager.nodes : null
spacing: 3

headerPositioning: ListView.OverlayHeader
Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/ImageGallery/ImageDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Item {
}
MenuItem {
text: "Define As Center Image"
property var activeNode: _reconstruction.activeNodes.get("SfMTransform").node
property var activeNode: _reconstruction ? _reconstruction.activeNodes.get("SfMTransform").node : null
enabled: !root.readOnly && _viewpoint.viewId != -1 && _reconstruction && activeNode
onClicked: activeNode.attribute("transformation").value = _viewpoint.viewId.toString()
}
Expand Down
32 changes: 17 additions & 15 deletions meshroom/ui/qml/ImageGallery/ImageGallery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Panel {

QtObject {
id: m
property variant currentCameraInit: _reconstruction.tempCameraInit ? _reconstruction.tempCameraInit : root.cameraInit
property variant currentCameraInit: _reconstruction && _reconstruction.tempCameraInit ? _reconstruction.tempCameraInit : root.cameraInit
property variant viewpoints: currentCameraInit ? currentCameraInit.attribute('viewpoints').value : undefined
property variant intrinsics: currentCameraInit ? currentCameraInit.attribute('intrinsics').value : undefined
property bool readOnly: root.readOnly || displayHDR.checked
Expand Down Expand Up @@ -144,7 +144,7 @@ Panel {
SensorDBDialog {
id: sensorDBDialog
sensorDatabase: cameraInit ? Filepath.stringToUrl(cameraInit.attribute("sensorDatabase").value) : ""
readOnly: _reconstruction.computing
readOnly: _reconstruction ? _reconstruction.computing : false
onUpdateIntrinsicsRequest: _reconstruction.rebuildIntrinsics(cameraInit)
}

Expand Down Expand Up @@ -273,11 +273,11 @@ Panel {
spacing: 2

property bool valid: Qt.isQtObject(object) // object can be evaluated to null at some point during creation/deletion
property bool inViews: valid && _reconstruction.sfmReport && _reconstruction.isInViews(object)
property bool inViews: valid && _reconstruction && _reconstruction.sfmReport && _reconstruction.isInViews(object)

// Camera Initialization indicator
IntrinsicsIndicator {
intrinsic: parent.valid ? _reconstruction.getIntrinsic(object) : null
intrinsic: parent.valid && _reconstruction ? _reconstruction.getIntrinsic(object) : null
metadata: imageDelegate.metadata
}

Expand Down Expand Up @@ -540,7 +540,7 @@ Panel {

RowLayout {
Layout.fillHeight: false
visible: root.cameraInits.count > 1
visible: root.cameraInits ? root.cameraInits.count > 1 : false
Layout.alignment: Qt.AlignHCenter
spacing: 2

Expand All @@ -560,22 +560,24 @@ Panel {
// display of group indices (real indices still are from
// 0 to cameraInits.count - 1)
var l = [];
for (var i = 1; i <= root.cameraInits.count; i++) {
l.push(i);
if (root.cameraInits) {
for (var i = 1; i <= root.cameraInits.count; i++) {
l.push(i);
}
}
return l;
}
implicitWidth: 40
currentIndex: root.cameraInitIndex
onActivated: root.changeCurrentIndex(currentIndex)
}
Label { text: "/ " + (root.cameraInits.count) }
Label { text: "/ " + (root.cameraInits ? root.cameraInits.count : "Unknown") }
ToolButton {
text: MaterialIcons.navigate_next
font.family: MaterialIcons.fontFamily
ToolTip.text: "Next Group (Alt+Right)"
ToolTip.visible: hovered
enabled: nodesCB.currentIndex < root.cameraInits.count - 1
enabled: root.cameraInits ? nodesCB.currentIndex < root.cameraInits.count - 1 : false
onClicked: nodesCB.incrementCurrentIndex()
}
}
Expand Down Expand Up @@ -617,10 +619,10 @@ Panel {
Layout.minimumWidth: childrenRect.width
ToolTip.text: label + " Estimated Cameras"
iconText: MaterialIcons.videocam
label: _reconstruction.nbCameras ? _reconstruction.nbCameras.toString() : "-"
label: _reconstruction && _reconstruction.nbCameras ? _reconstruction.nbCameras.toString() : "-"
padding: 3

enabled: _reconstruction.cameraInit && _reconstruction.nbCameras
enabled: _reconstruction ? _reconstruction.cameraInit && _reconstruction.nbCameras : false
checkable: true
checked: false

Expand All @@ -646,10 +648,10 @@ Panel {
Layout.minimumWidth: childrenRect.width
ToolTip.text: label + " Non Estimated Cameras"
iconText: MaterialIcons.videocam_off
label: _reconstruction.nbCameras ? ((m.viewpoints ? m.viewpoints.count : 0) - _reconstruction.nbCameras.toString()).toString() : "-"
label: _reconstruction && _reconstruction.nbCameras ? ((m.viewpoints ? m.viewpoints.count : 0) - _reconstruction.nbCameras.toString()).toString() : "-"
padding: 3

enabled: _reconstruction.cameraInit && _reconstruction.nbCameras
enabled: _reconstruction ? _reconstruction.cameraInit && _reconstruction.nbCameras : false
checkable: true
checked: false

Expand Down Expand Up @@ -704,7 +706,7 @@ Panel {
MaterialToolLabelButton {
id: displayHDR
Layout.minimumWidth: childrenRect.width
property var activeNode: _reconstruction.activeNodes.get("LdrToHdrMerge").node
property var activeNode: _reconstruction ? _reconstruction.activeNodes.get("LdrToHdrMerge").node : null
ToolTip.text: "Visualize HDR images: " + (activeNode ? activeNode.label : "No Node")
iconText: MaterialIcons.filter
label: activeNode ? activeNode.attribute("nbBrackets").value : ""
Expand Down Expand Up @@ -747,7 +749,7 @@ Panel {
id: imageProcessing
Layout.minimumWidth: childrenRect.width

property var activeNode: _reconstruction.activeNodes.get("ImageProcessing").node
property var activeNode: _reconstruction ? _reconstruction.activeNodes.get("ImageProcessing").node : null
font.pointSize: 15
padding: 0
ToolTip.text: "Preprocessed Images: " + (activeNode ? activeNode.label : "No Node")
Expand Down
10 changes: 5 additions & 5 deletions meshroom/ui/qml/LiveSfmView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Panel {
id: root

property variant reconstruction
readonly property variant liveSfmManager: reconstruction.liveSfmManager
readonly property variant liveSfmManager: reconstruction ? reconstruction.liveSfmManager : null

title: "Live Reconstruction"
icon: Label {
Expand Down Expand Up @@ -41,7 +41,7 @@ Panel {
width: parent.width
GroupBox {
Layout.fillWidth: true
enabled: !liveSfmManager.running
enabled: liveSfmManager ? !liveSfmManager.running : false

GridLayout {
width: parent.width
Expand All @@ -59,7 +59,7 @@ Panel {
id: folderPath
Layout.fillWidth: true
selectByMouse: true
text: liveSfmManager.folder
text: liveSfmManager ? liveSfmManager.folder : ""
placeholderText: "Select a Folder"
}
ToolButton {
Expand Down Expand Up @@ -90,8 +90,8 @@ Panel {
Button {
Layout.alignment: Qt.AlignCenter
text: checked ? "Stop" : "Start"
enabled: liveSfmManager.running || folderPath.text.trim() != ''
checked: liveSfmManager.running
enabled: liveSfmManager ? liveSfmManager.running || folderPath.text.trim() != '' : false
checked: liveSfmManager ? liveSfmManager.running : false
onClicked: {
if(!liveSfmManager.running)
liveSfmManager.start(folderPath.text, minImg_SB.value)
Expand Down
Loading

0 comments on commit a2f559f

Please sign in to comment.