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 class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton
28 {
29  Q_OBJECT
30 public:
31  /**
32  * Class for handling a color preferences item.
33  */
34  class KCONFIGGUI_EXPORT ItemColor : public KConfigSkeletonGenericItem<QColor>
35  {
36  public:
37  /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
38  ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128));
39 
40  /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
41  void readConfig(KConfig *config) override;
42 
43  /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
44  void setProperty(const QVariant &p) override;
45 
46  /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
47  bool isEqual(const QVariant &p) const override;
48 
49  /** @copydoc KConfigSkeletonItem::property() */
50  QVariant property() const override;
51  };
52 
53  /**
54  * Class for handling a font preferences item.
55  */
56  class KCONFIGGUI_EXPORT ItemFont : public KConfigSkeletonGenericItem<QFont>
57  {
58  public:
59  /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
60  ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue = QFont());
61 
62  /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
63  void readConfig(KConfig *config) override;
64 
65  /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
66  void setProperty(const QVariant &p) override;
67 
68  /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
69  bool isEqual(const QVariant &p) const override;
70 
71  /** @copydoc KConfigSkeletonItem::property() */
72  QVariant property() const override;
73  };
74 
75 public:
76  /**
77  * Constructor.
78  *
79  * @param configname name of config file. If no name is given, the default
80  * config file as returned by KSharedConfig::openConfig() is used.
81  */
82  explicit KConfigSkeleton(const QString &configname = QString(), QObject *parent = nullptr);
83 
84  /**
85  * Constructor.
86  *
87  * @param config configuration object to use.
88  */
89  explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = nullptr);
90 
91  /**
92  * Register an item of type QColor.
93  *
94  * @param name Name used to identify this setting. Names must be unique.
95  * @param reference Pointer to the variable, which is set by read()
96  * calls and read by save() calls.
97  * @param defaultValue Default value, which is used when the config file
98  * does not yet contain the key of this item.
99  * @param key Key used in config file. If @p key is a null string, @p name is used as key.
100  * @return The created item
101  */
102  ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString());
103 
104  /**
105  * Register an item of type QFont.
106  *
107  * @param name Name used to identify this setting. Names must be unique.
108  * @param reference Pointer to the variable, which is set by read()
109  * calls and read by save() calls.
110  * @param defaultValue Default value, which is used when the config file
111  * does not yet contain the key of this item.
112  * @param key Key used in config file. If @p key is a null string, @p name is used as key.
113  * @return The created item
114  */
115  ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString());
116 };
117 
118 #endif
virtual QVariant property() const =0
Return item as property.
Class for handling preferences settings for an application.
virtual void setProperty(const QVariant &p)=0
Set item to p.
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 font preferences item.
virtual void readConfig(KConfig *)=0
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file.
Base class for storing a preferences setting of type T.
Class for handling a color preferences item.
virtual bool isEqual(const QVariant &p) const =0
Check whether the item is equal to p.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed May 25 2022 04:10:41 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.