From 543f226db0512e0f058eeb85a79439c580a3d12e Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 6 May 2014 15:56:28 +0200 Subject: [PATCH] Planner: Offer to discard the plan when Quit is triggered in planner. Upon pressing Ctrl-Q or the window close button a modal dialog was shown to remind the user that the planned dive is not saved. This patch triggers the "cancel plan" action before trying to quit. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index b03fbe14c..fb5e3af8e 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -352,11 +352,17 @@ void MainWindow::on_actionPreferences_triggered() void MainWindow::on_actionQuit_triggered() { - if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + if (ui.InfoWidget->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before closing the file.")); return; } + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) { + DivePlannerPointsModel::instance()->cancelPlan(); + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) + // The planned dive was not discarded + return; + } + if (unsaved_changes() && (askSaveChanges() == false)) return; writeSettings();