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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-02-08 11:08:49 -08:00
parent d43a2c032b
commit c1b3de6190
2 changed files with 13 additions and 5 deletions

View file

@ -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();
}

View file

@ -48,6 +48,7 @@ public:
bool loadFromCloud() const;
void setLoadFromCloud(bool done);
void syncLoadFromCloud();
QString startPageText() const;
void setStartPageText(const QString& text);