summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui
Unidiff
Diffstat (limited to 'microkde/kdeui') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kcmodule.cpp16
-rw-r--r--microkde/kdeui/kcmodule.h11
2 files changed, 18 insertions, 9 deletions
diff --git a/microkde/kdeui/kcmodule.cpp b/microkde/kdeui/kcmodule.cpp
index 915cd0f..f646db3 100644
--- a/microkde/kdeui/kcmodule.cpp
+++ b/microkde/kdeui/kcmodule.cpp
@@ -1,106 +1,114 @@
1/* 1/*
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 3
4 Copyright (c) 2001 Michael Goffioul <goffioul@imec.be> 4 Copyright (c) 2001 Michael Goffioul <goffioul@imec.be>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20 20
21*/ 21*/
22 22
23#include "kcmodule.h" 23#include "kcmodule.h"
24//US#include <kinstance.h> 24//US#include <kinstance.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28 28
29class KCModulePrivate 29class KCModulePrivate
30{ 30{
31public: 31public:
32//US KInstance *_instance; 32//US KInstance *_instance;
33 QString _rootOnlyMsg; 33 QString _rootOnlyMsg;
34 bool _useRootOnlyMsg; 34 bool _useRootOnlyMsg;
35 bool _hasOwnInstance; 35 bool _hasOwnInstance;
36 KPrefs* _prefs;
36}; 37};
37 38
38KCModule::KCModule(QWidget *parent, const char *name, const QStringList &) 39KCModule::KCModule(KPrefs* prefs, QWidget *parent, const char *name, const QStringList &)
39 : QWidget(parent, name), _btn(Help|Default|Apply) 40 : QWidget(parent, name), _btn(Help|Default|Apply)
40{ 41{
41 kdDebug() << "KCModule " << name << endl; 42 kdDebug() << "KCModule " << name << endl;
42 d = new KCModulePrivate; 43 d = new KCModulePrivate;
43 d->_useRootOnlyMsg = true; 44 d->_useRootOnlyMsg = true;
44/*US 45 d->_prefs = prefs;
46/*US
45 d->_instance = new KInstance(name); 47 d->_instance = new KInstance(name);
46 if (name && strlen(name)) { 48 if (name && strlen(name)) {
47 d->_instance = new KInstance(name); 49 d->_instance = new KInstance(name);
48 KGlobal::locale()->insertCatalogue(name); 50 KGlobal::locale()->insertCatalogue(name);
49 } else 51 } else
50 d->_instance = new KInstance("kcmunnamed"); 52 d->_instance = new KInstance("kcmunnamed");
51*/ 53*/
52 d->_hasOwnInstance = true; 54 d->_hasOwnInstance = true;
53//US KGlobal::setActiveInstance(this->instance()); 55//US KGlobal::setActiveInstance(this->instance());
54} 56}
55 57
56/*US 58/*US
57KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & ) 59KCModule::KCModule(KInstance *instance, QWidget *parent, const QStringList & )
58 : QWidget(parent, instance ? instance->instanceName().data() : 0), _btn(Help|Default|Apply) 60 : QWidget(parent, instance ? instance->instanceName().data() : 0), _btn(Help|Default|Apply)
59{ 61{
60 kdDebug() << "KCModule instance " << (instance ? instance->instanceName().data() : "none") << endl; 62 kdDebug() << "KCModule instance " << (instance ? instance->instanceName().data() : "none") << endl;
61 d = new KCModulePrivate; 63 d = new KCModulePrivate;
62 d->_useRootOnlyMsg = true; 64 d->_useRootOnlyMsg = true;
63 d->_instance = instance; 65 d->_instance = instance;
64 KGlobal::locale()->insertCatalogue(instance->instanceName()); 66 KGlobal::locale()->insertCatalogue(instance->instanceName());
65 d->_hasOwnInstance = false; 67 d->_hasOwnInstance = false;
66 KGlobal::setActiveInstance(this->instance()); 68 KGlobal::setActiveInstance(this->instance());
67} 69}
68*/ 70*/
69KCModule::~KCModule() 71KCModule::~KCModule()
70{ 72{
71/*US 73/*US
72 if (d->_hasOwnInstance) 74 if (d->_hasOwnInstance)
73 delete d->_instance; 75 delete d->_instance;
74*/ 76*/
75 delete d; 77 delete d;
76} 78}
77 79
78void KCModule::setRootOnlyMsg(const QString& msg) 80void KCModule::setRootOnlyMsg(const QString& msg)
79{ 81{
80 d->_rootOnlyMsg = msg; 82 d->_rootOnlyMsg = msg;
81} 83}
82 84
83QString KCModule::rootOnlyMsg() const 85QString KCModule::rootOnlyMsg() const
84{ 86{
85 return d->_rootOnlyMsg; 87 return d->_rootOnlyMsg;
86} 88}
87 89
88void KCModule::setUseRootOnlyMsg(bool on) 90void KCModule::setUseRootOnlyMsg(bool on)
89{ 91{
90 d->_useRootOnlyMsg = on; 92 d->_useRootOnlyMsg = on;
91} 93}
92 94
93bool KCModule::useRootOnlyMsg() const 95bool KCModule::useRootOnlyMsg() const
94{ 96{
95 return d->_useRootOnlyMsg; 97 return d->_useRootOnlyMsg;
96} 98}
99
100KPrefs* KCModule::getPreferences()
101{
102 return d->_prefs;
103}
104
97/*US 105/*US
98KInstance *KCModule::instance() const 106KInstance *KCModule::instance() const
99{ 107{
100 return d->_instance; 108 return d->_instance;
101} 109}
102*/ 110*/
103void KCModule::virtual_hook( int, void* ) 111void KCModule::virtual_hook( int, void* )
104{ /*BASE::virtual_hook( id, data );*/ } 112{ /*BASE::virtual_hook( id, data );*/ }
105 113
106//US #include "kcmodule.moc" 114//US #include "kcmodule.moc"
diff --git a/microkde/kdeui/kcmodule.h b/microkde/kdeui/kcmodule.h
index bc020bc..874958c 100644
--- a/microkde/kdeui/kcmodule.h
+++ b/microkde/kdeui/kcmodule.h
@@ -1,267 +1,268 @@
1/* 1/*
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 3
4 Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> 4 Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20 20
21*/ 21*/
22#ifndef __KCMODULE_H__ 22#ifndef __KCMODULE_H__
23#define __KCMODULE_H__ 23#define __KCMODULE_H__
24 24
25#include <qwidget.h> 25#include <qwidget.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27//USclass KAboutData; 27//USclass KAboutData;
28class KCModulePrivate; 28class KCModulePrivate;
29class KPrefs; 29class KPrefs;
30//US class KInstance; 30//US class KInstance;
31 31
32/** 32/**
33 * The base class for control center modules. 33 * The base class for control center modules.
34 * 34 *
35 * Starting from KDE 2.0, control center modules are realized as shared 35 * Starting from KDE 2.0, control center modules are realized as shared
36 * libraries that are loaded into the control center at runtime. 36 * libraries that are loaded into the control center at runtime.
37 * 37 *
38 * The module in principle is a simple widget displaying the 38 * The module in principle is a simple widget displaying the
39 * item to be changed. The module has a very small interface. 39 * item to be changed. The module has a very small interface.
40 * 40 *
41 * All the necessary glue logic and the GUI bells and whistles 41 * All the necessary glue logic and the GUI bells and whistles
42 * are provided by the control center and must not concern 42 * are provided by the control center and must not concern
43 * the module author. 43 * the module author.
44 * 44 *
45 * To write a config module, you have to create a library 45 * To write a config module, you have to create a library
46 * that contains at one factory function like this: 46 * that contains at one factory function like this:
47 * 47 *
48 * <pre> 48 * <pre>
49 * #include <kgenericfactory.h> 49 * #include <kgenericfactory.h>
50 * 50 *
51 * typedef KGenericFactory<YourKCModule, QWidget> YourKCModuleFactory; 51 * typedef KGenericFactory<YourKCModule, QWidget> YourKCModuleFactory;
52 * K_EXPORT_COMPONENT_FACTORY( yourLibName, YourKCModuleFactory("name_of_the_po_file") ); 52 * K_EXPORT_COMPONENT_FACTORY( yourLibName, YourKCModuleFactory("name_of_the_po_file") );
53 * </pre> 53 * </pre>
54 * 54 *
55 * The parameter "name_of_the_po_file" has to correspond with the messages target 55 * The parameter "name_of_the_po_file" has to correspond with the messages target
56 * that you created in your Makefile.am. 56 * that you created in your Makefile.am.
57 * 57 *
58 * See kdebase/kcontrol/HOWTO for more detailed documentation. 58 * See kdebase/kcontrol/HOWTO for more detailed documentation.
59 * 59 *
60 * @author Matthias Hoelzer-Kluepfel <hoelzer@kde.org> 60 * @author Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
61 */ 61 */
62 62
63class KCModule : public QWidget 63class KCModule : public QWidget
64{ 64{
65 Q_OBJECT 65 Q_OBJECT
66 66
67public: 67public:
68 68
69 /** 69 /**
70 * An enumeration type for the buttons used by this module. 70 * An enumeration type for the buttons used by this module.
71 * You should only use Help, Default and Apply. The rest is obsolete. 71 * You should only use Help, Default and Apply. The rest is obsolete.
72 * 72 *
73 * @see KCModule::buttons @see KCModule::setButtons 73 * @see KCModule::buttons @see KCModule::setButtons
74 */ 74 */
75 enum Button {Help=1, Default=2, Apply=16, 75 enum Button {Help=1, Default=2, Apply=16,
76 Reset=4, /* obsolete, do not use! */ 76 Reset=4, /* obsolete, do not use! */
77 Cancel=8, /* obsolete, do not use! */ 77 Cancel=8, /* obsolete, do not use! */
78 Ok=32, /* obsolete, do not use! */ 78 Ok=32, /* obsolete, do not use! */
79 SysDefault=64 /* obsolete, do not use! */ }; 79 SysDefault=64 /* obsolete, do not use! */ };
80 80
81 /* 81 /*
82 * Base class for all KControlModules. 82 * Base class for all KControlModules.
83 * Make sure you have a QStringList argument in your 83 * Make sure you have a QStringList argument in your
84 * implementation. 84 * implementation.
85 */ 85 */
86 KCModule(QWidget *parent=0, const char *name=0, const QStringList &args=QStringList() ); 86 KCModule(KPrefs* prefs, QWidget *parent=0, const char *name=0, const QStringList &args=QStringList() );
87 87
88//US KCModule(KInstance *instance, QWidget *parent=0, const QStringList &args=QStringList() ); 88//US KCModule(KInstance *instance, QWidget *parent=0, const QStringList &args=QStringList() );
89 89
90 /* 90 /*
91 * Destroys the module. 91 * Destroys the module.
92 */ 92 */
93 ~KCModule(); 93 ~KCModule();
94 94
95 /** 95 /**
96 * Load the configuration data into the module. 96 * Load the configuration data into the module.
97 * 97 *
98 * The load method sets the user interface elements of the 98 * The load method sets the user interface elements of the
99 * module to reflect the current settings stored in the 99 * module to reflect the current settings stored in the
100 * configuration files. 100 * configuration files.
101 * 101 *
102 * This method is invoked whenever the module should read its configuration 102 * This method is invoked whenever the module should read its configuration
103 * (most of the times from a config file) and update the user interface. 103 * (most of the times from a config file) and update the user interface.
104 * This happens when the user clicks the "Reset" button in the control 104 * This happens when the user clicks the "Reset" button in the control
105 * center, to undo all of his changes and restore the currently valid 105 * center, to undo all of his changes and restore the currently valid
106 * settings. NOTE that this is not called after the modules is loaded, 106 * settings. NOTE that this is not called after the modules is loaded,
107 * so you probably want to call this method in the constructor. 107 * so you probably want to call this method in the constructor.
108 */ 108 */
109 virtual void load(KPrefs* prefs) {}; 109 virtual void load() {};
110 110
111 /** 111 /**
112 * Save the configuration data. 112 * Save the configuration data.
113 * 113 *
114 * The save method stores the config information as shown 114 * The save method stores the config information as shown
115 * in the user interface in the config files. 115 * in the user interface in the config files.
116 * 116 *
117 * If necessary, this method also updates the running system, 117 * If necessary, this method also updates the running system,
118 * e.g. by restarting applications. 118 * e.g. by restarting applications.
119 * 119 *
120 * save is called when the user clicks "Apply" or "Ok". 120 * save is called when the user clicks "Apply" or "Ok".
121 */ 121 */
122 virtual void save(KPrefs* prefs) {}; 122 virtual void save() {};
123 123
124 /** 124 /**
125 * Sets the configuration to sensible default values. 125 * Sets the configuration to sensible default values.
126 * 126 *
127 * This method is called when the user clicks the "Default" 127 * This method is called when the user clicks the "Default"
128 * button. It should set the display to useful values. 128 * button. It should set the display to useful values.
129 */ 129 */
130 virtual void defaults(KPrefs* prefs) {}; 130 virtual void defaults() {};
131 131
132 /** 132 /**
133 * Set the configuration to system default values. 133 * Set the configuration to system default values.
134 * 134 *
135 * This method is called when the user clicks the "System-Default" 135 * This method is called when the user clicks the "System-Default"
136 * button. It should set the display to the system default values. 136 * button. It should set the display to the system default values.
137 * 137 *
138 * NOTE: The default behaviour is to call defaults(). 138 * NOTE: The default behaviour is to call defaults().
139 */ 139 */
140 virtual void sysdefaults(KPrefs* prefs) { defaults(prefs); }; 140 virtual void sysdefaults() { defaults(); };
141 141
142 /** 142 /**
143 * Return a quick-help text. 143 * Return a quick-help text.
144 * 144 *
145 * This method is called when the module is docked. 145 * This method is called when the module is docked.
146 * The quick-help text should contain a short description of the module and 146 * The quick-help text should contain a short description of the module and
147 * links to the module's help files. You can use QML formating tags in the text. 147 * links to the module's help files. You can use QML formating tags in the text.
148 * 148 *
149 * NOTE: Please make sure the quick help text gets translated (use i18n()). 149 * NOTE: Please make sure the quick help text gets translated (use i18n()).
150 */ 150 */
151 virtual QString quickHelp() const { return QString::null; }; 151 virtual QString quickHelp() const { return QString::null; };
152 152
153 /** 153 /**
154 * Returns a the KAboutData for this module 154 * Returns a the KAboutData for this module
155 * This is generally only called for the KBugReport. 155 * This is generally only called for the KBugReport.
156 * Override and have it return a pointer to a constant 156 * Override and have it return a pointer to a constant
157 */ 157 */
158//US virtual const KAboutData *aboutData() const { return 0; } 158//US virtual const KAboutData *aboutData() const { return 0; }
159 159
160 /** 160 /**
161 * Indicate which buttons will be used. 161 * Indicate which buttons will be used.
162 * 162 *
163 * The return value is a value or'ed together from 163 * The return value is a value or'ed together from
164 * the Button enumeration type. 164 * the Button enumeration type.
165 * 165 *
166 * @see KCModule::setButtons 166 * @see KCModule::setButtons
167 */ 167 */
168 int buttons() const { return _btn; }; 168 int buttons() const { return _btn; };
169 169
170 /** 170 /**
171 * Get the RootOnly message for this module. 171 * Get the RootOnly message for this module.
172 * 172 *
173 * When the module must be run as root, or acts differently 173 * When the module must be run as root, or acts differently
174 * for root and a normal user, it is sometimes useful to 174 * for root and a normal user, it is sometimes useful to
175 * customize the message that appears at the top of the module 175 * customize the message that appears at the top of the module
176 * when used as a normal user. This function returns this 176 * when used as a normal user. This function returns this
177 * customized message. If none has been set, a default message 177 * customized message. If none has been set, a default message
178 * will be used. 178 * will be used.
179 * 179 *
180 * @see KCModule::setRootOnlyMsg 180 * @see KCModule::setRootOnlyMsg
181 */ 181 */
182 QString rootOnlyMsg() const; 182 QString rootOnlyMsg() const;
183 183
184 /** 184 /**
185 * Tell if KControl should show a RootOnly message when run as 185 * Tell if KControl should show a RootOnly message when run as
186 * a normal user. 186 * a normal user.
187 * 187 *
188 * In some cases, the module don't want a RootOnly message to 188 * In some cases, the module don't want a RootOnly message to
189 * appear (for example if it has already one). This function 189 * appear (for example if it has already one). This function
190 * tells KControl if a RootOnly message should be shown 190 * tells KControl if a RootOnly message should be shown
191 * 191 *
192 * @see KCModule::setUseRootOnlyMsg 192 * @see KCModule::setUseRootOnlyMsg
193 */ 193 */
194 bool useRootOnlyMsg() const; 194 bool useRootOnlyMsg() const;
195 195
196 KPrefs* getPreferences();
196 197
197//US KInstance *instance() const; 198//US KInstance *instance() const;
198 199
199signals: 200signals:
200 201
201 /** 202 /**
202 * Indicate that the state of the modules contents has changed. 203 * Indicate that the state of the modules contents has changed.
203 * 204 *
204 * This signal is emitted whenever the state of the configuration 205 * This signal is emitted whenever the state of the configuration
205 * shown in the module changes. It allows the control center to 206 * shown in the module changes. It allows the control center to
206 * keep track of unsaved changes. 207 * keep track of unsaved changes.
207 * 208 *
208 */ 209 */
209 void changed(bool state); 210 void changed(bool state);
210 211
211 /** 212 /**
212 * Indicate that the module's quickhelp has changed. 213 * Indicate that the module's quickhelp has changed.
213 * 214 *
214 * Emit this signal whenever the module's quickhelp changes. 215 * Emit this signal whenever the module's quickhelp changes.
215 * Modules implemented as tabbed dialogs might want to implement 216 * Modules implemented as tabbed dialogs might want to implement
216 * per-tab quickhelp for example. 217 * per-tab quickhelp for example.
217 * 218 *
218 */ 219 */
219 void quickHelpChanged(); 220 void quickHelpChanged();
220 221
221protected: 222protected:
222 223
223 /** 224 /**
224 * Sets the buttons to display. 225 * Sets the buttons to display.
225 * 226 *
226 * Help: shows a "Help" button. 227 * Help: shows a "Help" button.
227 * Default: shows a "Use Defaults" button 228 * Default: shows a "Use Defaults" button
228 * Apply: in kcontrol this will show an "Apply" and "Reset" button 229 * Apply: in kcontrol this will show an "Apply" and "Reset" button
229 * in kcmshell this will show an "Ok", "Apply" and "Cancel" button 230 * in kcmshell this will show an "Ok", "Apply" and "Cancel" button
230 * 231 *
231 * If Apply is not specified, kcmshell will show a "Close" button. 232 * If Apply is not specified, kcmshell will show a "Close" button.
232 * 233 *
233 * @see KCModule::buttons 234 * @see KCModule::buttons
234 */ 235 */
235 void setButtons(int btn) { _btn = btn; }; 236 void setButtons(int btn) { _btn = btn; };
236 237
237 /** 238 /**
238 * Sets the RootOnly message. 239 * Sets the RootOnly message.
239 * 240 *
240 * This message will be shown at the top of the module of the 241 * This message will be shown at the top of the module of the
241 * corresponding desktop file contains the line X-KDE-RootOnly=true. 242 * corresponding desktop file contains the line X-KDE-RootOnly=true.
242 * If no message is set, a default one will be used. 243 * If no message is set, a default one will be used.
243 * 244 *
244 * @see KCModule::rootOnlyMessage 245 * @see KCModule::rootOnlyMessage
245 */ 246 */
246 void setRootOnlyMsg(const QString& msg); 247 void setRootOnlyMsg(const QString& msg);
247 248
248 /** 249 /**
249 * Change wether or not the RootOnly message should be shown. 250 * Change wether or not the RootOnly message should be shown.
250 * 251 *
251 * Following the value of @p on, the RootOnly message will be 252 * Following the value of @p on, the RootOnly message will be
252 * shown or not. 253 * shown or not.
253 * 254 *
254 * @see KCModule::useRootOnlyMsg 255 * @see KCModule::useRootOnlyMsg
255 */ 256 */
256 void setUseRootOnlyMsg(bool on); 257 void setUseRootOnlyMsg(bool on);
257 258
258private: 259private:
259 260
260 int _btn; 261 int _btn;
261protected: 262protected:
262 virtual void virtual_hook( int id, void* data ); 263 virtual void virtual_hook( int id, void* data );
263private: 264private:
264 KCModulePrivate *d; 265 KCModulePrivate *d;
265}; 266};
266 267
267#endif 268#endif