1/*
2 SPDX-FileCopyrightText: 2020 Kevin Ottens <kevin.ottens@enioka.com>
3 SPDX-FileCopyrightText: 2020 Cyril Rossi <cyril.rossi@enioka.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef SETTINGSTATEPROXY_H
9#define SETTINGSTATEPROXY_H
10
11#include <QObject>
12#include <QPointer>
13#include <QQmlEngine>
14
15#include <KCoreConfigSkeleton>
16
17/**
18 * This element allows to represent in a declarative way the
19 * state of a particular setting in a config object.
20 *
21 * @since 5.73
22 */
23class SettingStateProxy : public QObject
24{
25 Q_OBJECT
26 QML_ELEMENT
27
28 /**
29 * The config object which will be monitored for setting state changes
30 */
31 Q_PROPERTY(KCoreConfigSkeleton *configObject READ configObject WRITE setConfigObject NOTIFY configObjectChanged)
32
33 /**
34 * The name of the setting in the config object
35 */
36 Q_PROPERTY(QString settingName READ settingName WRITE setSettingName NOTIFY settingNameChanged)
37
38 /**
39 * Indicates if the setting is marked as immutable
40 */
41 Q_PROPERTY(bool immutable READ isImmutable NOTIFY immutableChanged)
42
43 /**
44 * Indicates if the setting differs from its default value
45 */
46 Q_PROPERTY(bool defaulted READ isDefaulted NOTIFY defaultedChanged)
47
48public:
49 using QObject::QObject;
50
51 KCoreConfigSkeleton *configObject() const;
52 void setConfigObject(KCoreConfigSkeleton *configObject);
53
54 QString settingName() const;
55 void setSettingName(const QString &settingName);
56
57 bool isImmutable() const;
58 bool isDefaulted() const;
59
60Q_SIGNALS:
61 void configObjectChanged();
62 void settingNameChanged();
63
64 void immutableChanged();
65 void defaultedChanged();
66
67private Q_SLOTS:
68 void updateState();
69
70private:
71 void connectSetting();
72
73 QPointer<KCoreConfigSkeleton> m_configObject;
74 QString m_settingName;
75 bool m_immutable = false;
76 bool m_defaulted = true;
77};
78
79#endif
80

source code of kcmutils/src/qml/settingstateproxy.h