mobile-widgets: remove SettingsObjectWrapper and update qPref calls

remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-08-15 11:53:49 +02:00 committed by Dirk Hohndel
parent 1cc7c05170
commit 94fd758607
2 changed files with 19 additions and 20 deletions

View file

@ -33,7 +33,7 @@
#include "core/downloadfromdcthread.h" #include "core/downloadfromdcthread.h"
#include "core/subsurface-string.h" #include "core/subsurface-string.h"
#include "core/pref.h" #include "core/pref.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h" #include "core/settings/qPref.h"
#include "core/ssrf.h" #include "core/ssrf.h"
@ -253,10 +253,10 @@ void QMLManager::openLocalThenRemote(QString url)
clear_dive_file_data(); clear_dive_file_data();
setNotificationText(tr("Open local dive data file")); setNotificationText(tr("Open local dive data file"));
QByteArray fileNamePrt = QFile::encodeName(url); QByteArray fileNamePrt = QFile::encodeName(url);
bool glo = prefs.git_local_only; bool glo = qPrefCloudStorage::git_local_only();
prefs.git_local_only = true; prefs.git_local_only = true;
int error = parse_file(fileNamePrt.data()); int error = parse_file(fileNamePrt.data());
prefs.git_local_only = glo; qPrefCloudStorage::set_git_local_only(glo);
if (error) { if (error) {
appendTextToLog(QStringLiteral("loading dives from cache failed %1").arg(error)); appendTextToLog(QStringLiteral("loading dives from cache failed %1").arg(error));
setNotificationText(tr("Opening local data file failed")); setNotificationText(tr("Opening local data file failed"));
@ -277,16 +277,16 @@ void QMLManager::openLocalThenRemote(QString url)
if (QMLPrefs::instance()->credentialStatus() == qPref::CS_UNKNOWN) if (QMLPrefs::instance()->credentialStatus() == qPref::CS_UNKNOWN)
QMLPrefs::instance()->setCredentialStatus(qPref::CS_VERIFIED); QMLPrefs::instance()->setCredentialStatus(qPref::CS_VERIFIED);
prefs.unit_system = git_prefs.unit_system; prefs.unit_system = git_prefs.unit_system;
if (git_prefs.unit_system == IMPERIAL) if (qPrefUnits::unit_system() == IMPERIAL)
git_prefs.units = IMPERIAL_units; git_prefs.units = IMPERIAL_units;
else if (git_prefs.unit_system == METRIC) else if (git_prefs.unit_system == METRIC)
git_prefs.units = SI_units; git_prefs.units = SI_units;
prefs.units = git_prefs.units; prefs.units = git_prefs.units;
prefs.tankbar = git_prefs.tankbar; qPrefTechnicalDetails::set_tankbar(git_prefs.tankbar);
prefs.dcceiling = git_prefs.dcceiling; qPrefTechnicalDetails::set_dcceiling(git_prefs.dcceiling);
prefs.show_ccr_setpoint = git_prefs.show_ccr_setpoint; qPrefTechnicalDetails::set_show_ccr_setpoint(git_prefs.show_ccr_setpoint);
prefs.show_ccr_sensors = git_prefs.show_ccr_sensors; qPrefTechnicalDetails::set_show_ccr_sensors(git_prefs.show_ccr_sensors);
prefs.pp_graphs.po2 = git_prefs.pp_graphs.po2; qPrefPartialPressureGas::set_po2(git_prefs.pp_graphs.po2);
process_dives(false, false); process_dives(false, false);
DiveListModel::instance()->clear(); DiveListModel::instance()->clear();
DiveListModel::instance()->addAllDives(); DiveListModel::instance()->addAllDives();
@ -299,11 +299,11 @@ void QMLManager::openLocalThenRemote(QString url)
} }
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) { if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) {
// if we switch to credentials from CS_NOCLOUD, we take things online temporarily // if we switch to credentials from CS_NOCLOUD, we take things online temporarily
prefs.git_local_only = false; qPrefCloudStorage::set_git_local_only(false);
appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account")); appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account"));
} }
set_filename(fileNamePrt.data()); set_filename(fileNamePrt.data());
if (prefs.git_local_only) { if (qPrefCloudStorage::git_local_only()) {
appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network")); appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network"));
alreadySaving = false; alreadySaving = false;
} else { } else {
@ -371,9 +371,9 @@ void QMLManager::copyAppLogToClipboard()
void QMLManager::finishSetup() void QMLManager::finishSetup()
{ {
// Initialize cloud credentials. // Initialize cloud credentials.
QMLPrefs::instance()->setCloudUserName(prefs.cloud_storage_email); QMLPrefs::instance()->setCloudUserName(qPrefCloudStorage::cloud_storage_email());
QMLPrefs::instance()->setCloudPassword(prefs.cloud_storage_password); QMLPrefs::instance()->setCloudPassword(qPrefCloudStorage::cloud_storage_password());
setSyncToCloud(!prefs.git_local_only); setSyncToCloud(!qPrefCloudStorage::git_local_only());
QMLPrefs::instance()->setCredentialStatus((qPref::cloud_status) prefs.cloud_verification_status); QMLPrefs::instance()->setCredentialStatus((qPref::cloud_status) prefs.cloud_verification_status);
// if the cloud credentials are valid, we should get the GPS Webservice ID as well // if the cloud credentials are valid, we should get the GPS Webservice ID as well
QString url; QString url;
@ -404,8 +404,8 @@ void QMLManager::finishSetup()
appendTextToLog(tr("no cloud credentials")); appendTextToLog(tr("no cloud credentials"));
setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT); setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
} }
QMLPrefs::instance()->setDistanceThreshold(prefs.distance_threshold); QMLPrefs::instance()->setDistanceThreshold(qPrefLocationService::distance_threshold());
QMLPrefs::instance()->setTimeThreshold(prefs.time_threshold / 60); QMLPrefs::instance()->setTimeThreshold(qPrefLocationService::time_threshold() / 60);
} }
QMLManager::~QMLManager() QMLManager::~QMLManager()
@ -424,9 +424,8 @@ QMLManager *QMLManager::instance()
void QMLManager::savePreferences() void QMLManager::savePreferences()
{ {
auto location = SettingsObjectWrapper::instance()->location_settings; qPrefLocationService::set_time_threshold(QMLPrefs::instance()->timeThreshold() * 60);
location->set_time_threshold(QMLPrefs::instance()->timeThreshold() * 60); qPrefLocationService::set_distance_threshold(QMLPrefs::instance()->distanceThreshold());
location->set_distance_threshold(QMLPrefs::instance()->distanceThreshold());
} }
#define CLOUDURL QString(prefs.cloud_base_url) #define CLOUDURL QString(prefs.cloud_base_url)

View file

@ -3,7 +3,7 @@
#include "qmlmanager.h" #include "qmlmanager.h"
#include "core/membuffer.h" #include "core/membuffer.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h" #include "core/settings/qPref.h"
#include "core/gpslocation.h" #include "core/gpslocation.h"