MainWindow: Make it possible to cancel closing of database file

When closing the database, either by using the menu item or by closing
the window, the user is asked whether the changes he made shall be
saved or not. Add a third button to this message box which makes it
possible to cancel the action.
This commit is contained in:
Martin Kleusberg
2014-06-20 13:03:23 +02:00
parent 3da0d36463
commit dca664270f
3 changed files with 33 additions and 16 deletions

View File

@@ -373,7 +373,9 @@ void MainWindow::resetBrowser()
void MainWindow::fileClose()
{
db.close();
if(!db.close())
return;
setWindowTitle(QApplication::applicationName());
resetBrowser();
populateStructure();
@@ -401,13 +403,17 @@ void MainWindow::fileClose()
void MainWindow::closeEvent( QCloseEvent* event )
{
db.close();
PreferencesDialog::setSettingsValue("MainWindow", "geometry", saveGeometry());
PreferencesDialog::setSettingsValue("MainWindow", "windowState", saveState());
PreferencesDialog::setSettingsValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
PreferencesDialog::setSettingsValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState());
clearCompleterModelsFields();
QMainWindow::closeEvent(event);
if(db.close())
{
PreferencesDialog::setSettingsValue("MainWindow", "geometry", saveGeometry());
PreferencesDialog::setSettingsValue("MainWindow", "windowState", saveState());
PreferencesDialog::setSettingsValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
PreferencesDialog::setSettingsValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState());
clearCompleterModelsFields();
QMainWindow::closeEvent(event);
} else {
event->ignore();
}
}
void MainWindow::addRecord()