From 8f8457ebe4b01b42bdb7545b7a782f35bf207134 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 3 May 2020 16:04:34 +0200 Subject: 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 --- desktop-widgets/mainwindow.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'desktop-widgets') 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(); } -- cgit v1.2.3-70-g09d2