mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
desktop: prevent exit only in plan but not in edit mode
Currently, when the profile is in edit mode, the user can't save, exit, plan a new dive and is requested to save the current dive. However, this makes no sense anymore, since the profile always switches to edit mode when showing a manually added dive. If the user has any unsaved profile changes, the usual dirty checks of the undo-system apply. Only show above behavior when in the planner. There it is useful because, these are not included in the undo system. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b1384b286f
commit
fd35fbb349
2 changed files with 10 additions and 6 deletions
|
@ -457,8 +457,7 @@ void MainWindow::on_actionCloudOnline_triggered()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Refuse to go online if there is an edit in progress
|
// Refuse to go online if there is an edit in progress
|
||||||
if (!isOffline &&
|
if (!isOffline && inPlanner()) {
|
||||||
(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING)) {
|
|
||||||
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before going online"));
|
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before going online"));
|
||||||
// We didn't switch to online, therefore uncheck the checkbox
|
// We didn't switch to online, therefore uncheck the checkbox
|
||||||
ui.actionCloudOnline->setChecked(false);
|
ui.actionCloudOnline->setChecked(false);
|
||||||
|
@ -491,7 +490,7 @@ void MainWindow::on_actionCloudOnline_triggered()
|
||||||
|
|
||||||
bool MainWindow::okToClose(QString message)
|
bool MainWindow::okToClose(QString message)
|
||||||
{
|
{
|
||||||
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
if (inPlanner()) {
|
||||||
QMessageBox::warning(this, tr("Warning"), message);
|
QMessageBox::warning(this, tr("Warning"), message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -614,13 +613,18 @@ void MainWindow::on_actionDivelogs_de_triggered()
|
||||||
DivelogsDeWebServices::instance()->downloadDives();
|
DivelogsDeWebServices::instance()->downloadDives();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::inPlanner()
|
||||||
|
{
|
||||||
|
return DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::PLAN;
|
||||||
|
}
|
||||||
|
|
||||||
bool MainWindow::plannerStateClean()
|
bool MainWindow::plannerStateClean()
|
||||||
{
|
{
|
||||||
if (progressDialog)
|
if (progressDialog)
|
||||||
// we are accessing the cloud, so let's not switch into Add or Plan mode
|
// we are accessing the cloud, so let's not switch into Add or Plan mode
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
if (inPlanner()) {
|
||||||
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive."));
|
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1031,7 +1035,7 @@ void MainWindow::writeSettings()
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
if (inPlanner()) {
|
||||||
on_actionQuit_triggered();
|
on_actionQuit_triggered();
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -70,7 +70,6 @@ public:
|
||||||
void importFiles(const QStringList importFiles);
|
void importFiles(const QStringList importFiles);
|
||||||
void setToolButtonsEnabled(bool enabled);
|
void setToolButtonsEnabled(bool enabled);
|
||||||
void setApplicationState(ApplicationState state);
|
void setApplicationState(ApplicationState state);
|
||||||
bool inPlanner();
|
|
||||||
NotificationWidget *getNotificationWidget();
|
NotificationWidget *getNotificationWidget();
|
||||||
void enableDisableCloudActions();
|
void enableDisableCloudActions();
|
||||||
void enableDisableOtherDCsActions();
|
void enableDisableOtherDCsActions();
|
||||||
|
@ -194,6 +193,7 @@ private:
|
||||||
UpdateManager *updateManager;
|
UpdateManager *updateManager;
|
||||||
std::unique_ptr<LocationInformationWidget> diveSiteEdit;
|
std::unique_ptr<LocationInformationWidget> diveSiteEdit;
|
||||||
|
|
||||||
|
bool inPlanner();
|
||||||
bool plannerStateClean();
|
bool plannerStateClean();
|
||||||
void setupSocialNetworkMenu();
|
void setupSocialNetworkMenu();
|
||||||
QDialog *findMovedImagesDialog;
|
QDialog *findMovedImagesDialog;
|
||||||
|
|
Loading…
Add table
Reference in a new issue