2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#include "fake_gsettings.h"
21
GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0;
23
GSettingsControllerQml::GSettingsControllerQml()
24
: m_fingerprintNames()
28
GSettingsControllerQml::~GSettingsControllerQml() {
29
s_controllerInstance = 0;
32
GSettingsControllerQml* GSettingsControllerQml::instance() {
33
if (!s_controllerInstance) {
34
s_controllerInstance = new GSettingsControllerQml();
36
return s_controllerInstance;
39
QVariantMap GSettingsControllerQml::fingerprintNames() const
41
return m_fingerprintNames;
44
void GSettingsControllerQml::setFingerprintNames(QVariantMap map)
46
if (map != m_fingerprintNames) {
47
m_fingerprintNames = map;
48
Q_EMIT fingerprintNamesChanged();
52
GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) {
55
QByteArray GSettingsSchemaQml::id() const {
59
void GSettingsSchemaQml::setId(const QByteArray &id) {
60
if (!m_id.isEmpty()) {
61
qWarning("GSettings.schema.id may only be set on construction");
68
QByteArray GSettingsSchemaQml::path() const {
72
void GSettingsSchemaQml::setPath(const QByteArray &path) {
73
if (!m_path.isEmpty()) {
74
qWarning("GSettings.schema.path may only be set on construction");
81
GSettingsQml::GSettingsQml(QObject *parent)
85
m_schema = new GSettingsSchemaQml(this);
88
void GSettingsQml::classBegin()
92
void GSettingsQml::componentComplete()
94
// Emulate what the real GSettings module does, and only return undefined
95
// values until we are completed loading.
98
// FIXME: We should make this dynamic, instead of hard-coding all possible
99
// properties in one object. We should create properties based on the schema.
100
connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::fingerprintNamesChanged,
101
this, &GSettingsQml::fingerprintNamesChanged);
103
Q_EMIT fingerprintNamesChanged();
106
GSettingsSchemaQml * GSettingsQml::schema() const {
110
QVariantMap GSettingsQml::fingerprintNames() const
112
if (m_valid && m_schema->id() == "com.ubuntu.touch.system") {
113
return GSettingsControllerQml::instance()->fingerprintNames();
115
return QVariantMap();
119
void GSettingsQml::setFingerprintNames(const QVariantMap &map)
121
if (m_valid && m_schema->id() == "com.ubuntu.touch.system") {
122
GSettingsControllerQml::instance()->setFingerprintNames(map);