mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user