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>
This commit is contained in:
Berthold Stoeger 2020-05-03 16:04:34 +02:00 committed by Dirk Hohndel
parent 2a31203221
commit 8f8457ebe4

View file

@ -741,21 +741,9 @@ void MainWindow::on_actionPreferences_triggered()
void MainWindow::on_actionQuit_triggered() void MainWindow::on_actionQuit_triggered()
{ {
if (mainTab->isEditing()) { if (!okToClose(tr("Please save or cancel the current dive edit before quiting the application.")))
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))
return; return;
writeSettings(); writeSettings();
QApplication::quit(); QApplication::quit();
} }