mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-18 00:57:16 +02:00
[ui] show unsaved project warning dialog also when computing from GraphEditor
This commit is contained in:
parent
6823695146
commit
28e7e64f3d
2 changed files with 68 additions and 36 deletions
|
@ -21,7 +21,10 @@ Item {
|
||||||
// signals
|
// signals
|
||||||
signal workspaceMoved()
|
signal workspaceMoved()
|
||||||
signal workspaceClicked()
|
signal workspaceClicked()
|
||||||
|
|
||||||
signal nodeDoubleClicked(var mouse, var node)
|
signal nodeDoubleClicked(var mouse, var node)
|
||||||
|
signal computeRequest(var node)
|
||||||
|
signal submitRequest(var node)
|
||||||
|
|
||||||
// trigger initial fit() after initialization
|
// trigger initial fit() after initialization
|
||||||
// (ensure GraphEditor has its final size)
|
// (ensure GraphEditor has its final size)
|
||||||
|
@ -279,14 +282,14 @@ Item {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Compute"
|
text: "Compute"
|
||||||
enabled: !uigraph.computing && !root.readOnly && nodeMenu.canComputeNode
|
enabled: !uigraph.computing && !root.readOnly && nodeMenu.canComputeNode
|
||||||
onTriggered: uigraph.execute(nodeMenu.currentNode)
|
onTriggered: computeRequest(nodeMenu.currentNode)
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Submit"
|
text: "Submit"
|
||||||
enabled: !uigraph.computing && !root.readOnly && nodeMenu.canComputeNode
|
enabled: !uigraph.computing && !root.readOnly && nodeMenu.canComputeNode
|
||||||
visible: uigraph.canSubmit
|
visible: uigraph.canSubmit
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: uigraph.submit(nodeMenu.currentNode)
|
onTriggered: submitRequest(nodeMenu.currentNode)
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Open Folder"
|
text: "Open Folder"
|
||||||
|
|
|
@ -139,24 +139,66 @@ ApplicationWindow {
|
||||||
onRejected: closed(Platform.Dialog.Rejected)
|
onRejected: closed(Platform.Dialog.Rejected)
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDialog {
|
Item {
|
||||||
id: unsavedComputeDialog
|
id: computeManager
|
||||||
|
|
||||||
canCopy: false
|
property bool warnIfUnsaved: true
|
||||||
icon.text: MaterialIcons.warning
|
|
||||||
preset: "Warning"
|
// evaluate if global reconstruction computation can be started
|
||||||
title: "Unsaved Project"
|
property bool canStartComputation: _reconstruction.viewpoints.count >= 2 // at least 2 images
|
||||||
text: "Data will be computed in the default cache folder if project remains unsaved."
|
&& !_reconstruction.computing // computation is not started
|
||||||
detailedText: "Default cache folder: " + _reconstruction.graph.cacheDir
|
&& _reconstruction.graph.canComputeLeaves // graph has no uncomputable nodes
|
||||||
helperText: "Save project first?"
|
|
||||||
standardButtons: Dialog.Discard | Dialog.Cancel | Dialog.Save
|
// evaluate if graph computation can be submitted externally
|
||||||
Component.onCompleted: {
|
property bool canSubmit: _reconstruction.canSubmit // current setup allows to compute externally
|
||||||
// set up discard button text
|
&& canStartComputation // can be computed
|
||||||
standardButton(Dialog.Discard).text = "Continue without Saving"
|
&& _reconstruction.graph.filepath // graph is saved on disk
|
||||||
|
|
||||||
|
function compute(node, force) {
|
||||||
|
if(!force && warnIfUnsaved && !_reconstruction.graph.filepath)
|
||||||
|
{
|
||||||
|
unsavedComputeDialog.currentNode = node;
|
||||||
|
unsavedComputeDialog.open();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_reconstruction.execute(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDiscarded: { close(); _reconstruction.execute(null) }
|
function submit(node) {
|
||||||
onAccepted: saveAsAction.trigger()
|
_reconstruction.submit(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MessageDialog {
|
||||||
|
id: unsavedComputeDialog
|
||||||
|
|
||||||
|
property var currentNode: null
|
||||||
|
|
||||||
|
canCopy: false
|
||||||
|
icon.text: MaterialIcons.warning
|
||||||
|
parent: Overlay.overlay
|
||||||
|
preset: "Warning"
|
||||||
|
title: "Unsaved Project"
|
||||||
|
text: "Data will be computed in the default cache folder if project remains unsaved."
|
||||||
|
detailedText: "Default cache folder: " + _reconstruction.graph.cacheDir
|
||||||
|
helperText: "Save project first?"
|
||||||
|
standardButtons: Dialog.Discard | Dialog.Cancel | Dialog.Save
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text: "Don't ask again for this session"
|
||||||
|
padding: 0
|
||||||
|
onToggled: computeManager.warnIfUnsaved = !checked
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// set up discard button text
|
||||||
|
standardButton(Dialog.Discard).text = "Continue without Saving"
|
||||||
|
}
|
||||||
|
|
||||||
|
onDiscarded: { close(); computeManager.compute(currentNode, true) }
|
||||||
|
onAccepted: saveAsAction.trigger()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Platform.FileDialog {
|
Platform.FileDialog {
|
||||||
|
@ -418,16 +460,6 @@ ApplicationWindow {
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
// evaluate if global reconstruction computation can be started
|
|
||||||
property bool canStartComputation: _reconstruction.viewpoints.count >= 2 // at least 2 images
|
|
||||||
&& !_reconstruction.computing // computation is not started
|
|
||||||
&& _reconstruction.graph.canComputeLeaves // graph has no uncomputable nodes
|
|
||||||
|
|
||||||
// evaluate if graph computation can be submitted externally
|
|
||||||
property bool canSubmit: _reconstruction.canSubmit // current setup allows to compute externally
|
|
||||||
&& canStartComputation // can be computed
|
|
||||||
&& _reconstruction.graph.filepath // graph is saved on disk
|
|
||||||
|
|
||||||
// disable controls if graph is executed externally
|
// disable controls if graph is executed externally
|
||||||
enabled: !_reconstruction.computingExternally
|
enabled: !_reconstruction.computingExternally
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
@ -438,13 +470,8 @@ ApplicationWindow {
|
||||||
palette.button: enabled ? buttonColor : disabledPalette.button
|
palette.button: enabled ? buttonColor : disabledPalette.button
|
||||||
palette.window: enabled ? buttonColor : disabledPalette.window
|
palette.window: enabled ? buttonColor : disabledPalette.window
|
||||||
palette.buttonText: enabled ? "white" : disabledPalette.buttonText
|
palette.buttonText: enabled ? "white" : disabledPalette.buttonText
|
||||||
enabled: parent.canStartComputation
|
enabled: computeManager.canStartComputation
|
||||||
onClicked: {
|
onClicked: computeManager.compute(null)
|
||||||
if(!_reconstruction.graph.filepath)
|
|
||||||
unsavedComputeDialog.open()
|
|
||||||
else
|
|
||||||
_reconstruction.execute(null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
text: "Stop"
|
text: "Stop"
|
||||||
|
@ -454,9 +481,9 @@ ApplicationWindow {
|
||||||
Item { width: 20; height: 1 }
|
Item { width: 20; height: 1 }
|
||||||
Button {
|
Button {
|
||||||
visible: _reconstruction.canSubmit
|
visible: _reconstruction.canSubmit
|
||||||
enabled: parent.canSubmit
|
enabled: computeManager.canSubmit
|
||||||
text: "Submit"
|
text: "Submit"
|
||||||
onClicked: _reconstruction.submit(null)
|
onClicked: computeManager.submit(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item { Layout.fillWidth: true; Layout.fillHeight: true }
|
Item { Layout.fillWidth: true; Layout.fillHeight: true }
|
||||||
|
@ -573,6 +600,8 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onComputeRequest: computeManager.compute(node)
|
||||||
|
onSubmitRequest: computeManager.submit(node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue