From 5d20d97e249a42d7dae1061d946c90c9c987d608 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Wed, 15 Oct 2014 13:44:52 +0200 Subject: [PATCH] MainWindow: Improve saving of project files When saving a project file make sure it's got the right file ending. Also add it to the list of recently opened files. Use the default location from the preferences dialog for initialising the file dialogs for loading and saving project files. --- src/MainWindow.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 20c78853..9a024967 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1729,7 +1729,7 @@ bool MainWindow::loadProject(QString filename) { filename = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), - QString(), + PreferencesDialog::getSettingsValue("db", "defaultlocation").toString(), tr("DB Browser for SQLite project file (*.sqbpro)")); } @@ -1871,11 +1871,15 @@ void MainWindow::saveProject() { QString filename = QFileDialog::getSaveFileName(this, tr("Choose a filename to save under"), - QString(), + PreferencesDialog::getSettingsValue("db", "defaultlocation").toString(), tr("DB Browser for SQLite project file (*.sqbpro)") ); if(!filename.isEmpty()) { + // Make sure the file has got a .sqbpro ending + if(!filename.endsWith(".sqbpro", Qt::CaseInsensitive)) + filename.append(".sqbpro"); + QFile file(filename); file.open(QFile::WriteOnly | QFile::Text); QXmlStreamWriter xml(&file); @@ -1942,6 +1946,7 @@ void MainWindow::saveProject() xml.writeEndElement(); xml.writeEndDocument(); file.close(); + addToRecentFilesMenu(filename); } }