KConfig

kconfigskeleton.h
1 /*
2  This file is part of KDE.
3  SPDX-FileCopyrightText: 2001, 2002, 2003 Cornelius Schumacher <[email protected]>
4  SPDX-FileCopyrightText: 2003 Waldo Bastian <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef KCONFIGSKELETON_H
10 #define KCONFIGSKELETON_H
11 
12 #include <kconfiggui_export.h>
13 
14 #include <kcoreconfigskeleton.h>
15 
16 #include <QColor>
17 #include <QFont>
18 
19 /**
20  * @class KConfigSkeleton kconfigskeleton.h <KConfigSkeleton>
21  *
22  * @short Class for handling preferences settings for an application.
23  * @author Cornelius Schumacher
24  *
25  * This class extends KCoreConfigSkeleton by support for GUI types.
26  *
27  */
28 class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton
29 {
30  Q_OBJECT
31 public:
32  /**
33  * Class for handling a color preferences item.
34  */
35  class KCONFIGGUI_EXPORT ItemColor : public KConfigSkeletonGenericItem<QColor>
36  {
37  public:
38  /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
39  ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128));
40 
41  /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
42  void readConfig(KConfig *config) override;
43 
44  /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
45  void setProperty(const QVariant &p) override;
46 
47  /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
48  bool isEqual(const QVariant &p) const override;
49 
50  /** @copydoc KConfigSkeletonItem::property() */
51  QVariant property() const override;
52  };
53 
54  /**
55  * Class for handling a font preferences item.
56  */
57  class KCONFIGGUI_EXPORT ItemFont : public KConfigSkeletonGenericItem<QFont>
58  {
59  public:
60  /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
61  ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue = QFont());
62 
63  /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
64  void readConfig(KConfig *config) override;
65 
66  /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
67  void setProperty(const QVariant &p) override;
68 
69  /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
70  bool isEqual(const QVariant &p) const override;
71 
72  /** @copydoc KConfigSkeletonItem::property() */
73  QVariant property() const override;
74  };
75 
76 public:
77  /**
78  * Constructor.
79  *
80  * @param configname name of config file. If no name is given, the default
81  * config file as returned by KSharedConfig::openConfig() is used.
82  */
83  explicit KConfigSkeleton(const QString &configname = QString(), QObject *parent = nullptr);
84 
85  /**
86  * Constructor.
87  *
88  * @param config configuration object to use.
89  */
90  explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = nullptr);
91 
92  /**
93  * Register an item of type QColor.
94  *
95  * @param name Name used to identify this setting. Names must be unique.
96  * @param reference Pointer to the variable, which is set by read()
97  * calls and read by save() calls.
98  * @param defaultValue Default value, which is used when the config file
99  * does not yet contain the key of this item.
100  * @param key Key used in config file. If key is null, name is used as key.
101  * @return The created item
102  */
103  ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString());
104 
105  /**
106  * Register an item of type QFont.
107  *
108  * @param name Name used to identify this setting. Names must be unique.
109  * @param reference Pointer to the variable, which is set by read()
110  * calls and read by save() calls.
111  * @param defaultValue Default value, which is used when the config file
112  * does not yet contain the key of this item.
113  * @param key Key used in config file. If key is null, name is used as key.
114  * @return The created item
115  */
116  ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString());
117 };
118 
119 #endif
Class for handling preferences settings for an application.
const QLatin1String name
Class for handling a font preferences item.
Class for handling preferences settings for an application.
The central class of the KDE configuration data system.
Definition: kconfig.h:56
Class for handling a color preferences item.
QCA_EXPORT void setProperty(const QString &name, const QVariant &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Nov 28 2021 22:43:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.