From 4cb8afebeee77af6482ed7b64dda736af81a11f2 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 14 Feb 2018 14:12:31 +0100 Subject: [PATCH] Use default filepath of item when saving if exists, if not use last path used when save_as in the current session if exists, if not use build dir like before. --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 9 ++++++++- Polyhedron/demo/Polyhedron/MainWindow.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index db0cf994fd4..7f48202467c 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1606,12 +1606,19 @@ void MainWindow::on_actionSaveAs_triggered() continue; } QString caption = tr("Save %1 to File...").arg(item->name()); + QString dir = item->property("source filename").toString(); + if(dir.isEmpty()) + dir = QString("%1/%2").arg(last_saved_dir).arg(item->name()); + if(dir.isEmpty()) + dir = item->name(); QString filename = QFileDialog::getSaveFileName(this, caption, - QString("%1").arg(item->name()), + dir, filters.join(";;"), &sf); + + last_saved_dir = QFileInfo(dir).absoluteDir().path(); extensions.indexIn(sf.split(";;").first()); ext1 = extensions.cap(); //remove `)` diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index dbf92ec601f..7118c3ad139 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -402,6 +402,7 @@ private: QTreeView* sceneView; Ui::MainWindow* ui; QVector io_plugins; + QString last_saved_dir; QMap default_plugin_selection; // typedef to make Q_FOREACH work typedef QPair PluginNamePair;