1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLSETTINGS_P_H
5#define QQMLSETTINGS_P_H
6
7#include "qqmlsettingsglobal_p.h"
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtQml/qqml.h>
21#include <QtCore/qobject.h>
22#include <QtCore/qscopedpointer.h>
23#include <QtQml/qqmlparserstatus.h>
24
25QT_BEGIN_NAMESPACE
26
27class QQmlSettingsPrivate;
28
29class Q_LABSSETTINGS_PRIVATE_EXPORT QQmlSettings : public QObject, public QQmlParserStatus
30{
31 Q_OBJECT
32 Q_INTERFACES(QQmlParserStatus)
33 Q_PROPERTY(QString category READ category WRITE setCategory FINAL)
34 Q_PROPERTY(QString fileName READ fileName WRITE setFileName FINAL)
35 QML_NAMED_ELEMENT(Settings)
36 QML_ADDED_IN_VERSION(1, 0)
37
38public:
39 explicit QQmlSettings(QObject *parent = nullptr);
40 ~QQmlSettings();
41
42 QString category() const;
43 void setCategory(const QString &category);
44
45 QString fileName() const;
46 void setFileName(const QString &fileName);
47
48 Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
49 Q_INVOKABLE void setValue(const QString &key, const QVariant &value);
50 Q_INVOKABLE void sync();
51
52protected:
53 void timerEvent(QTimerEvent *event) override;
54
55 void classBegin() override;
56 void componentComplete() override;
57
58private:
59 Q_DISABLE_COPY(QQmlSettings)
60 Q_DECLARE_PRIVATE(QQmlSettings)
61 QScopedPointer<QQmlSettingsPrivate> d_ptr;
62 Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged())
63};
64
65QT_END_NAMESPACE
66
67QML_DECLARE_TYPE(QQmlSettings)
68
69#endif // QQMLSETTINGS_P_H
70

source code of qtdeclarative/src/labs/settings/qqmlsettings_p.h