diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-04-08 12:35:45 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-08 12:37:17 -0700 |
commit | 4ed369b9759d2a720cffcba3062d50713233150d (patch) | |
tree | a696f62bdd963462652486f7f9d3d43c6f03b2bc /mobile-widgets | |
parent | 685d31cd4fda38c5d7c410356bbb2398d6dc2867 (diff) | |
download | subsurface-4ed369b9759d2a720cffcba3062d50713233150d.tar.gz |
QML UI: only force network access when user asks us to
So when the user taps on the manual cloud sync, we always force access to
the cloud server. Otherwise we only access the cloud server if
git_local_only isn't set.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qml/main.qml | 2 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 17 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 2 |
3 files changed, 14 insertions, 7 deletions
diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index cf67d2d5d..4f75f2d7f 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -138,7 +138,7 @@ Kirigami.ApplicationWindow { onTriggered: { globalDrawer.close() detailsWindow.endEditMode() - manager.saveChangesCloud(); + manager.saveChangesCloud(true); globalDrawer.close() } } diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 62652361b..67b8d993b 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -84,7 +84,6 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), qDebug() << QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()); setStartPageText(tr("Starting...")); setAccessingCloud(-1); - setSyncToCloud(true); // create location manager service locationProvider = new GpsLocation(&appendTextToLogStandalone, this); set_git_update_cb(&gitProgressCB); @@ -117,7 +116,7 @@ void QMLManager::applicationStateChanged(Qt::ApplicationState state) // FIXME // make sure the user sees that we are saving data if they come back // while this is running - saveChangesCloud(); + saveChangesCloud(false); appendTextToLog(QString::number(timer.elapsed() / 1000.0,'f', 3) + ": done saving to git local / remote"); } } @@ -147,8 +146,12 @@ void QMLManager::openLocalThenRemote(QString url) appendTextToLog(QStringLiteral("%1 dives loaded from cache").arg(dive_table.nr)); } set_filename(fileNamePrt.data(), true); - appendTextToLog(QStringLiteral("have cloud credentials, trying to connect")); - tryRetrieveDataFromBackend(); + if (prefs.git_local_only) { + appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network")); + } else { + appendTextToLog(QStringLiteral("have cloud credentials, trying to connect")); + tryRetrieveDataFromBackend(); + } } void QMLManager::finishSetup() @@ -156,6 +159,7 @@ void QMLManager::finishSetup() // Initialize cloud credentials. setCloudUserName(prefs.cloud_storage_email); setCloudPassword(prefs.cloud_storage_password); + setSyncToCloud(!prefs.git_local_only); // if the cloud credentials are valid, we should get the GPS Webservice ID as well QString url; if (!cloudUserName().isEmpty() && @@ -771,8 +775,11 @@ void QMLManager::saveChangesLocal() } } -void QMLManager::saveChangesCloud() +void QMLManager::saveChangesCloud(bool forceRemoteSync) { + if (prefs.git_local_only && !forceRemoteSync) + return; + git_storage_update_progress(true, "start save change to cloud"); if (!loadFromCloud()) { appendTextToLog("Don't save dives without loading from the cloud, first."); diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index c7699b3c5..bb9db791f 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -100,7 +100,7 @@ public slots: QString buddy, QString diveMaster, QString weight, QString notes, QString startpressure, QString endpressure, QString gasmix); void saveChangesLocal(); - void saveChangesCloud(); + void saveChangesCloud(bool forceRemoteSync); void deleteDive(int id); void undoDelete(int id); QString addDive(); |