mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: store nocloud data when adding cloud credentials
We want to allow people to keep dives they collected without a cloud account. The code was mostly there, we just got confused about the existing status because we ran through this twice (no cloud -> unknown -> verified). This way we explicitly remember this kind of transition. Fixes #1404 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e6835d76cc
commit
7ec9c206b5
1 changed files with 16 additions and 2 deletions
|
@ -37,6 +37,7 @@
|
||||||
#include "core/ssrf.h"
|
#include "core/ssrf.h"
|
||||||
|
|
||||||
QMLManager *QMLManager::m_instance = NULL;
|
QMLManager *QMLManager::m_instance = NULL;
|
||||||
|
bool noCloudToCloud = false;
|
||||||
|
|
||||||
#define RED_FONT QLatin1Literal("<font color=\"red\">")
|
#define RED_FONT QLatin1Literal("<font color=\"red\">")
|
||||||
#define END_FONT QLatin1Literal("</font>")
|
#define END_FONT QLatin1Literal("</font>")
|
||||||
|
@ -442,6 +443,12 @@ void QMLManager::saveCloudCredentials()
|
||||||
free((void *)prefs.cloud_storage_password);
|
free((void *)prefs.cloud_storage_password);
|
||||||
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
|
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
|
||||||
}
|
}
|
||||||
|
if (QMLPrefs::instance()->oldStatus() == QMLPrefs::CS_NOCLOUD && cloudCredentialsChanged && dive_table.nr) {
|
||||||
|
// we came from NOCLOUD and are connecting to a cloud account;
|
||||||
|
// since we already have dives in the table, let's remember that so we can keep them
|
||||||
|
noCloudToCloud = true;
|
||||||
|
appendTextToLog("transitioning from no-cloud to cloud and have dives");
|
||||||
|
}
|
||||||
if (QMLPrefs::instance()->cloudUserName().isEmpty() ||
|
if (QMLPrefs::instance()->cloudUserName().isEmpty() ||
|
||||||
QMLPrefs::instance()->cloudPassword().isEmpty()) {
|
QMLPrefs::instance()->cloudPassword().isEmpty()) {
|
||||||
setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
|
setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
|
||||||
|
@ -624,7 +631,13 @@ void QMLManager::loadDivesWithValidCredentials()
|
||||||
}
|
}
|
||||||
appendTextToLog("Cloud sync brought newer data, reloading the dive list");
|
appendTextToLog("Cloud sync brought newer data, reloading the dive list");
|
||||||
|
|
||||||
clear_dive_file_data();
|
// if we aren't switching from no-cloud mode, let's clear the dive data
|
||||||
|
if (!noCloudToCloud) {
|
||||||
|
appendTextToLog("Clear out in memory dive data");
|
||||||
|
clear_dive_file_data();
|
||||||
|
} else {
|
||||||
|
appendTextToLog("Switching from no cloud mode; keep in memory dive data");
|
||||||
|
}
|
||||||
if (git != dummy_git_repository) {
|
if (git != dummy_git_repository) {
|
||||||
appendTextToLog(QString("have repository and branch %1").arg(branch));
|
appendTextToLog(QString("have repository and branch %1").arg(branch));
|
||||||
error = git_load_dives(git, branch);
|
error = git_load_dives(git, branch);
|
||||||
|
@ -649,13 +662,14 @@ successful_exit:
|
||||||
setLoadFromCloud(true);
|
setLoadFromCloud(true);
|
||||||
// if we came from local storage mode, let's merge the local data into the local cache
|
// if we came from local storage mode, let's merge the local data into the local cache
|
||||||
// for the remote data - which then later gets merged with the remote data if necessary
|
// for the remote data - which then later gets merged with the remote data if necessary
|
||||||
if (QMLPrefs::instance()->oldStatus() == QMLPrefs::CS_NOCLOUD) {
|
if (noCloudToCloud) {
|
||||||
git_storage_update_progress(qPrintable(tr("Loading dives from local storage ('no cloud' mode)")));
|
git_storage_update_progress(qPrintable(tr("Loading dives from local storage ('no cloud' mode)")));
|
||||||
dive_table.preexisting = dive_table.nr;
|
dive_table.preexisting = dive_table.nr;
|
||||||
mergeLocalRepo();
|
mergeLocalRepo();
|
||||||
DiveListModel::instance()->clear();
|
DiveListModel::instance()->clear();
|
||||||
DiveListModel::instance()->addAllDives();
|
DiveListModel::instance()->addAllDives();
|
||||||
appendTextToLog(QStringLiteral("%1 dives loaded after importing nocloud local storage").arg(dive_table.nr));
|
appendTextToLog(QStringLiteral("%1 dives loaded after importing nocloud local storage").arg(dive_table.nr));
|
||||||
|
noCloudToCloud = false;
|
||||||
saveChangesLocal();
|
saveChangesLocal();
|
||||||
if (m_syncToCloud == false) {
|
if (m_syncToCloud == false) {
|
||||||
appendTextToLog(QStringLiteral("taking things back offline now that storage is synced"));
|
appendTextToLog(QStringLiteral("taking things back offline now that storage is synced"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue