KCMUtils

settingstateproxy.h
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 */
24{
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
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
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
This element allows to represent in a declarative way the state of a particular setting in a config o...
QML_ELEMENTKCoreConfigSkeleton * configObject
The config object which will be monitored for setting state changes.
bool defaulted
Indicates if the setting differs from its default value.
QString settingName
The name of the setting in the config object.
bool immutable
Indicates if the setting is marked as immutable.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.