author | ulf69 <ulf69> | 2004-09-21 19:47:57 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-21 19:47:57 (UTC) |
commit | c2cce86fdb2d0b291c3d3bdfa9fac47452153d1a (patch) (unidiff) | |
tree | 6f8ac380b5db0831f02e4cc35cd0a6fd5ece5ff9 | |
parent | 427906b75a4672531f2b7d86b2a4a27427f5d4a4 (diff) | |
download | kdepimpi-c2cce86fdb2d0b291c3d3bdfa9fac47452153d1a.zip kdepimpi-c2cce86fdb2d0b291c3d3bdfa9fac47452153d1a.tar.gz kdepimpi-c2cce86fdb2d0b291c3d3bdfa9fac47452153d1a.tar.bz2 |
added prefwriting prefreading for size and font object
-rw-r--r-- | microkde/kdecore/kprefs.cpp | 50 | ||||
-rw-r--r-- | microkde/kdecore/kprefs.h | 15 | ||||
-rw-r--r-- | microkde/kutils/kcmultidialog.cpp | 20 | ||||
-rw-r--r-- | microkde/kutils/kcmultidialog.h | 5 |
4 files changed, 87 insertions, 3 deletions
diff --git a/microkde/kdecore/kprefs.cpp b/microkde/kdecore/kprefs.cpp index f5e5e5a..71050e7 100644 --- a/microkde/kdecore/kprefs.cpp +++ b/microkde/kdecore/kprefs.cpp | |||
@@ -44,64 +44,79 @@ class KPrefsItemBool : public KPrefsItem { | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | class KPrefsItemInt : public KPrefsItem { | 46 | class KPrefsItemInt : public KPrefsItem { |
47 | public: | 47 | public: |
48 | KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); | 48 | KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); |
49 | virtual ~KPrefsItemInt() {} | 49 | virtual ~KPrefsItemInt() {} |
50 | 50 | ||
51 | void setDefault(); | 51 | void setDefault(); |
52 | void readConfig(KConfig *); | 52 | void readConfig(KConfig *); |
53 | void writeConfig(KConfig *); | 53 | void writeConfig(KConfig *); |
54 | 54 | ||
55 | private: | 55 | private: |
56 | int *mReference; | 56 | int *mReference; |
57 | int mDefault; | 57 | int mDefault; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | 60 | ||
61 | class KPrefsItemColor : public KPrefsItem { | 61 | class KPrefsItemColor : public KPrefsItem { |
62 | public: | 62 | public: |
63 | KPrefsItemColor(const QString &group,const QString &name,QColor *, | 63 | KPrefsItemColor(const QString &group,const QString &name,QColor *, |
64 | const QColor &defaultValue=QColor(128,128,128)); | 64 | const QColor &defaultValue=QColor(128,128,128)); |
65 | virtual ~KPrefsItemColor() {} | 65 | virtual ~KPrefsItemColor() {} |
66 | 66 | ||
67 | void setDefault(); | 67 | void setDefault(); |
68 | void readConfig(KConfig *); | 68 | void readConfig(KConfig *); |
69 | void writeConfig(KConfig *); | 69 | void writeConfig(KConfig *); |
70 | 70 | ||
71 | private: | 71 | private: |
72 | QColor *mReference; | 72 | QColor *mReference; |
73 | QColor mDefault; | 73 | QColor mDefault; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | class KPrefsItemSize : public KPrefsItem { | ||
77 | public: | ||
78 | KPrefsItemSize(const QString &group,const QString &name,QSize *, | ||
79 | const QSize &defaultValue=QSize()); | ||
80 | ~KPrefsItemSize() {} | ||
81 | |||
82 | void setDefault(); | ||
83 | void readConfig(KConfig *); | ||
84 | void writeConfig(KConfig *); | ||
85 | |||
86 | private: | ||
87 | QSize *mReference; | ||
88 | QSize mDefault; | ||
89 | }; | ||
90 | |||
76 | 91 | ||
77 | class KPrefsItemFont : public KPrefsItem { | 92 | class KPrefsItemFont : public KPrefsItem { |
78 | public: | 93 | public: |
79 | KPrefsItemFont(const QString &group,const QString &name,QFont *, | 94 | KPrefsItemFont(const QString &group,const QString &name,QFont *, |
80 | const QFont &defaultValue=QFont("helvetica",12)); | 95 | const QFont &defaultValue=QFont("helvetica",12)); |
81 | virtual ~KPrefsItemFont() {} | 96 | virtual ~KPrefsItemFont() {} |
82 | 97 | ||
83 | void setDefault(); | 98 | void setDefault(); |
84 | void readConfig(KConfig *); | 99 | void readConfig(KConfig *); |
85 | void writeConfig(KConfig *); | 100 | void writeConfig(KConfig *); |
86 | 101 | ||
87 | private: | 102 | private: |
88 | QFont *mReference; | 103 | QFont *mReference; |
89 | QFont mDefault; | 104 | QFont mDefault; |
90 | }; | 105 | }; |
91 | 106 | ||
92 | 107 | ||
93 | class KPrefsItemString : public KPrefsItem { | 108 | class KPrefsItemString : public KPrefsItem { |
94 | public: | 109 | public: |
95 | KPrefsItemString(const QString &group,const QString &name,QString *, | 110 | KPrefsItemString(const QString &group,const QString &name,QString *, |
96 | const QString &defaultValue="", bool isPassword=false); | 111 | const QString &defaultValue="", bool isPassword=false); |
97 | virtual ~KPrefsItemString() {} | 112 | virtual ~KPrefsItemString() {} |
98 | 113 | ||
99 | void setDefault(); | 114 | void setDefault(); |
100 | void readConfig(KConfig *); | 115 | void readConfig(KConfig *); |
101 | void writeConfig(KConfig *); | 116 | void writeConfig(KConfig *); |
102 | 117 | ||
103 | private: | 118 | private: |
104 | QString *mReference; | 119 | QString *mReference; |
105 | QString mDefault; | 120 | QString mDefault; |
106 | bool mPassword; | 121 | bool mPassword; |
107 | }; | 122 | }; |
@@ -190,64 +205,91 @@ void KPrefsItemInt::readConfig(KConfig *config) | |||
190 | config->setGroup(mGroup); | 205 | config->setGroup(mGroup); |
191 | *mReference = config->readNumEntry(mName,mDefault); | 206 | *mReference = config->readNumEntry(mName,mDefault); |
192 | } | 207 | } |
193 | 208 | ||
194 | 209 | ||
195 | KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name, | 210 | KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name, |
196 | QColor *reference,const QColor &defaultValue) : | 211 | QColor *reference,const QColor &defaultValue) : |
197 | KPrefsItem(group,name) | 212 | KPrefsItem(group,name) |
198 | { | 213 | { |
199 | mReference = reference; | 214 | mReference = reference; |
200 | mDefault = defaultValue; | 215 | mDefault = defaultValue; |
201 | } | 216 | } |
202 | 217 | ||
203 | void KPrefsItemColor::setDefault() | 218 | void KPrefsItemColor::setDefault() |
204 | { | 219 | { |
205 | *mReference = mDefault; | 220 | *mReference = mDefault; |
206 | } | 221 | } |
207 | 222 | ||
208 | void KPrefsItemColor::writeConfig(KConfig *config) | 223 | void KPrefsItemColor::writeConfig(KConfig *config) |
209 | { | 224 | { |
210 | config->setGroup(mGroup); | 225 | config->setGroup(mGroup); |
211 | config->writeEntry(mName,*mReference); | 226 | config->writeEntry(mName,*mReference); |
212 | } | 227 | } |
213 | 228 | ||
214 | void KPrefsItemColor::readConfig(KConfig *config) | 229 | void KPrefsItemColor::readConfig(KConfig *config) |
215 | { | 230 | { |
216 | config->setGroup(mGroup); | 231 | config->setGroup(mGroup); |
217 | *mReference = config->readColorEntry(mName,&mDefault); | 232 | *mReference = config->readColorEntry(mName,&mDefault); |
218 | 233 | ||
219 | } | 234 | } |
220 | 235 | ||
221 | 236 | ||
237 | KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name, | ||
238 | QSize *reference,const QSize &defaultValue) : | ||
239 | KPrefsItem(group,name) | ||
240 | { | ||
241 | mReference = reference; | ||
242 | mDefault = defaultValue; | ||
243 | } | ||
244 | |||
245 | void KPrefsItemSize::setDefault() | ||
246 | { | ||
247 | *mReference = mDefault; | ||
248 | } | ||
249 | |||
250 | void KPrefsItemSize::writeConfig(KConfig *config) | ||
251 | { | ||
252 | config->setGroup(mGroup); | ||
253 | config->writeEntry(mName,*mReference); | ||
254 | } | ||
255 | |||
256 | void KPrefsItemSize::readConfig(KConfig *config) | ||
257 | { | ||
258 | config->setGroup(mGroup); | ||
259 | *mReference = config->readSizeEntry(mName,&mDefault); | ||
260 | |||
261 | } | ||
262 | |||
263 | |||
222 | KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name, | 264 | KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name, |
223 | QFont *reference,const QFont &defaultValue) : | 265 | QFont *reference,const QFont &defaultValue) : |
224 | KPrefsItem(group,name) | 266 | KPrefsItem(group,name) |
225 | { | 267 | { |
226 | mReference = reference; | 268 | mReference = reference; |
227 | mDefault = defaultValue; | 269 | mDefault = defaultValue; |
228 | } | 270 | } |
229 | 271 | ||
230 | void KPrefsItemFont::setDefault() | 272 | void KPrefsItemFont::setDefault() |
231 | { | 273 | { |
232 | *mReference = mDefault; | 274 | *mReference = mDefault; |
233 | } | 275 | } |
234 | 276 | ||
235 | void KPrefsItemFont::writeConfig(KConfig *config) | 277 | void KPrefsItemFont::writeConfig(KConfig *config) |
236 | { | 278 | { |
237 | config->setGroup(mGroup); | 279 | config->setGroup(mGroup); |
238 | config->writeEntry(mName,*mReference); | 280 | config->writeEntry(mName,*mReference); |
239 | } | 281 | } |
240 | 282 | ||
241 | void KPrefsItemFont::readConfig(KConfig *config) | 283 | void KPrefsItemFont::readConfig(KConfig *config) |
242 | { | 284 | { |
243 | config->setGroup(mGroup); | 285 | config->setGroup(mGroup); |
244 | *mReference = config->readFontEntry(mName,&mDefault); | 286 | *mReference = config->readFontEntry(mName,&mDefault); |
245 | } | 287 | } |
246 | 288 | ||
247 | 289 | ||
248 | QString endecryptStr( const QString &aStr ) | 290 | QString endecryptStr( const QString &aStr ) |
249 | { | 291 | { |
250 | QString result; | 292 | QString result; |
251 | uint i; | 293 | uint i; |
252 | for ( i = 0; i < aStr.length(); i++) | 294 | for ( i = 0; i < aStr.length(); i++) |
253 | result += (aStr.at(i).unicode() < 0x20) ? | 295 | result += (aStr.at(i).unicode() < 0x20) ? |
@@ -371,93 +413,99 @@ KPrefs::~KPrefs() | |||
371 | } | 413 | } |
372 | } | 414 | } |
373 | 415 | ||
374 | void KPrefs::setCurrentGroup(const QString &group) | 416 | void KPrefs::setCurrentGroup(const QString &group) |
375 | { | 417 | { |
376 | if (mCurrentGroup) delete mCurrentGroup; | 418 | if (mCurrentGroup) delete mCurrentGroup; |
377 | mCurrentGroup = new QString(group); | 419 | mCurrentGroup = new QString(group); |
378 | } | 420 | } |
379 | 421 | ||
380 | KConfig *KPrefs::config() const | 422 | KConfig *KPrefs::config() const |
381 | { | 423 | { |
382 | return mConfig; | 424 | return mConfig; |
383 | } | 425 | } |
384 | 426 | ||
385 | void KPrefs::setDefaults() | 427 | void KPrefs::setDefaults() |
386 | { | 428 | { |
387 | KPrefsItem *item; | 429 | KPrefsItem *item; |
388 | for(item = mItems.first();item;item = mItems.next()) { | 430 | for(item = mItems.first();item;item = mItems.next()) { |
389 | item->setDefault(); | 431 | item->setDefault(); |
390 | } | 432 | } |
391 | 433 | ||
392 | usrSetDefaults(); | 434 | usrSetDefaults(); |
393 | } | 435 | } |
394 | 436 | ||
395 | void KPrefs::readConfig() | 437 | void KPrefs::readConfig() |
396 | { | 438 | { |
397 | KPrefsItem *item; | 439 | KPrefsItem *item; |
398 | for(item = mItems.first();item;item = mItems.next()) { | 440 | for(item = mItems.first();item;item = mItems.next()) { |
399 | item->readConfig(mConfig); | 441 | item->readConfig(mConfig); |
400 | } | 442 | } |
401 | 443 | ||
402 | usrReadConfig(); | 444 | usrReadConfig(); |
445 | //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1()); | ||
403 | } | 446 | } |
404 | 447 | ||
405 | void KPrefs::writeConfig() | 448 | void KPrefs::writeConfig() |
406 | { | 449 | { |
407 | KPrefsItem *item; | 450 | KPrefsItem *item; |
408 | for(item = mItems.first();item;item = mItems.next()) { | 451 | for(item = mItems.first();item;item = mItems.next()) { |
409 | item->writeConfig(mConfig); | 452 | item->writeConfig(mConfig); |
410 | } | 453 | } |
411 | 454 | ||
412 | usrWriteConfig(); | 455 | usrWriteConfig(); |
413 | 456 | //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1()); | |
414 | mConfig->sync(); | 457 | mConfig->sync(); |
415 | } | 458 | } |
416 | 459 | ||
417 | 460 | ||
418 | void KPrefs::addItem(KPrefsItem *item) | 461 | void KPrefs::addItem(KPrefsItem *item) |
419 | { | 462 | { |
420 | mItems.append(item); | 463 | mItems.append(item); |
421 | } | 464 | } |
422 | 465 | ||
423 | void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue) | 466 | void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue) |
424 | { | 467 | { |
425 | addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue)); | 468 | addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue)); |
426 | } | 469 | } |
427 | 470 | ||
428 | void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) | 471 | void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) |
429 | { | 472 | { |
430 | addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue)); | 473 | addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue)); |
431 | } | 474 | } |
432 | 475 | ||
433 | void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) | 476 | void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) |
434 | { | 477 | { |
435 | addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); | 478 | addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); |
436 | } | 479 | } |
437 | 480 | ||
438 | void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) | 481 | void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) |
439 | { | 482 | { |
440 | addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); | 483 | addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); |
441 | } | 484 | } |
442 | 485 | ||
486 | void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) | ||
487 | { | ||
488 | addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); | ||
489 | } | ||
490 | |||
443 | void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) | 491 | void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) |
444 | { | 492 | { |
445 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); | 493 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); |
446 | } | 494 | } |
447 | 495 | ||
448 | void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) | 496 | void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) |
449 | { | 497 | { |
450 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); | 498 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); |
451 | } | 499 | } |
452 | 500 | ||
453 | void KPrefs::addItemStringList(const QString &key,QStringList *reference, | 501 | void KPrefs::addItemStringList(const QString &key,QStringList *reference, |
454 | const QStringList &defaultValue) | 502 | const QStringList &defaultValue) |
455 | { | 503 | { |
456 | addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); | 504 | addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); |
457 | } | 505 | } |
458 | 506 | ||
459 | void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, | 507 | void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, |
460 | const QValueList<int> &defaultValue) | 508 | const QValueList<int> &defaultValue) |
461 | { | 509 | { |
462 | addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); | 510 | addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); |
463 | } | 511 | } |
diff --git a/microkde/kdecore/kprefs.h b/microkde/kdecore/kprefs.h index 7014bb8..95d2724 100644 --- a/microkde/kdecore/kprefs.h +++ b/microkde/kdecore/kprefs.h | |||
@@ -1,58 +1,59 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef _KPREFS_H | 20 | #ifndef _KPREFS_H |
21 | #define _KPREFS_H | 21 | #define _KPREFS_H |
22 | // $Id$ | 22 | // $Id$ |
23 | 23 | ||
24 | #include <qptrlist.h> | 24 | #include <qptrlist.h> |
25 | #include <qcolor.h> | 25 | #include <qcolor.h> |
26 | #include <qfont.h> | 26 | #include <qfont.h> |
27 | #include <qsize.h> | ||
27 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
28 | 29 | ||
29 | class KConfig; | 30 | class KConfig; |
30 | 31 | ||
31 | /** | 32 | /** |
32 | @short Class for storing a preferences setting | 33 | @short Class for storing a preferences setting |
33 | @author Cornelius Schumacher | 34 | @author Cornelius Schumacher |
34 | @see KPref | 35 | @see KPref |
35 | 36 | ||
36 | This class represents one preferences setting as used by @ref KPrefs. | 37 | This class represents one preferences setting as used by @ref KPrefs. |
37 | Subclasses of KPrefsItem implement storage functions for a certain type of | 38 | Subclasses of KPrefsItem implement storage functions for a certain type of |
38 | setting. Normally you don't have to use this class directly. Use the special | 39 | setting. Normally you don't have to use this class directly. Use the special |
39 | addItem() functions of KPrefs instead. If you subclass this class you will | 40 | addItem() functions of KPrefs instead. If you subclass this class you will |
40 | have to register instances with the function KPrefs::addItem(). | 41 | have to register instances with the function KPrefs::addItem(). |
41 | */ | 42 | */ |
42 | class KPrefsItem { | 43 | class KPrefsItem { |
43 | public: | 44 | public: |
44 | /** | 45 | /** |
45 | Constructor. | 46 | Constructor. |
46 | 47 | ||
47 | @param group Config file group. | 48 | @param group Config file group. |
48 | @param name Config file key. | 49 | @param name Config file key. |
49 | */ | 50 | */ |
50 | KPrefsItem(const QString &group,const QString &name) : | 51 | KPrefsItem(const QString &group,const QString &name) : |
51 | mGroup(group),mName(name) {} | 52 | mGroup(group),mName(name) {} |
52 | /** | 53 | /** |
53 | Destructor. | 54 | Destructor. |
54 | */ | 55 | */ |
55 | virtual ~KPrefsItem() {} | 56 | virtual ~KPrefsItem() {} |
56 | 57 | ||
57 | /** | 58 | /** |
58 | This function is called by @ref KPrefs to set this setting to its default | 59 | This function is called by @ref KPrefs to set this setting to its default |
@@ -178,64 +179,78 @@ class KPrefs { | |||
178 | @param reference Pointer to the variable, which is set by readConfig() | 179 | @param reference Pointer to the variable, which is set by readConfig() |
179 | and setDefaults() calls and read by writeConfig() calls. | 180 | and setDefaults() calls and read by writeConfig() calls. |
180 | @param defaultValue Default value, which is used by setDefaults() and | 181 | @param defaultValue Default value, which is used by setDefaults() and |
181 | when the config file does not yet contain the key of | 182 | when the config file does not yet contain the key of |
182 | this item. | 183 | this item. |
183 | */ | 184 | */ |
184 | void addItemBool(const QString &key,bool *reference, | 185 | void addItemBool(const QString &key,bool *reference, |
185 | bool defaultValue=false); | 186 | bool defaultValue=false); |
186 | /** | 187 | /** |
187 | Register an item of type int. | 188 | Register an item of type int. |
188 | 189 | ||
189 | @param key Key used in config file. | 190 | @param key Key used in config file. |
190 | @param reference Pointer to the variable, which is set by readConfig() | 191 | @param reference Pointer to the variable, which is set by readConfig() |
191 | and setDefaults() calls and read by writeConfig() calls. | 192 | and setDefaults() calls and read by writeConfig() calls. |
192 | @param defaultValue Default value, which is used by setDefaults() and | 193 | @param defaultValue Default value, which is used by setDefaults() and |
193 | when the config file does not yet contain the key of | 194 | when the config file does not yet contain the key of |
194 | this item. | 195 | this item. |
195 | */ | 196 | */ |
196 | void addItemInt(const QString &key,int *reference, | 197 | void addItemInt(const QString &key,int *reference, |
197 | int defaultValue=0); | 198 | int defaultValue=0); |
198 | /** | 199 | /** |
199 | Register an item of type QColor. | 200 | Register an item of type QColor. |
200 | 201 | ||
201 | @param key Key used in config file. | 202 | @param key Key used in config file. |
202 | @param reference Pointer to the variable, which is set by readConfig() | 203 | @param reference Pointer to the variable, which is set by readConfig() |
203 | and setDefaults() calls and read by writeConfig() calls. | 204 | and setDefaults() calls and read by writeConfig() calls. |
204 | @param defaultValue Default value, which is used by setDefaults() and | 205 | @param defaultValue Default value, which is used by setDefaults() and |
205 | when the config file does not yet contain the key of | 206 | when the config file does not yet contain the key of |
206 | this item. | 207 | this item. |
207 | */ | 208 | */ |
208 | void addItemColor(const QString &key,QColor *reference, | 209 | void addItemColor(const QString &key,QColor *reference, |
209 | const QColor &defaultValue=QColor(128,128,128)); | 210 | const QColor &defaultValue=QColor(128,128,128)); |
211 | |||
212 | /** | ||
213 | Register an item of type QSize. | ||
214 | |||
215 | @param key Key used in config file. | ||
216 | @param reference Pointer to the variable, which is set by readConfig() | ||
217 | and setDefaults() calls and read by writeConfig() calls. | ||
218 | @param defaultValue Default value, which is used by setDefaults() and | ||
219 | when the config file does not yet contain the key of | ||
220 | this item. | ||
221 | */ | ||
222 | void addItemSize(const QString &key,QSize *reference, | ||
223 | const QSize &defaultValue=QSize()); | ||
224 | |||
210 | /** | 225 | /** |
211 | Register an item of type QFont. | 226 | Register an item of type QFont. |
212 | 227 | ||
213 | @param key Key used in config file. | 228 | @param key Key used in config file. |
214 | @param reference Pointer to the variable, which is set by readConfig() | 229 | @param reference Pointer to the variable, which is set by readConfig() |
215 | and setDefaults() calls and read by writeConfig() calls. | 230 | and setDefaults() calls and read by writeConfig() calls. |
216 | @param defaultValue Default value, which is used by setDefaults() and | 231 | @param defaultValue Default value, which is used by setDefaults() and |
217 | when the config file does not yet contain the key of | 232 | when the config file does not yet contain the key of |
218 | this item. | 233 | this item. |
219 | */ | 234 | */ |
220 | void addItemFont(const QString &key,QFont *reference, | 235 | void addItemFont(const QString &key,QFont *reference, |
221 | const QFont &defaultValue=QFont("helvetica",12)); | 236 | const QFont &defaultValue=QFont("helvetica",12)); |
222 | /** | 237 | /** |
223 | Register an item of type QString. | 238 | Register an item of type QString. |
224 | 239 | ||
225 | @param key Key used in config file. | 240 | @param key Key used in config file. |
226 | @param reference Pointer to the variable, which is set by readConfig() | 241 | @param reference Pointer to the variable, which is set by readConfig() |
227 | and setDefaults() calls and read by writeConfig() calls. | 242 | and setDefaults() calls and read by writeConfig() calls. |
228 | @param defaultValue Default value, which is used by setDefaults() and | 243 | @param defaultValue Default value, which is used by setDefaults() and |
229 | when the config file does not yet contain the key of | 244 | when the config file does not yet contain the key of |
230 | this item. | 245 | this item. |
231 | */ | 246 | */ |
232 | void addItemString(const QString &key,QString *reference, | 247 | void addItemString(const QString &key,QString *reference, |
233 | const QString &defaultValue=""); | 248 | const QString &defaultValue=""); |
234 | /** | 249 | /** |
235 | Register a password item of type QString. The string value is written | 250 | Register a password item of type QString. The string value is written |
236 | encrypted to the config file. Note that the current encryption scheme | 251 | encrypted to the config file. Note that the current encryption scheme |
237 | is very weak. | 252 | is very weak. |
238 | 253 | ||
239 | @param key Key used in config file. | 254 | @param key Key used in config file. |
240 | @param reference Pointer to the variable, which is set by readConfig() | 255 | @param reference Pointer to the variable, which is set by readConfig() |
241 | and setDefaults() calls and read by writeConfig() calls. | 256 | and setDefaults() calls and read by writeConfig() calls. |
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp index e7aa9d1..c4ccede 100644 --- a/microkde/kutils/kcmultidialog.cpp +++ b/microkde/kutils/kcmultidialog.cpp | |||
@@ -38,65 +38,65 @@ | |||
38 | //US #include "kcmoduleloader.h" | 38 | //US #include "kcmoduleloader.h" |
39 | 39 | ||
40 | KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) | 40 | KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) |
41 | : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, | 41 | : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, |
42 | parent, name, modal, true), d(0L) | 42 | parent, name, modal, true), d(0L) |
43 | { | 43 | { |
44 | enableButton(Apply, false); | 44 | enableButton(Apply, false); |
45 | //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); | 45 | //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); |
46 | 46 | ||
47 | connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); | 47 | connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); |
48 | 48 | ||
49 | _baseGroup = baseGroup; | 49 | _baseGroup = baseGroup; |
50 | mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); | 50 | mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); |
51 | setMainWidget(mMainWidget ); | 51 | setMainWidget(mMainWidget ); |
52 | #ifdef DESKTOP_VERSION | 52 | #ifdef DESKTOP_VERSION |
53 | resize(640,480); | 53 | resize(640,480); |
54 | #else | 54 | #else |
55 | resize(640,480); | 55 | resize(640,480); |
56 | setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); | 56 | setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); |
57 | //showMaximized(); | 57 | //showMaximized(); |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | } | 60 | } |
61 | 61 | ||
62 | KCMultiDialog::~KCMultiDialog() | 62 | KCMultiDialog::~KCMultiDialog() |
63 | { | 63 | { |
64 | //US moduleDict.setAutoDelete(true); | 64 | //US moduleDict.setAutoDelete(true); |
65 | } | 65 | } |
66 | 66 | ||
67 | void KCMultiDialog::slotDefault() | 67 | void KCMultiDialog::slotDefault() |
68 | { | 68 | { |
69 | 69 | ||
70 | int curPageIndex = mMainWidget->activePageIndex(); | 70 | int curPageIndex = activePageIndex(); |
71 | 71 | ||
72 | QPtrListIterator<KCModule> it(modules); | 72 | QPtrListIterator<KCModule> it(modules); |
73 | for (; it.current(); ++it) | 73 | for (; it.current(); ++it) |
74 | { | 74 | { |
75 | if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) | 75 | if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) |
76 | { | 76 | { |
77 | (*it)->defaults(); | 77 | (*it)->defaults(); |
78 | clientChanged(true); | 78 | clientChanged(true); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | } | 83 | } |
84 | void KCMultiDialog::accept() | 84 | void KCMultiDialog::accept() |
85 | { | 85 | { |
86 | slotOk(); | 86 | slotOk(); |
87 | } | 87 | } |
88 | void KCMultiDialog::slotApply() | 88 | void KCMultiDialog::slotApply() |
89 | { | 89 | { |
90 | qDebug("KCMultiDialog::slotApply clicked"); | 90 | qDebug("KCMultiDialog::slotApply clicked"); |
91 | 91 | ||
92 | QPtrListIterator<KCModule> it(modules); | 92 | QPtrListIterator<KCModule> it(modules); |
93 | for (; it.current(); ++it) | 93 | for (; it.current(); ++it) |
94 | (*it)->save(); | 94 | (*it)->save(); |
95 | clientChanged(false); | 95 | clientChanged(false); |
96 | 96 | ||
97 | emit applyClicked(); | 97 | emit applyClicked(); |
98 | 98 | ||
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void KCMultiDialog::slotOk() | 102 | void KCMultiDialog::slotOk() |
@@ -178,32 +178,50 @@ void KCMultiDialog::slotAboutToShow(QWidget *page) | |||
178 | 178 | ||
179 | QApplication::setOverrideCursor(Qt::WaitCursor); | 179 | QApplication::setOverrideCursor(Qt::WaitCursor); |
180 | 180 | ||
181 | moduleDict.remove(page); | 181 | moduleDict.remove(page); |
182 | 182 | ||
183 | KCModuleInfo info(loadInfo->path, _baseGroup); | 183 | KCModuleInfo info(loadInfo->path, _baseGroup); |
184 | 184 | ||
185 | KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); | 185 | KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); |
186 | 186 | ||
187 | if (!module) | 187 | if (!module) |
188 | { | 188 | { |
189 | QApplication::restoreOverrideCursor(); | 189 | QApplication::restoreOverrideCursor(); |
190 | KCModuleLoader::showLastLoaderError(this); | 190 | KCModuleLoader::showLastLoaderError(this); |
191 | delete loadInfo; | 191 | delete loadInfo; |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | 194 | ||
195 | module->reparent(page,0,QPoint(0,0),true); | 195 | module->reparent(page,0,QPoint(0,0),true); |
196 | connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); | 196 | connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); |
197 | //setHelp( docpath, QString::null ); | 197 | //setHelp( docpath, QString::null ); |
198 | _docPath = info.docPath(); | 198 | _docPath = info.docPath(); |
199 | modules.append(module); | 199 | modules.append(module); |
200 | 200 | ||
201 | //KCGlobal::repairAccels( topLevelWidget() ); | 201 | //KCGlobal::repairAccels( topLevelWidget() ); |
202 | 202 | ||
203 | delete loadInfo; | 203 | delete loadInfo; |
204 | 204 | ||
205 | QApplication::restoreOverrideCursor(); | 205 | QApplication::restoreOverrideCursor(); |
206 | */ | 206 | */ |
207 | 207 | ||
208 | qDebug("KCMultiDialog::slotAboutToShow not implemented"); | 208 | qDebug("KCMultiDialog::slotAboutToShow not implemented"); |
209 | } | 209 | } |
210 | |||
211 | |||
212 | bool KCMultiDialog::showPage( int index ) | ||
213 | { | ||
214 | return(mMainWidget->showPage(index) ); | ||
215 | } | ||
216 | |||
217 | |||
218 | int KCMultiDialog::activePageIndex() const | ||
219 | { | ||
220 | return( mMainWidget->activePageIndex() ); | ||
221 | } | ||
222 | |||
223 | |||
224 | int KCMultiDialog::pageIndex( QWidget *widget ) const | ||
225 | { | ||
226 | return( mMainWidget->pageIndex( widget) ); | ||
227 | } | ||
diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h index 768faea..66412ac 100644 --- a/microkde/kutils/kcmultidialog.h +++ b/microkde/kutils/kcmultidialog.h | |||
@@ -44,69 +44,72 @@ class KCMultiDialog : public KDialogBase | |||
44 | 44 | ||
45 | public: | 45 | public: |
46 | /** | 46 | /** |
47 | * Constructs a new KCMultiDialog | 47 | * Constructs a new KCMultiDialog |
48 | * | 48 | * |
49 | * @param parent The parent Widget | 49 | * @param parent The parent Widget |
50 | * @param name The widget name | 50 | * @param name The widget name |
51 | * @param baseGroup The baseGroup, if you want to call a module out of | 51 | * @param baseGroup The baseGroup, if you want to call a module out of |
52 | * kcontrol, just keep "settings" | 52 | * kcontrol, just keep "settings" |
53 | * @param modal If you pass true here, the dialog will be modal | 53 | * @param modal If you pass true here, the dialog will be modal |
54 | **/ | 54 | **/ |
55 | KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"), | 55 | KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"), |
56 | QWidget *parent=0, const char *name=0, | 56 | QWidget *parent=0, const char *name=0, |
57 | bool modal=false); | 57 | bool modal=false); |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Destructor | 60 | * Destructor |
61 | **/ | 61 | **/ |
62 | virtual ~KCMultiDialog(); | 62 | virtual ~KCMultiDialog(); |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Add a module. | 65 | * Add a module. |
66 | * | 66 | * |
67 | * @param module Specify the name of the module that is to be added | 67 | * @param module Specify the name of the module that is to be added |
68 | * to the list of modules the dialog will show. | 68 | * to the list of modules the dialog will show. |
69 | * | 69 | * |
70 | * @param withfallback Try harder to load the module. Might result | 70 | * @param withfallback Try harder to load the module. Might result |
71 | * in the module appearing outside the dialog. | 71 | * in the module appearing outside the dialog. |
72 | **/ | 72 | **/ |
73 | //US void addModule(const QString& module, bool withfallback=true); | 73 | //US void addModule(const QString& module, bool withfallback=true); |
74 | 74 | ||
75 | 75 | ||
76 | //US special method for microkde. We dop noty want to load everything dynamically. | 76 | //US special method for microkde. We do not want to load everything dynamically. |
77 | void addModule(KCModule* module );//, const QString& modulename, const QString& iconname); | 77 | void addModule(KCModule* module );//, const QString& modulename, const QString& iconname); |
78 | QVBox* getNewVBoxPage(const QString & modulename) ; | 78 | QVBox* getNewVBoxPage(const QString & modulename) ; |
79 | 79 | ||
80 | 80 | ||
81 | bool showPage( int index ); | ||
82 | int activePageIndex() const; | ||
83 | int pageIndex( QWidget *widget ) const; | ||
81 | 84 | ||
82 | protected slots: | 85 | protected slots: |
83 | /** | 86 | /** |
84 | * This slot is called when the user presses the "Default" Button | 87 | * This slot is called when the user presses the "Default" Button |
85 | * You can reimplement it if needed. | 88 | * You can reimplement it if needed. |
86 | * | 89 | * |
87 | * @note Make sure you call the original implementation! | 90 | * @note Make sure you call the original implementation! |
88 | **/ | 91 | **/ |
89 | virtual void slotDefault(); | 92 | virtual void slotDefault(); |
90 | 93 | ||
91 | /** | 94 | /** |
92 | * This slot is called when the user presses the "Apply" Button | 95 | * This slot is called when the user presses the "Apply" Button |
93 | * You can reimplement it if needed | 96 | * You can reimplement it if needed |
94 | * | 97 | * |
95 | * @note Make sure you call the original implementation! | 98 | * @note Make sure you call the original implementation! |
96 | **/ | 99 | **/ |
97 | virtual void slotApply(); | 100 | virtual void slotApply(); |
98 | 101 | ||
99 | /** | 102 | /** |
100 | * This slot is called when the user presses the "OK" Button | 103 | * This slot is called when the user presses the "OK" Button |
101 | * You can reimplement it if needed | 104 | * You can reimplement it if needed |
102 | * | 105 | * |
103 | * @note Make sure you call the original implementation! | 106 | * @note Make sure you call the original implementation! |
104 | **/ | 107 | **/ |
105 | virtual void slotOk(); | 108 | virtual void slotOk(); |
106 | 109 | ||
107 | /** | 110 | /** |
108 | * This slot is called when the user presses the "Help" Button | 111 | * This slot is called when the user presses the "Help" Button |
109 | * You can reimplement it if needed | 112 | * You can reimplement it if needed |
110 | * | 113 | * |
111 | * @note Make sure you call the original implementation! | 114 | * @note Make sure you call the original implementation! |
112 | **/ | 115 | **/ |