diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-11-17 15:46:27 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-17 15:46:27 -0800 |
commit | e289881db9727b5bcfec12c3c390cdd6743f7472 (patch) | |
tree | 0f31e14b0c0692ec54e3793ed5c429fb19b8d06b | |
parent | 5945c18c8aeb5ae2c27c00f7409fddf8048b6ec0 (diff) | |
download | subsurface-e289881db9727b5bcfec12c3c390cdd6743f7472.tar.gz |
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 <dirk@hohndel.org>
-rw-r--r-- | qt-ui/mainwindow.cpp | 19 |
1 files 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(); |