summaryrefslogtreecommitdiffstats
path: root/core/settings/qPref.cpp
blob: b37024f328ea90728111557080a38d19d222f3a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: GPL-2.0
#include "qPref.h"
#include "qPrefPrivate.h"

#include <QQuickItem>
#include <QQmlEngine>
#include <QQmlContext>

qPref::qPref(QObject *parent) : QObject(parent)
{
}

qPref *qPref::instance()
{
	static qPref *self = new qPref;
	return self;
}

void qPref::loadSync(bool doSync)
{
	if (!doSync)
		uiLanguage(NULL);

	// 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");
}