From e289881db9727b5bcfec12c3c390cdd6743f7472 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 17 Nov 2013 15:46:27 -0800 Subject: Make edit / dive add in progress check more consistent We need to check for this whenever we do something that directly or indirectly closes the data file. Previously we were missing the straight "quit". Also, we should consistently check for both editing or dive addition. And lastly, we should use consistent language with commit 0e9cd0944284 ("Make editing message consistent with button labels"). Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 8628ca558..a1c8d290f 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -98,8 +98,9 @@ void MainWindow::on_actionNew_triggered() void MainWindow::on_actionOpen_triggered() { - if (ui.InfoWidget->isEditing()) { - QMessageBox::warning(this, tr("Warning"), "Please save or undo the current dive edit before opening a new file." ); + if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { + QMessageBox::warning(this, tr("Warning"), "Please save or cancel the current dive edit before opening a new file." ); return; } QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), lastUsedDir(), filter()); @@ -134,8 +135,9 @@ void MainWindow::cleanUpEmpty() void MainWindow::on_actionClose_triggered() { - if (ui.InfoWidget->isEditing()) { - QMessageBox::warning(this, tr("Warning"), "Please save or undo the current dive edit before closing the file." ); + if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { + QMessageBox::warning(this, tr("Warning"), "Please save or cancel the current dive edit before closing the file." ); return; } if (unsaved_changes() && (askSaveChanges() == FALSE)) @@ -214,7 +216,7 @@ void MainWindow::on_actionDivePlanner_triggered() { if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || ui.InfoWidget->isEditing()) { - QMessageBox::warning(this, tr("Warning"), "Please save or undo the current dive edit before trying to plan a dive." ); + QMessageBox::warning(this, tr("Warning"), "Please save or cancel the current dive edit before trying to plan a dive." ); return; } disableDcShortcuts(); @@ -239,6 +241,11 @@ void MainWindow::on_actionPreferences_triggered() void MainWindow::on_actionQuit_triggered() { + if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { + QMessageBox::warning(this, tr("Warning"), "Please save or cancel the current dive edit before closing the file." ); + return; + } if (unsaved_changes() && (askSaveChanges() == FALSE)) return; writeSettings(); @@ -272,7 +279,7 @@ void MainWindow::on_actionAddDive_triggered() { if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || ui.InfoWidget->isEditing()) { - QMessageBox::warning(this, tr("Warning"), "Please save or undo the current dive edit before trying to add a dive." ); + QMessageBox::warning(this, tr("Warning"), "Please save or cancel the current dive edit before trying to add a dive." ); return; } dive_list()->rememberSelection(); -- cgit v1.2.3-70-g09d2