summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-03 16:04:34 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-03 14:17:47 -0700
commit8f8457ebe4b01b42bdb7545b7a782f35bf207134 (patch)
treeb0405bf98cd8df08c4302c8f0bdc30f0829a5e6a /desktop-widgets/mainwindow.cpp
parent2a31203221ab1ff5592062c340e54f6b42695c85 (diff)
downloadsubsurface-8f8457ebe4b01b42bdb7545b7a782f35bf207134.tar.gz
desktop: ask user when quitting application while planning
We used to cancel a plan (or profile edit) when the user quit the application while planning. This is inconsistent with respect to closing or opening a different log, where the user was asked for confirmation. Thus, for consistency and to avoid loss of a planned dive, use the okToClose() function in on_actionClose_triggered() of MainWindow. As an added bonus, this saves a few SLOC. Fixes #1078 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp16
1 files changed, 2 insertions, 14 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 452cc322f..cb1179d8c 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -741,21 +741,9 @@ void MainWindow::on_actionPreferences_triggered()
void MainWindow::on_actionQuit_triggered()
{
- if (mainTab->isEditing()) {
- mainTab->rejectChanges();
- if (mainTab->isEditing())
- // didn't discard the edits
- return;
- }
- if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
- DivePlannerPointsModel::instance()->cancelPlan();
- if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING)
- // The planned dive was not discarded
- return;
- }
-
- if (unsavedChanges() && (askSaveChanges() == false))
+ if (!okToClose(tr("Please save or cancel the current dive edit before quiting the application.")))
return;
+
writeSettings();
QApplication::quit();
}