mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-03 08:48:40 +02:00
Compare last saved date before saving to prevent overwrite
This commit is contained in:
parent
bc139d13e7
commit
e63c2df2a8
3 changed files with 56 additions and 1 deletions
|
@ -368,6 +368,36 @@ ApplicationWindow {
|
|||
onDiscarded: close()
|
||||
onAccepted: saveAsAction.trigger()
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: fileModifiedDialog
|
||||
|
||||
canCopy: false
|
||||
icon.text: MaterialIcons.warning
|
||||
parent: Overlay.overlay
|
||||
preset: "Warning"
|
||||
title: "File Modified"
|
||||
text: "The file has been modified by another instance."
|
||||
detailedText: "Do you want to overwrite the file?"
|
||||
|
||||
// Add a reload file button next to the save button
|
||||
footer: DialogButtonBox {
|
||||
position: DialogButtonBox.Footer
|
||||
standardButtons: Dialog.Save | Dialog.Cancel
|
||||
|
||||
Button {
|
||||
text: "Reload File"
|
||||
|
||||
onClicked: {
|
||||
_reconstruction.loadUrl(_reconstruction.graph.filepath)
|
||||
fileModifiedDialog.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAccepted: _reconstruction.save()
|
||||
onDiscarded: close()
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
|
@ -715,7 +745,14 @@ ApplicationWindow {
|
|||
enabled: _reconstruction ? (_reconstruction.graph && !_reconstruction.graph.filepath) || !_reconstruction.undoStack.clean : false
|
||||
onTriggered: {
|
||||
if (_reconstruction.graph.filepath) {
|
||||
_reconstruction.save()
|
||||
// get current time date
|
||||
var date = _reconstruction.graph.getFileDateVersionFromPath(_reconstruction.graph.filepath)
|
||||
|
||||
// check if the file has been modified by another instance
|
||||
if (_reconstruction.graph.fileDateVersion !== date) {
|
||||
fileModifiedDialog.open()
|
||||
} else
|
||||
_reconstruction.save()
|
||||
} else {
|
||||
initFileDialogFolder(saveFileDialog)
|
||||
saveFileDialog.open()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue