From c1b3de61902ac392ffe2597a11a89664c9499304 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 8 Feb 2016 11:08:49 -0800 Subject: Remember status of specific cloud account in settings What matters is that the cloud storage for a specific email address has successfully been synced - and we need to remember this across restarts of the app. This way Subsurface-mobile can work with different accounts, even if offline. Signed-off-by: Dirk Hohndel --- qt-mobile/qmlmanager.cpp | 17 ++++++++++++----- qt-mobile/qmlmanager.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'qt-mobile') diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index e6a5d9b0b..bce25795d 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -42,7 +42,6 @@ extern "C" int gitProgressCB(int percent) QMLManager::QMLManager() : m_locationServiceEnabled(false), m_verboseEnabled(false), - m_loadFromCloud(false), reply(0) { m_instance = this; @@ -54,9 +53,9 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), // create location manager service locationProvider = new GpsLocation(&appendTextToLogStandalone, this); set_git_update_cb(&gitProgressCB); - QSettings s; - if (s.contains("setLoadFromCloud") && s.value("setLoadFromCloud").toInt() == 1) - setLoadFromCloud(true); + + // make sure we know if the current cloud repo has been successfully synced + syncLoadFromCloud(); } void QMLManager::finishSetup() @@ -716,10 +715,18 @@ bool QMLManager::loadFromCloud() const return m_loadFromCloud; } +void QMLManager::syncLoadFromCloud() +{ + QSettings s; + QString cloudMarker = QLatin1Literal("loadFromCloud") + QString(prefs.cloud_storage_email); + m_loadFromCloud = s.contains(cloudMarker) && s.value(cloudMarker).toBool(); +} + void QMLManager::setLoadFromCloud(bool done) { QSettings s; - s.setValue("loadFromCloud", 1); + QString cloudMarker = QLatin1Literal("loadFromCloud") + QString(prefs.cloud_storage_email); + s.setValue(cloudMarker, done); m_loadFromCloud = done; emit loadFromCloudChanged(); } diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index 0f43f473c..4d9b9cc8c 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -48,6 +48,7 @@ public: bool loadFromCloud() const; void setLoadFromCloud(bool done); + void syncLoadFromCloud(); QString startPageText() const; void setStartPageText(const QString& text); -- cgit v1.2.3-70-g09d2