[qml] Clean-up: Harmonize syntax across all files

This commit is contained in:
Candice Bentéjac 2023-10-17 15:42:51 +02:00
parent e9d80611c7
commit e463f0dce2
6 changed files with 99 additions and 94 deletions

View file

@ -14,7 +14,11 @@ Dialog {
// Fade in transition // Fade in transition
enter: Transition { enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 } NumberAnimation {
property: "opacity"
from: 0.0
to: 1.0
}
} }
modal: true modal: true
@ -173,14 +177,14 @@ Dialog {
// try to load the local file // try to load the local file
var url = Filepath.stringToUrl(modelData.localUrl) var url = Filepath.stringToUrl(modelData.localUrl)
// fallback to the online url if file is not found // fallback to the online url if file is not found
if(!Filepath.exists(url)) if (!Filepath.exists(url))
url = modelData.onlineUrl url = modelData.onlineUrl
Request.get(url, Request.get(url,
function(xhr){ function(xhr) {
if(xhr.readyState === XMLHttpRequest.DONE) if (xhr.readyState === XMLHttpRequest.DONE)
{ {
// status is OK // status is OK
if(xhr.status === 200) if (xhr.status === 200)
textArea.text = MeshroomApp.markdownToHtml(xhr.responseText) textArea.text = MeshroomApp.markdownToHtml(xhr.responseText)
else else
textArea.text = "Could not load license file. Available online at <a href='" + url + "'>"+ url + "</a>." textArea.text = "Could not load license file. Available online at <a href='" + url + "'>"+ url + "</a>."

View file

@ -93,7 +93,7 @@ Panel {
enabled: liveSfmManager ? liveSfmManager.running || folderPath.text.trim() != '' : false enabled: liveSfmManager ? liveSfmManager.running || folderPath.text.trim() != '' : false
checked: liveSfmManager ? liveSfmManager.running : false checked: liveSfmManager ? liveSfmManager.running : false
onClicked: { onClicked: {
if(!liveSfmManager.running) if (!liveSfmManager.running)
liveSfmManager.start(folderPath.text, minImg_SB.value) liveSfmManager.start(folderPath.text, minImg_SB.value)
else else
liveSfmManager.stop() liveSfmManager.stop()

View file

@ -19,14 +19,13 @@ ToolButton {
} }
background: Rectangle { background: Rectangle {
color: { color: {
if(pressed || checked || hovered) if (pressed || checked || hovered) {
{ if (pressed || checked)
if(pressed || checked)
return Qt.darker(parent.palette.base, 1.3) return Qt.darker(parent.palette.base, 1.3)
if(hovered) if (hovered)
return Qt.darker(parent.palette.base, 0.6) return Qt.darker(parent.palette.base, 0.6)
} }
return "transparent"; return "transparent"
} }
border.color: checked ? Qt.darker(parent.palette.base, 1.4) : "transparent" border.color: checked ? Qt.darker(parent.palette.base, 1.4) : "transparent"

View file

@ -36,14 +36,13 @@ ToolButton {
} }
background: Rectangle { background: Rectangle {
color: { color: {
if(pressed || checked || hovered) if (pressed || checked || hovered) {
{ if (pressed || checked)
if(pressed || checked)
return Qt.darker(parent.palette.base, 1.3) return Qt.darker(parent.palette.base, 1.3)
if(hovered) if (hovered)
return Qt.darker(parent.palette.base, 0.6) return Qt.darker(parent.palette.base, 0.6)
} }
return "transparent"; return "transparent"
} }
border.color: checked ? Qt.darker(parent.palette.base, 1.4) : "transparent" border.color: checked ? Qt.darker(parent.palette.base, 1.4) : "transparent"

View file

@ -32,15 +32,15 @@ Item {
// Load a 3D media file in the 3D viewer // Load a 3D media file in the 3D viewer
function load3DMedia(filepath, label = undefined) { function load3DMedia(filepath, label = undefined) {
if(panel3dViewerLoader.active) { if (panel3dViewerLoader.active) {
panel3dViewerLoader.item.viewer3D.load(filepath, label); panel3dViewerLoader.item.viewer3D.load(filepath, label)
} }
} }
Connections { Connections {
target: reconstruction target: reconstruction
function onGraphChanged() { function onGraphChanged() {
if(panel3dViewerLoader.active) { if (panel3dViewerLoader.active) {
panel3dViewerLoader.item.viewer3D.clear() panel3dViewerLoader.item.viewer3D.clear()
} }
} }
@ -51,11 +51,11 @@ Item {
// Load reconstruction's current SfM file // Load reconstruction's current SfM file
function viewSfM() { function viewSfM() {
var activeNode = _reconstruction.activeNodes ? _reconstruction.activeNodes.get('sfm').node : null; var activeNode = _reconstruction.activeNodes ? _reconstruction.activeNodes.get('sfm').node : null
if(!activeNode) if (!activeNode)
return; return
if(panel3dViewerLoader.active) { if (panel3dViewerLoader.active) {
panel3dViewerLoader.item.viewer3D.view(activeNode.attribute('output')); panel3dViewerLoader.item.viewer3D.view(activeNode.attribute('output'))
} }
} }

View file

@ -34,9 +34,9 @@ ApplicationWindow {
onClosing: { onClosing: {
// make sure document is saved before exiting application // make sure document is saved before exiting application
close.accepted = false close.accepted = false
if(!ensureNotComputing()) if (!ensureNotComputing())
return return
ensureSaved(function(){ Qt.quit() }) ensureSaved(function() { Qt.quit() })
} }
palette: _PaletteManager.palette palette: _PaletteManager.palette
@ -134,7 +134,7 @@ ApplicationWindow {
onAccepted: { onAccepted: {
// save current file // save current file
if(saveAction.enabled) if (saveAction.enabled)
{ {
saveAction.trigger() saveAction.trigger()
fireCallback() fireCallback()
@ -144,7 +144,7 @@ ApplicationWindow {
{ {
saveFileDialog.open() saveFileDialog.open()
function _callbackWrapper(rc) { function _callbackWrapper(rc) {
if(rc === Platform.Dialog.Accepted) if (rc === Platform.Dialog.Accepted)
fireCallback() fireCallback()
saveFileDialog.closed.disconnect(_callbackWrapper) saveFileDialog.closed.disconnect(_callbackWrapper)
} }
@ -155,7 +155,7 @@ ApplicationWindow {
function fireCallback() function fireCallback()
{ {
// call the callback and reset it // call the callback and reset it
if(_callback) if (_callback)
_callback() _callback()
_callback = undefined _callback = undefined
} }
@ -215,7 +215,7 @@ ApplicationWindow {
false false
function compute(node, force) { function compute(node, force) {
if(!force && warnIfUnsaved && !_reconstruction.graph.filepath) if (!force && warnIfUnsaved && !_reconstruction.graph.filepath)
{ {
unsavedComputeDialog.currentNode = node; unsavedComputeDialog.currentNode = node;
unsavedComputeDialog.open(); unsavedComputeDialog.open();
@ -226,7 +226,7 @@ ApplicationWindow {
} }
catch (error) { catch (error) {
const data = ErrorHandler.analyseError(error) const data = ErrorHandler.analyseError(error)
if(data.context === "COMPUTATION") if (data.context === "COMPUTATION")
computeSubmitErrorDialog.openError(data.type, data.msg, node) computeSubmitErrorDialog.openError(data.type, data.msg, node)
} }
} }
@ -241,7 +241,7 @@ ApplicationWindow {
} }
catch (error) { catch (error) {
const data = ErrorHandler.analyseError(error) const data = ErrorHandler.analyseError(error)
if(data.context === "SUBMITTING") if (data.context === "SUBMITTING")
computeSubmitErrorDialog.openError(data.type, data.msg, node) computeSubmitErrorDialog.openError(data.type, data.msg, node)
} }
} }
@ -255,10 +255,18 @@ ApplicationWindow {
function openError(type, msg, node) { function openError(type, msg, node) {
errorType = type errorType = type
switch(type) { switch (type) {
case "Already Submitted": this.setupPendingStatusError(msg, node); break case "Already Submitted": {
case "Compatibility Issue": this.setupCompatibilityIssue(msg); break this.setupPendingStatusError(msg, node)
default: this.onlyDisplayError(msg) break
}
case "Compatibility Issue": {
this.setupCompatibilityIssue(msg)
break
}
default: {
this.onlyDisplayError(msg)
}
} }
this.open() this.open()
@ -291,7 +299,7 @@ ApplicationWindow {
text: "" text: ""
onAccepted: { onAccepted: {
switch(errorType) { switch (errorType) {
case "Already Submitted": { case "Already Submitted": {
close() close()
_reconstruction.graph.clearSubmittedNodes() _reconstruction.graph.clearSubmittedNodes()
@ -337,7 +345,11 @@ ApplicationWindow {
standardButton(Dialog.Discard).text = "Continue without Saving" standardButton(Dialog.Discard).text = "Continue without Saving"
} }
onDiscarded: { close(); computeManager.compute(currentNode, true) } onDiscarded: {
close()
computeManager.compute(currentNode, true)
}
onAccepted: saveAsAction.trigger() onAccepted: saveAsAction.trigger()
} }
@ -363,8 +375,7 @@ ApplicationWindow {
title: "Open File" title: "Open File"
nameFilters: ["Meshroom Graphs (*.mg)"] nameFilters: ["Meshroom Graphs (*.mg)"]
onAccepted: { onAccepted: {
if(_reconstruction.loadUrl(fileUrl)) if (_reconstruction.loadUrl(fileUrl)) {
{
MeshroomApp.addRecentProjectFile(fileUrl.toString()) MeshroomApp.addRecentProjectFile(fileUrl.toString())
} }
} }
@ -413,13 +424,9 @@ ApplicationWindow {
function ensureSaved(callback) function ensureSaved(callback)
{ {
var saved = _reconstruction.undoStack.clean var saved = _reconstruction.undoStack.clean
// If current document is modified, open "unsaved dialog" if (!saved) { // If current document is modified, open "unsaved dialog"
if(!saved)
{
unsavedDialog.prompt(callback) unsavedDialog.prompt(callback)
} } else { // Otherwise, directly call the callback
else // otherwise, directly call the callback
{
callback() callback()
} }
return saved return saved
@ -438,7 +445,7 @@ ApplicationWindow {
// Check and return whether no local computation is in progress // Check and return whether no local computation is in progress
function ensureNotComputing() function ensureNotComputing()
{ {
if(_reconstruction.computingLocally) if (_reconstruction.computingLocally)
{ {
// Open a warning dialog to ask for computation to be stopped // Open a warning dialog to ask for computation to be stopped
computingAtExitDialog.open() computingAtExitDialog.open()
@ -578,23 +585,23 @@ ApplicationWindow {
let folder = ""; let folder = "";
if (imagesFolder.toString() === "" && workspaceView.imageGallery.galleryGrid.itemAtIndex(0) !== null) { if (imagesFolder.toString() === "" && workspaceView.imageGallery.galleryGrid.itemAtIndex(0) !== null) {
imagesFolder = Filepath.stringToUrl(Filepath.dirname(workspaceView.imageGallery.galleryGrid.itemAtIndex(0).source)); imagesFolder = Filepath.stringToUrl(Filepath.dirname(workspaceView.imageGallery.galleryGrid.itemAtIndex(0).source))
} }
if (_reconstruction.graph && _reconstruction.graph.filepath) { if (_reconstruction.graph && _reconstruction.graph.filepath) {
folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath)); folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath))
} else { } else {
var projects = MeshroomApp.recentProjectFiles; var projects = MeshroomApp.recentProjectFiles;
if (projects.length > 0 && Filepath.exists(projects[0])) { if (projects.length > 0 && Filepath.exists(projects[0])) {
folder = Filepath.stringToUrl(Filepath.dirname(projects[0])); folder = Filepath.stringToUrl(Filepath.dirname(projects[0]))
} }
} }
if (importImages && imagesFolder.toString() !== "" && Filepath.exists(imagesFolder)) { if (importImages && imagesFolder.toString() !== "" && Filepath.exists(imagesFolder)) {
folder = imagesFolder; folder = imagesFolder
} }
dialog.folder = folder; dialog.folder = folder
} }
header: MenuBar { header: MenuBar {
@ -609,8 +616,8 @@ ApplicationWindow {
property int fullWidth: { property int fullWidth: {
var result = 0; var result = 0;
for (var i = 0; i < count; ++i) { for (var i = 0; i < count; ++i) {
var item = itemAt(i); var item = itemAt(i)
result = Math.max(item.implicitWidth + item.padding * 2, result); result = Math.max(item.implicitWidth + item.padding * 2, result)
} }
return result; return result;
} }
@ -641,8 +648,8 @@ ApplicationWindow {
text: "Open" text: "Open"
shortcut: "Ctrl+O" shortcut: "Ctrl+O"
onTriggered: ensureSaved(function() { onTriggered: ensureSaved(function() {
initFileDialogFolder(openFileDialog); initFileDialogFolder(openFileDialog)
openFileDialog.open(); openFileDialog.open()
}) })
} }
Menu { Menu {
@ -653,10 +660,10 @@ ApplicationWindow {
property int fullWidth: { property int fullWidth: {
var result = 0; var result = 0;
for (var i = 0; i < count; ++i) { for (var i = 0; i < count; ++i) {
var item = itemAt(i); var item = itemAt(i)
result = Math.max(item.implicitWidth + item.padding * 2, result); result = Math.max(item.implicitWidth + item.padding * 2, result)
} }
return result; return result
} }
implicitWidth: fullWidth implicitWidth: fullWidth
Repeater { Repeater {
@ -664,14 +671,11 @@ ApplicationWindow {
model: MeshroomApp.recentProjectFiles model: MeshroomApp.recentProjectFiles
MenuItem { MenuItem {
onTriggered: ensureSaved(function() { onTriggered: ensureSaved(function() {
openRecentMenu.dismiss(); openRecentMenu.dismiss()
if(_reconstruction.loadUrl(modelData)) if (_reconstruction.loadUrl(modelData)) {
{ MeshroomApp.addRecentProjectFile(modelData)
MeshroomApp.addRecentProjectFile(modelData); } else {
} MeshroomApp.removeRecentProjectFile(modelData)
else
{
MeshroomApp.removeRecentProjectFile(modelData);
} }
}) })
@ -692,13 +696,11 @@ ApplicationWindow {
shortcut: "Ctrl+S" shortcut: "Ctrl+S"
enabled: _reconstruction ? (_reconstruction.graph && !_reconstruction.graph.filepath) || !_reconstruction.undoStack.clean : false enabled: _reconstruction ? (_reconstruction.graph && !_reconstruction.graph.filepath) || !_reconstruction.undoStack.clean : false
onTriggered: { onTriggered: {
if(_reconstruction.graph.filepath) { if (_reconstruction.graph.filepath) {
_reconstruction.save(); _reconstruction.save()
} } else {
else initFileDialogFolder(saveFileDialog)
{ saveFileDialog.open()
initFileDialogFolder(saveFileDialog);
saveFileDialog.open();
} }
} }
} }
@ -707,8 +709,8 @@ ApplicationWindow {
text: "Save As..." text: "Save As..."
shortcut: "Ctrl+Shift+S" shortcut: "Ctrl+Shift+S"
onTriggered: { onTriggered: {
initFileDialogFolder(saveFileDialog); initFileDialogFolder(saveFileDialog)
saveFileDialog.open(); saveFileDialog.open()
} }
} }
MenuSeparator { } MenuSeparator { }
@ -717,8 +719,8 @@ ApplicationWindow {
text: "Import Images" text: "Import Images"
shortcut: "Ctrl+I" shortcut: "Ctrl+I"
onTriggered: { onTriggered: {
initFileDialogFolder(importImagesDialog, true); initFileDialogFolder(importImagesDialog, true)
importImagesDialog.open(); importImagesDialog.open()
} }
} }
@ -743,8 +745,8 @@ ApplicationWindow {
onActivated: saveAsTemplateAction.triggered() onActivated: saveAsTemplateAction.triggered()
} }
onTriggered: { onTriggered: {
initFileDialogFolder(saveTemplateDialog); initFileDialogFolder(saveTemplateDialog)
saveTemplateDialog.open(); saveTemplateDialog.open()
} }
} }
@ -763,8 +765,8 @@ ApplicationWindow {
onActivated: importProjectAction.triggered() onActivated: importProjectAction.triggered()
} }
onTriggered: { onTriggered: {
initFileDialogFolder(importProjectDialog); initFileDialogFolder(importProjectDialog)
importProjectDialog.open(); importProjectDialog.open()
} }
} }
@ -896,7 +898,7 @@ ApplicationWindow {
function onGraphChanged() { function onGraphChanged() {
// open CompatibilityManager after file loading if any issue is detected // open CompatibilityManager after file loading if any issue is detected
if(compatibilityManager.issueCount) if (compatibilityManager.issueCount)
compatibilityManager.open() compatibilityManager.open()
// trigger fit to visualize all nodes // trigger fit to visualize all nodes
graphEditor.fit() graphEditor.fit()
@ -984,24 +986,25 @@ ApplicationWindow {
function viewNode(node, mouse) { function viewNode(node, mouse) {
// 2D viewer // 2D viewer
viewer2D.tryLoadNode(node); viewer2D.tryLoadNode(node)
// 3D viewer // 3D viewer
for (var i = 0; i < node.attributes.count; i++) { for (var i = 0; i < node.attributes.count; i++) {
var attr = node.attributes.at(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; break
} }
} }
function viewIn3D(attribute, mouse) { function viewIn3D(attribute, mouse) {
if(!panel3dViewer || !attribute.node.has3DOutput) if (!panel3dViewer || !attribute.node.has3DOutput)
return false; return false
var loaded = panel3dViewer.viewer3D.view(attribute); var loaded = panel3dViewer.viewer3D.view(attribute)
// solo media if Control modifier was held // solo media if Control modifier was held
if(loaded && mouse && mouse.modifiers & Qt.ControlModifier) if (loaded && mouse && mouse.modifiers & Qt.ControlModifier)
panel3dViewer.viewer3D.solo(attribute); panel3dViewer.viewer3D.solo(attribute)
return loaded; return loaded
} }
} }
} }
@ -1203,8 +1206,8 @@ ApplicationWindow {
readOnly: node ? node.locked : false readOnly: node ? node.locked : false
onUpgradeRequest: { onUpgradeRequest: {
var n = _reconstruction.upgradeNode(node); var n = _reconstruction.upgradeNode(node)
_reconstruction.selectedNode = n; _reconstruction.selectedNode = n
} }
} }
} }