KConfig

kconfigpropertymap.h
1 /*
2  SPDX-FileCopyrightText: 2013 Marco Martin <[email protected]>
3  SPDX-FileCopyrightText: 2020 David Edmundson <[email protected]>
4  SPDX-FileCopyrightText: 2021 Alexander Lohnau <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef KCONFIGPROPERTYMAP_H
10 #define KCONFIGPROPERTYMAP_H
11 
12 #include <QQmlPropertyMap>
13 #include <memory>
14 
16 
17 #include <kconfigqml_export.h>
18 
19 class KConfigPropertyMapPrivate;
20 
21 /**
22  * @class KConfigPropertyMap configpropertymap.h ConfigPropertyMap
23  *
24  * An object that (optionally) automatically saves changes in a
25  * property map to a configuration object (e.g. a KConfig file).
26  * @since 5.89
27  */
28 class KCONFIGQML_EXPORT KConfigPropertyMap : public QQmlPropertyMap
29 {
30  Q_OBJECT
31 
32 public:
33  KConfigPropertyMap(KCoreConfigSkeleton *config, QObject *parent = nullptr);
34  ~KConfigPropertyMap() override;
35 
36  /**
37  * Whether notifications on config changes are enabled. Disabled by default.
38  * @see KConfigBase::Notify
39  * @return true if writes send (dbus) notifications
40  */
41  bool isNotify() const;
42 
43  /**
44  * Enable or disable notifications on config changes.
45  * @see KConfigBase::Notify
46  * @param notify whether to send notifications
47  */
48  void setNotify(bool notify);
49 
50  /**
51  * @brief Whether the value at the given key is immutable
52  *
53  * @return true if the value is immutable, false if it isn't or it doesn't exist
54  */
55  Q_INVOKABLE bool isImmutable(const QString &key) const;
56 
57  /**
58  * Saves the state of the property map on disk.
59  */
60  void writeConfig();
61 
62 protected:
63  QVariant updateValue(const QString &key, const QVariant &input) override;
64 
65 private:
66  std::unique_ptr<KConfigPropertyMapPrivate> const d;
67 };
68 
69 #endif
Class for handling preferences settings for an application.
virtual QVariant updateValue(const QString &key, const QVariant &input)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:20:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.