| 1 | /* |
| 2 | This file is part of KDE. |
| 3 | SPDX-FileCopyrightText: 2001, 2002, 2003 Cornelius Schumacher <schumacher@kde.org> |
| 4 | SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> |
| 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 |
| 21 | * \inmodule KConfigGui |
| 22 | * |
| 23 | * \brief Class for handling preferences settings for an application. |
| 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 | * \inmodule KConfigGui |
| 33 | * Class for handling a color preferences item. |
| 34 | */ |
| 35 | class KCONFIGGUI_EXPORT ItemColor : public KConfigSkeletonGenericItem<QColor> |
| 36 | { |
| 37 | public: |
| 38 | /*! */ |
| 39 | ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128)); |
| 40 | |
| 41 | void readConfig(KConfig *config) override; |
| 42 | |
| 43 | void setProperty(const QVariant &p) override; |
| 44 | |
| 45 | bool isEqual(const QVariant &p) const override; |
| 46 | |
| 47 | QVariant property() const override; |
| 48 | }; |
| 49 | |
| 50 | /*! |
| 51 | * \inmodule KConfigGui |
| 52 | * Class for handling a font preferences item. |
| 53 | */ |
| 54 | class KCONFIGGUI_EXPORT ItemFont : public KConfigSkeletonGenericItem<QFont> |
| 55 | { |
| 56 | public: |
| 57 | /*! */ |
| 58 | ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue = QFont()); |
| 59 | |
| 60 | void readConfig(KConfig *config) override; |
| 61 | |
| 62 | void setProperty(const QVariant &p) override; |
| 63 | |
| 64 | bool isEqual(const QVariant &p) const override; |
| 65 | |
| 66 | QVariant property() const override; |
| 67 | }; |
| 68 | |
| 69 | public: |
| 70 | /*! |
| 71 | * Constructor. |
| 72 | * |
| 73 | * \a configname name of config file. If no name is given, the default |
| 74 | * config file as returned by KSharedConfig::openConfig() is used. |
| 75 | */ |
| 76 | explicit KConfigSkeleton(const QString &configname = QString(), QObject *parent = nullptr); |
| 77 | |
| 78 | /*! |
| 79 | * Constructor. |
| 80 | * |
| 81 | * \a config configuration object to use. |
| 82 | */ |
| 83 | explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = nullptr); |
| 84 | |
| 85 | /*! |
| 86 | * Register an item of type QColor. |
| 87 | * |
| 88 | * \a name Name used to identify this setting. Names must be unique. |
| 89 | * |
| 90 | * \a reference Pointer to the variable, which is set by read() |
| 91 | * calls and read by save() calls. |
| 92 | * |
| 93 | * \a defaultValue Default value, which is used when the config file |
| 94 | * does not yet contain the key of this item. |
| 95 | * |
| 96 | * \a key Key used in config file. If \a key is a null string, \a name is used as key. |
| 97 | * |
| 98 | * Returns the created item |
| 99 | */ |
| 100 | ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString()); |
| 101 | |
| 102 | /*! |
| 103 | * Register an item of type QFont. |
| 104 | * |
| 105 | * \a name Name used to identify this setting. Names must be unique. |
| 106 | * |
| 107 | * \a reference Pointer to the variable, which is set by read() |
| 108 | * calls and read by save() calls. |
| 109 | * |
| 110 | * \a defaultValue Default value, which is used when the config file |
| 111 | * does not yet contain the key of this item. |
| 112 | * |
| 113 | * \a key Key used in config file. If \a key is a null string, \a name is used as key. |
| 114 | * |
| 115 | * Returns the created item |
| 116 | */ |
| 117 | ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString()); |
| 118 | }; |
| 119 | |
| 120 | #endif |
| 121 | |