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.
This commit is contained in:
Martin Kleusberg
2014-10-15 13:44:52 +02:00
parent ff5cf3e63d
commit 5d20d97e24

View File

@@ -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);
}
}