summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mobile-widgets/qmlmanager.cpp30
-rw-r--r--mobile-widgets/qmlmanager.h2
2 files changed, 17 insertions, 15 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 17ceebd3b..dffdc9cc5 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -381,13 +381,17 @@ void QMLManager::updateAllGlobalLists()
updateSiteList();
}
+static QString nocloud_localstorage()
+{
+ return QString(system_default_directory()) + "/cloudstorage/localrepo[master]";
+}
+
void QMLManager::mergeLocalRepo()
{
- char *filename = NOCLOUD_LOCALSTORAGE;
struct dive_table table = empty_dive_table;
struct trip_table trips = empty_trip_table;
struct dive_site_table sites = empty_dive_site_table;
- parse_file(filename, &table, &trips, &sites);
+ parse_file(qPrintable(nocloud_localstorage()), &table, &trips, &sites);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
}
@@ -460,7 +464,7 @@ void QMLManager::finishSetup()
} else if (!empty_string(existing_filename) &&
qPrefCloudStorage::cloud_verification_status() != qPrefCloudStorage::CS_UNKNOWN) {
setOldStatus((qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status());
- set_filename(NOCLOUD_LOCALSTORAGE);
+ set_filename(qPrintable(nocloud_localstorage()));
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
saveCloudCredentials(qPrefCloudStorage::cloud_storage_email(), qPrefCloudStorage::cloud_storage_password(), qPrefCloudStorage::cloud_storage_pin());
appendTextToLog(tr("working in no-cloud mode"));
@@ -820,7 +824,7 @@ void QMLManager::revertToNoCloudIfNeeded()
qPrefCloudStorage::set_cloud_storage_password("");
setOldStatus((qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status());
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
- set_filename(NOCLOUD_LOCALSTORAGE);
+ set_filename(qPrintable(nocloud_localstorage()));
setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT);
}
alreadySaving = false;
@@ -1292,17 +1296,17 @@ void QMLManager::openNoCloudRepo()
* is obviously empty when just created.
*/
{
- char *filename = NOCLOUD_LOCALSTORAGE;
+ QString filename = nocloud_localstorage();
const char *branch;
struct git_repository *git;
- git = is_git_repository(filename, &branch, NULL, false);
+ git = is_git_repository(qPrintable(filename), &branch, NULL, false);
if (git == dummy_git_repository) {
- git_create_local_repo(filename);
- set_filename(filename);
+ git_create_local_repo(qPrintable(filename));
+ set_filename(qPrintable(filename));
auto s = qPrefLog::instance();
- s->set_default_filename(filename);
+ s->set_default_filename(qPrintable(filename));
s->set_default_file_behavior(LOCAL_DEFAULT_FILE);
}
@@ -1314,11 +1318,11 @@ void QMLManager::saveChangesLocal()
if (unsaved_changes()) {
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NOCLOUD) {
if (empty_string(existing_filename)) {
- char *filename = NOCLOUD_LOCALSTORAGE;
- git_create_local_repo(filename);
- set_filename(filename);
+ QString filename = nocloud_localstorage();
+ git_create_local_repo(qPrintable(filename));
+ set_filename(qPrintable(filename));
auto s = qPrefLog::instance();
- s->set_default_filename(filename);
+ s->set_default_filename(qPrintable(filename));
s->set_default_file_behavior(LOCAL_DEFAULT_FILE);
}
} else if (!m_loadFromCloud) {
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 145a3df17..74addbc50 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -19,8 +19,6 @@
#include "core/settings/qPrefCloudStorage.h"
#include "core/subsurface-qt/divelistnotifier.h"
-#define NOCLOUD_LOCALSTORAGE format_string("%s/cloudstorage/localrepo[master]", system_default_directory())
-
class QMLManager : public QObject {
Q_OBJECT
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)