Skip to content

Commit e897bdc

Browse files
committed
[ui] Add new saveAs window
1 parent cca5cc5 commit e897bdc

7 files changed

Lines changed: 804 additions & 40 deletions

File tree

meshroom/core/graph.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,20 @@ def _unsetFilepath(self):
14831483
self.cacheDir = ""
14841484
self.filepathChanged.emit()
14851485

1486+
@Slot(result=str)
1487+
def getCurrentFilename(self):
1488+
if os.path.exists(self._filepath):
1489+
return os.path.basename(self._filepath)
1490+
else:
1491+
return ""
1492+
1493+
@Slot(result=str)
1494+
def getCurrentFolder(self):
1495+
if os.path.exists(self._filepath):
1496+
return os.path.dirname(self._filepath)
1497+
else:
1498+
return os.getcwd()
1499+
14861500
def updateInternals(self, startNodes=None, force=False):
14871501
nodes, edges = self.dfsOnFinish(startNodes=startNodes)
14881502
for node in nodes:

meshroom/ui/graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ def _saveAs(self, url, setupProjectFile=True, template=False):
531531
# ensure file is saved with ".mg" extension
532532
if os.path.splitext(localFile)[-1] != ".mg":
533533
localFile += ".mg"
534+
self.parent().showMessage(f"Saving file to {localFile}", "ok")
534535
self._graph.save(localFile, setupProjectFile=setupProjectFile, template=template)
535536
self._undoStack.setClean()
536537
# saving file on disk impacts cache folder location

meshroom/ui/qml/Application.qml

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import GraphEditor 1.0
1212
import MaterialIcons 2.2
1313
import Utils 1.0
1414
import Controls 1.0
15+
import Dialogs 1.0
1516

1617
Page {
1718
id: root
@@ -129,49 +130,31 @@ Page {
129130
}
130131

131132
// File dialogs
132-
Platform.FileDialog {
133-
id: saveFileDialog
134-
135-
property var _callback: undefined
136133

137-
signal closed(var result)
134+
MrFileDialog {
135+
id: saveFileDialog
136+
saveMode: true
137+
nameFilters: ["*"]
138+
property string fileToSave: ""
138139

139-
title: "Save File"
140-
nameFilters: ["Meshroom Graphs (*.mg)"]
141-
defaultSuffix: ".mg"
142-
fileMode: Platform.FileDialog.SaveFile
140+
onFileSelected: (path) => {
141+
fileToSave = path.toString().replace("file://", "")
142+
// Do something with the file path
143+
}
144+
143145
onAccepted: {
144-
if (!validateFilepathForSave(currentFile, saveFileDialog))
146+
if (!validateFilepathForSave(fileToSave, saveFileDialog))
145147
{
146148
return;
147149
}
148150

149151
// Only save a valid file
150-
_reconstruction.saveAs(currentFile)
151-
MeshroomApp.addRecentProjectFile(currentFile.toString())
152-
closed(Platform.Dialog.Accepted)
153-
fireCallback(Platform.Dialog.Accepted)
154-
}
155-
onRejected: {
156-
closed(Platform.Dialog.Rejected)
157-
fireCallback(Platform.Dialog.Rejected)
158-
}
159-
160-
function fireCallback(rc)
161-
{
162-
// Call the callback and reset it
163-
if (_callback)
164-
_callback(rc)
165-
_callback = undefined
166-
}
167-
168-
// Open the unsaved dialog warning with an optional
169-
// callback to fire when the dialog is accepted/discarded
170-
function prompt(callback)
171-
{
172-
_callback = callback
173-
open()
152+
_reconstruction.saveAs("file://" + fileToSave)
153+
MeshroomApp.addRecentProjectFile(fileToSave.toString())
174154
}
155+
// onRejected: {
156+
// console.log("File not saved")
157+
// }
175158
}
176159

177160
Platform.FileDialog {

0 commit comments

Comments
 (0)