summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/settings/qPref.cpp1
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.cpp45
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.h22
-rw-r--r--mobile-widgets/qmlmanager.cpp4
-rw-r--r--subsurface-helper.cpp1
-rw-r--r--tests/testpreferences.cpp14
6 files changed, 15 insertions, 72 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp
index cd93fe44e..90aaa8fea 100644
--- a/core/settings/qPref.cpp
+++ b/core/settings/qPref.cpp
@@ -20,6 +20,7 @@ void qPref::loadSync(bool doSync)
qPrefDiveComputer::instance()->loadSync(doSync);
qPrefDivePlanner::instance()->loadSync(doSync);
// qPrefFaceook does not use disk.
+ qPrefLocationService::instance()->loadSync(doSync);
qPrefProxy::instance()->loadSync(doSync);
qPrefTechnicalDetails::instance()->loadSync(doSync);
qPrefUnits::instance()->loadSync(doSync);
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp
index 224e314a5..84ffc5a26 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -532,44 +532,6 @@ void LanguageSettingsObjectWrapper::setDateFormatOverride(bool value)
}
-LocationServiceSettingsObjectWrapper::LocationServiceSettingsObjectWrapper(QObject* parent):
- QObject(parent)
-{
-}
-
-int LocationServiceSettingsObjectWrapper::distanceThreshold() const
-{
- return prefs.distance_threshold;
-}
-
-int LocationServiceSettingsObjectWrapper::timeThreshold() const
-{
- return prefs.time_threshold;
-}
-
-void LocationServiceSettingsObjectWrapper::setDistanceThreshold(int value)
-{
- if (value == prefs.distance_threshold)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("distance_threshold", value);
- prefs.distance_threshold = value;
- emit distanceThresholdChanged(value);
-}
-
-void LocationServiceSettingsObjectWrapper::setTimeThreshold(int value)
-{
- if (value == prefs.time_threshold)
- return;
-
- QSettings s;
- s.beginGroup(group);
- s.setValue("time_threshold", value);
- prefs.time_threshold = value;
- emit timeThresholdChanged(value);
-}
-
SettingsObjectWrapper::SettingsObjectWrapper(QObject* parent):
QObject(parent),
techDetails(new qPrefTechnicalDetails(this)),
@@ -584,7 +546,7 @@ QObject(parent),
display_settings(new qPrefDisplay(this)),
language_settings(new LanguageSettingsObjectWrapper(this)),
animation_settings(new qPrefAnimations(this)),
- location_settings(new LocationServiceSettingsObjectWrapper(this)),
+ location_settings(new qPrefLocationService(this)),
update_manager_settings(new qPrefUpdateManager(this)),
dive_computer_settings(new qPrefDiveComputer(this))
{
@@ -633,10 +595,7 @@ void SettingsObjectWrapper::load()
s.endGroup();
// GPS service time and distance thresholds
- s.beginGroup("LocationService");
- GET_INT("time_threshold", time_threshold);
- GET_INT("distance_threshold", distance_threshold);
- s.endGroup();
+ qPrefLocationService::instance()->load();
qPrefDivePlanner::instance()->load();
qPrefDiveComputer::instance()->load();
diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h
index 7b84f26d5..3af79404e 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.h
+++ b/core/subsurface-qt/SettingsObjectWrapper.h
@@ -183,24 +183,6 @@ private:
const QString group = QStringLiteral("Language");
};
-class LocationServiceSettingsObjectWrapper : public QObject {
- Q_OBJECT
- Q_PROPERTY(int time_threshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged)
- Q_PROPERTY(int distance_threshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged)
-public:
- LocationServiceSettingsObjectWrapper(QObject *parent);
- int timeThreshold() const;
- int distanceThreshold() const;
-public slots:
- void setTimeThreshold(int value);
- void setDistanceThreshold(int value);
-signals:
- void timeThresholdChanged(int value);
- void distanceThresholdChanged(int value);
-private:
- const QString group = QStringLiteral("LocationService");
-};
-
class SettingsObjectWrapper : public QObject {
Q_OBJECT
@@ -216,7 +198,7 @@ class SettingsObjectWrapper : public QObject {
Q_PROPERTY(qPrefDisplay* display MEMBER display_settings CONSTANT)
Q_PROPERTY(LanguageSettingsObjectWrapper* language MEMBER language_settings CONSTANT)
Q_PROPERTY(qPrefAnimations* animation MEMBER animation_settings CONSTANT)
- Q_PROPERTY(LocationServiceSettingsObjectWrapper* Location MEMBER location_settings CONSTANT)
+ Q_PROPERTY(qPrefLocationService* Location MEMBER location_settings CONSTANT)
Q_PROPERTY(qPrefUpdateManager* update MEMBER update_manager_settings CONSTANT)
Q_PROPERTY(qPrefDiveComputer* dive_computer MEMBER dive_computer_settings CONSTANT)
@@ -235,7 +217,7 @@ public:
qPrefDisplay *display_settings;
LanguageSettingsObjectWrapper *language_settings;
qPrefAnimations *animation_settings;
- LocationServiceSettingsObjectWrapper *location_settings;
+ qPrefLocationService *location_settings;
qPrefUpdateManager *update_manager_settings;
qPrefDiveComputer *dive_computer_settings;
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 6a5043583..5ede64152 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -425,8 +425,8 @@ QMLManager *QMLManager::instance()
void QMLManager::savePreferences()
{
auto location = SettingsObjectWrapper::instance()->location_settings;
- location->setTimeThreshold(QMLPrefs::instance()->timeThreshold() * 60);
- location->setDistanceThreshold(QMLPrefs::instance()->distanceThreshold());
+ location->set_time_threshold(QMLPrefs::instance()->timeThreshold() * 60);
+ location->set_distance_threshold(QMLPrefs::instance()->distanceThreshold());
}
#define CLOUDURL QString(prefs.cloud_base_url)
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp
index 1c2b824c3..99480c3ac 100644
--- a/subsurface-helper.cpp
+++ b/subsurface-helper.cpp
@@ -162,6 +162,7 @@ void register_qml_types()
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
REGISTER_TYPE(qPrefDivePlanner, "SsrfDivePlannerPrefs");
REGISTER_TYPE(qPrefFacebook, "SsrfFacebookPrefs");
+ REGISTER_TYPE(qPrefLocationService, "SsrfLocationServicePrefs");
REGISTER_TYPE(qPrefProxy, "SsrfProxyPrefs");
REGISTER_TYPE(qPrefTechnicalDetails, "SsrfTechnicalDetailsPrefs");
REGISTER_TYPE(qPrefUnits, "SsrfUnitPrefs");
diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp
index bf2f0ed74..47de21219 100644
--- a/tests/testpreferences.cpp
+++ b/tests/testpreferences.cpp
@@ -147,15 +147,15 @@ void TestPreferences::testPreferences()
TEST(language->dateFormatOverride(), true);
TEST(language->useSystemLanguage(), true);
- auto location = pref->location_settings;
- location->setTimeThreshold(10);
- location->setDistanceThreshold(20);
+ auto location = qPrefLocationService::instance();
+ location->set_time_threshold(10);
+ location->set_distance_threshold(20);
- TEST(location->timeThreshold(), 10);
- TEST(location->distanceThreshold(), 20);
+ TEST(location->time_threshold(), 10);
+ TEST(location->distance_threshold(), 20);
- location->setTimeThreshold(30);
- location->setDistanceThreshold(40);
+ location->set_time_threshold(30);
+ location->set_distance_threshold(40);
TEST(location->timeThreshold(), 30);
TEST(location->distanceThreshold(), 40);