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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2014-05-06 15:56:28 +02:00 committed by Dirk Hohndel
parent e3ef1b7a1e
commit 543f226db0

View file

@ -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();