1 | // Copyright (C) 2022 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 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/qobject.h> |
19 | #include <QtCore/qvariant.h> |
20 | #include <QtCore/qurl.h> |
21 | #include <QtQml/qqml.h> |
22 | #include <QtQml/qqmlparserstatus.h> |
23 | #include <QtQmlCore/private/qqmlcoreglobal_p.h> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QQmlSettingsPrivate; |
28 | |
29 | class Q_QMLCORE_PRIVATE_EXPORT QQmlSettings : public QObject, public QQmlParserStatus |
30 | { |
31 | Q_OBJECT |
32 | Q_INTERFACES(QQmlParserStatus) |
33 | Q_DECLARE_PRIVATE(QQmlSettings) |
34 | QML_NAMED_ELEMENT(Settings) |
35 | QML_ADDED_IN_VERSION(6, 5) |
36 | |
37 | Q_PROPERTY(QString category READ category WRITE setCategory NOTIFY categoryChanged FINAL) |
38 | Q_PROPERTY(QUrl location READ location WRITE setLocation NOTIFY locationChanged FINAL) |
39 | |
40 | public: |
41 | explicit QQmlSettings(QObject *parent = nullptr); |
42 | ~QQmlSettings() override; |
43 | |
44 | QString category() const; |
45 | void setCategory(const QString &category); |
46 | |
47 | QUrl location() const; |
48 | void setLocation(const QUrl &location); |
49 | |
50 | Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = {}) const; |
51 | Q_INVOKABLE void setValue(const QString &key, const QVariant &value); |
52 | Q_INVOKABLE void sync(); |
53 | |
54 | Q_SIGNALS: |
55 | void categoryChanged(const QString &arg); |
56 | void locationChanged(const QUrl &arg); |
57 | |
58 | protected: |
59 | void timerEvent(QTimerEvent *event) override; |
60 | |
61 | void classBegin() override; |
62 | void componentComplete() override; |
63 | |
64 | private: |
65 | QScopedPointer<QQmlSettingsPrivate> d_ptr; |
66 | |
67 | Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged()) |
68 | }; |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | #endif // QQMLSETTINGS_P_H |
73 |