File: gsettings-qml.h

package info (click to toggle)
gsettings-qt 0.1%2B17.10.20170824-9
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 268 kB
  • sloc: cpp: 550; xml: 31; makefile: 19
file content (80 lines) | stat: -rw-r--r-- 2,187 bytes parent folder | download | duplicates (4)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Copyright 2013 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Lars Uebernickel <lars.uebernickel@canonical.com>
 */

#include <QtQml>
#include <QQmlParserStatus>

class GSettingsSchemaQml: public QObject
{
    Q_OBJECT
    Q_PROPERTY(QByteArray id      READ id      WRITE setId)
    Q_PROPERTY(QByteArray path    READ path    WRITE setPath)
    Q_PROPERTY(bool       isValid READ isValid NOTIFY isValidChanged)

public:
    GSettingsSchemaQml(QObject *parent = NULL);
    ~GSettingsSchemaQml();

    QByteArray id() const;
    void setId(const QByteArray &id);

    QByteArray path() const;
    void setPath(const QByteArray &path);

    bool isValid() const;
    void setIsValid(bool valid);

    Q_INVOKABLE QVariantList choices(const QByteArray &key) const;
    Q_INVOKABLE void reset(const QByteArray &key);

Q_SIGNALS:
    void isValidChanged();

private:
    struct GSettingsSchemaQmlPrivate *priv;
};

class GSettingsQml: public QQmlPropertyMap, public QQmlParserStatus
{
    Q_OBJECT
    Q_INTERFACES(QQmlParserStatus)
    Q_PROPERTY(GSettingsSchemaQml* schema READ schema NOTIFY schemaChanged)

public:
    GSettingsQml(QObject *parent = NULL);
    ~GSettingsQml();

    GSettingsSchemaQml * schema() const;

    void classBegin();
    void componentComplete();

Q_SIGNALS:
    void schemaChanged();
    void changed (const QString &key, const QVariant &value);

private Q_SLOTS:
    void settingChanged(const QString &key);

private:
    struct GSettingsQmlPrivate *priv;

    QVariant updateValue(const QString& key, const QVariant &value);

    friend class GSettingsSchemaQml;
};