1 | /* |
2 | * This file is part of KDE. |
3 | * |
4 | * Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | * Copyright (c) 2003 Waldo Bastian <bastian@kde.org> |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Library General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Library General Public License |
18 | * along with this library; see the file COPYING.LIB. If not, write to |
19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | * Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef KCONFIGSKELETON_H |
24 | #define KCONFIGSKELETON_H |
25 | |
26 | #include <kdeui_export.h> |
27 | |
28 | #include <kcoreconfigskeleton.h> |
29 | |
30 | #include <QtGui/QColor> |
31 | #include <QtGui/QFont> |
32 | |
33 | /** |
34 | * @short Class for handling preferences settings for an application. |
35 | * @author Cornelius Schumacher |
36 | * |
37 | * This class extends KCoreConfigSkeleton by support for GUI types. |
38 | * |
39 | */ |
40 | class KDEUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton |
41 | { |
42 | Q_OBJECT |
43 | public: |
44 | /** |
45 | * Class for handling a color preferences item. |
46 | */ |
47 | class KDEUI_EXPORT ItemColor:public KConfigSkeletonGenericItem < QColor > |
48 | { |
49 | public: |
50 | /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ |
51 | ItemColor(const QString & _group, const QString & _key, |
52 | QColor & reference, |
53 | const QColor & defaultValue = QColor(128, 128, 128)); |
54 | |
55 | /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ |
56 | void readConfig(KConfig * config); |
57 | |
58 | /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */ |
59 | void setProperty(const QVariant & p); |
60 | |
61 | /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */ |
62 | bool isEqual(const QVariant &p) const; |
63 | |
64 | /** @copydoc KConfigSkeletonItem::property() */ |
65 | QVariant property() const; |
66 | }; |
67 | |
68 | |
69 | /** |
70 | * Class for handling a font preferences item. |
71 | */ |
72 | class KDEUI_EXPORT ItemFont:public KConfigSkeletonGenericItem < QFont > |
73 | { |
74 | public: |
75 | /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ |
76 | ItemFont(const QString & _group, const QString & _key, QFont & reference, |
77 | const QFont & defaultValue = QFont()); |
78 | |
79 | /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ |
80 | void readConfig(KConfig * config); |
81 | |
82 | /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */ |
83 | void setProperty(const QVariant & p); |
84 | |
85 | /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */ |
86 | bool isEqual(const QVariant &p) const; |
87 | |
88 | /** @copydoc KConfigSkeletonItem::property() */ |
89 | QVariant property() const; |
90 | }; |
91 | |
92 | public: |
93 | /** |
94 | * Constructor. |
95 | * |
96 | * @param configname name of config file. If no name is given, the default |
97 | * config file as returned by KGlobal::config() is used. |
98 | */ |
99 | explicit KConfigSkeleton(const QString & configname = QString(), QObject* parent = 0); |
100 | |
101 | /** |
102 | * Constructor. |
103 | * |
104 | * @param config configuration object to use. |
105 | */ |
106 | explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject* parent = 0); |
107 | |
108 | /** |
109 | * Register an item of type QColor. |
110 | * |
111 | * @param name Name used to identify this setting. Names must be unique. |
112 | * @param reference Pointer to the variable, which is set by readConfig() |
113 | * calls and read by writeConfig() calls. |
114 | * @param defaultValue Default value, which is used when the config file |
115 | * does not yet contain the key of this item. |
116 | * @param key Key used in config file. If key is null, name is used as key. |
117 | * @return The created item |
118 | */ |
119 | ItemColor *addItemColor(const QString & name, QColor & reference, |
120 | const QColor & defaultValue = QColor(128, 128, 128), |
121 | const QString & key = QString()); |
122 | |
123 | /** |
124 | * Register an item of type QFont. |
125 | * |
126 | * @param name Name used to identify this setting. Names must be unique. |
127 | * @param reference Pointer to the variable, which is set by readConfig() |
128 | * calls and read by writeConfig() calls. |
129 | * @param defaultValue Default value, which is used when the config file |
130 | * does not yet contain the key of this item. |
131 | * @param key Key used in config file. If key is null, name is used as key. |
132 | * @return The created item |
133 | */ |
134 | ItemFont *addItemFont(const QString & name, QFont & reference, |
135 | const QFont & defaultValue = QFont(), |
136 | const QString & key = QString()); |
137 | |
138 | }; |
139 | |
140 | #endif |
141 | |