Skip to content

Commit 89121bd

Browse files
committed
[ui] Add new saveAs window
1 parent 88ef217 commit 89121bd

7 files changed

Lines changed: 805 additions & 40 deletions

File tree

meshroom/core/graph.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,20 @@ def _unsetFilepath(self):
15071507
self.cacheDir = ""
15081508
self.filepathChanged.emit()
15091509

1510+
@Slot(result=str)
1511+
def getCurrentFilename(self):
1512+
if os.path.exists(self._filepath):
1513+
return os.path.basename(self._filepath)
1514+
else:
1515+
return ""
1516+
1517+
@Slot(result=str)
1518+
def getCurrentFolder(self):
1519+
if os.path.exists(self._filepath):
1520+
return os.path.dirname(self._filepath)
1521+
else:
1522+
return os.getcwd()
1523+
15101524
def updateInternals(self, startNodes=None, force=False):
15111525
nodes, edges = self.dfsOnFinish(startNodes=startNodes)
15121526
for node in nodes:

meshroom/ui/graph.py

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

meshroom/ui/qml/Application.qml

Lines changed: 18 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
@@ -135,49 +136,32 @@ Page {
135136
}
136137

137138
// File dialogs
138-
Platform.FileDialog {
139-
id: saveFileDialog
140-
141-
property var _callback: undefined
142139

143-
signal closed(var result)
140+
MrFileDialog {
141+
id: saveFileDialog
142+
saveMode: true
143+
nameFilters: ["*"]
144+
property string fileToSave: ""
144145

145-
title: "Save File"
146-
nameFilters: ["Meshroom Graphs (*.mg)"]
147-
defaultSuffix: ".mg"
148-
fileMode: Platform.FileDialog.SaveFile
146+
onFileSelected: (path) => {
147+
fileToSave = path.toString().replace("file://", "")
148+
// Do something with the file path
149+
}
150+
149151
onAccepted: {
150-
if (!validateFilepathForSave(currentFile, saveFileDialog))
152+
if (!validateFilepathForSave(fileToSave, saveFileDialog))
151153
{
152154
return;
153155
}
154156

155157
// Only save a valid file
156-
_currentScene.saveAs(currentFile)
157-
MeshroomApp.addRecentProjectFile(currentFile.toString())
158-
closed(Platform.Dialog.Accepted)
159-
fireCallback(Platform.Dialog.Accepted)
160-
}
161-
onRejected: {
162-
closed(Platform.Dialog.Rejected)
163-
fireCallback(Platform.Dialog.Rejected)
164-
}
165-
166-
function fireCallback(rc)
167-
{
168-
// Call the callback and reset it
169-
if (_callback)
170-
_callback(rc)
171-
_callback = undefined
172-
}
173-
174-
// Open the unsaved dialog warning with an optional
175-
// callback to fire when the dialog is accepted/discarded
176-
function prompt(callback)
177-
{
178-
_callback = callback
179-
open()
158+
_currentScene.saveAs("file://" + fileToSave)
159+
MeshroomApp.addRecentProjectFile(fileToSave.toString())
180160
}
161+
162+
// onRejected: {
163+
// console.log("File not saved")
164+
// }
181165
}
182166

183167
Platform.FileDialog {

0 commit comments

Comments
 (0)