aboutsummaryrefslogtreecommitdiffstats
path: root/core/settings/qPref.cpp
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-08-31 11:57:28 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-11 17:22:58 -0700
commita71afd31ee66edf45c8970dcbd6514d7c4b5e9f0 (patch)
treef37c28d33c80aee2f0169f140d62ae751d46a9ed /core/settings/qPref.cpp
parent7940e45c4c56594a0fe43dda28f6126cb2ceb555 (diff)
downloadsubsurface-a71afd31ee66edf45c8970dcbd6514d7c4b5e9f0.tar.gz
core: add auto registration to qPref*
Instead of having all register calls in subsurface-helper.cpp let qPref.cpp handle all qPref registration, since they also need to be different update subsurface-helper and testqml accordingly. Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core/settings/qPref.cpp')
-rw-r--r--core/settings/qPref.cpp60
1 files changed, 46 insertions, 14 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp
index d1e3d8b23..b37024f32 100644
--- a/core/settings/qPref.cpp
+++ b/core/settings/qPref.cpp
@@ -2,6 +2,10 @@
#include "qPref.h"
#include "qPrefPrivate.h"
+#include <QQuickItem>
+#include <QQmlEngine>
+#include <QQmlContext>
+
qPref::qPref(QObject *parent) : QObject(parent)
{
}
@@ -17,18 +21,46 @@ void qPref::loadSync(bool doSync)
if (!doSync)
uiLanguage(NULL);
- qPrefCloudStorage::instance()->loadSync(doSync);
- qPrefDisplay::instance()->loadSync(doSync);
- qPrefDiveComputer::instance()->loadSync(doSync);
- qPrefDivePlanner::instance()->loadSync(doSync);
- // qPrefFaceook does not use disk.
- qPrefGeneral::instance()->loadSync(doSync);
- qPrefGeocoding::instance()->loadSync(doSync);
- qPrefLanguage::instance()->loadSync(doSync);
- qPrefLocationService::instance()->loadSync(doSync);
- qPrefPartialPressureGas::instance()->loadSync(doSync);
- qPrefProxy::instance()->loadSync(doSync);
- qPrefTechnicalDetails::instance()->loadSync(doSync);
- qPrefUnits::instance()->loadSync(doSync);
- qPrefUpdateManager::instance()->loadSync(doSync);
+ // the following calls, ensures qPref* is instanciated, registred and
+ // that properties are loaded
+ qPrefCloudStorage::loadSync(doSync);
+ qPrefDisplay::loadSync(doSync);
+ qPrefDiveComputer::loadSync(doSync);
+ qPrefDivePlanner::loadSync(doSync);
+ qPrefFacebook::loadSync(doSync);
+ qPrefGeneral::loadSync(doSync);
+ qPrefGeocoding::loadSync(doSync);
+ qPrefLanguage::loadSync(doSync);
+ qPrefLocationService::loadSync(doSync);
+ qPrefPartialPressureGas::loadSync(doSync);
+ qPrefProxy::loadSync(doSync);
+ qPrefTechnicalDetails::loadSync(doSync);
+ qPrefUnits::loadSync(doSync);
+ qPrefUpdateManager::loadSync(doSync);
+}
+
+#define REGISTER_QPREF(useClass, useQML) \
+ rc = qmlRegisterType<useClass>("org.subsurfacedivelog.mobile", 1, 0, useQML); \
+ if (rc < 0) \
+ qWarning() << "ERROR: Cannot register " << useQML << ", QML will not work!!";
+
+void qPref::registerQML()
+{
+ int rc;
+
+ REGISTER_QPREF(qPref, "SsrfPrefs");
+ REGISTER_QPREF(qPrefCloudStorage, "SsrfCloudStoragePrefs");
+ REGISTER_QPREF(qPrefDisplay, "SsrfDisplayPrefs");
+ REGISTER_QPREF(qPrefDiveComputer, "SsrfDiveComputerPrefs");
+ REGISTER_QPREF(qPrefDivePlanner, "SsrfDivePlannerPrefs");
+ REGISTER_QPREF(qPrefFacebook, "SsrfFacebookPrefs");
+ REGISTER_QPREF(qPrefGeneral, "SsrfGeneralPrefs");
+ REGISTER_QPREF(qPrefGeocoding, "SsrfGeocodingPrefs");
+ REGISTER_QPREF(qPrefLanguage, "SsrfLanguagePrefs");
+ REGISTER_QPREF(qPrefLocationService, "SsrfLocationServicePrefs");
+ REGISTER_QPREF(qPrefPartialPressureGas, "SsrfPartialPressureGasPrefs");
+ REGISTER_QPREF(qPrefProxy, "SsrfProxyPrefs");
+ REGISTER_QPREF(qPrefTechnicalDetails, "SsrfTechnicalDetailsPrefs");
+ REGISTER_QPREF(qPrefUnits, "SsrfUnitPrefs");
+ REGISTER_QPREF(qPrefUpdateManager, "SsrfUpdateManagerPrefs");
}