summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-01-02 21:56:03 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-01-06 10:46:07 -0800
commitdbef391786a3ba70ba5e4c002ed968122c5e780a (patch)
tree41a57d1d4d688f96a106270abd2a2e86ea729e4e /desktop-widgets
parentfd5a521b948fc9f9551ea17d054a65d288ca990d (diff)
downloadsubsurface-dbef391786a3ba70ba5e4c002ed968122c5e780a.tar.gz
Sync cloud storage on take-cloud-online
When taking the cloud online, actually sync with the online cloud storage. If there are no unsaved changes, do the same as "Open cloud storage". If there are unsaved changes, ask the user if they want to commit them (do the same as "Save to cloud storage") or if they want to sync manually. If syncing failed, inform the user. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/mainwindow.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index ad8b39dd7..84cac46b4 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -647,8 +647,31 @@ void MainWindow::on_actionCloudstoragesave_triggered()
void MainWindow::on_actionTake_cloud_storage_online_triggered()
{
+ // Refuse to go online if there is an edit in progress
+ if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
+ information()->isEditing() ) {
+ QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before going online"));
+ return;
+ }
+
prefs.git_local_only = false;
- ui.actionTake_cloud_storage_online->setEnabled(false);
+ if (unsaved_changes()) {
+ // If there are unsaved changes, ask the user if they want to save them.
+ // If they don't, they have to sync manually.
+ if (QMessageBox::warning(this, tr("Save changes?"),
+ tr("You have unsaved changes. Do you want to commit them to the cloud storage?\n"
+ "If answering no, the cloud will only be synced on next call to "
+ "\"Open cloud storage\" or \"Save to cloud storage\"."),
+ QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes)
+ on_actionCloudstoragesave_triggered();
+ else
+ setTitle();
+ } else {
+ // If there are no unsaved changes, let's just try to load the remote cloud
+ on_actionCloudstorageopen_triggered();
+ }
+ if (prefs.git_local_only)
+ report_error(qPrintable(tr("Failure taking cloud storage online")));
}
void learnImageDirs(QStringList dirnames)