-rw-r--r-- | microkde/kdecore/kprefs.cpp | 50 |
1 files changed, 49 insertions, 1 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 | |||
@@ -75,2 +75,17 @@ class KPrefsItemColor : public KPrefsItem { | |||
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 | ||
@@ -221,2 +236,29 @@ void KPrefsItemColor::readConfig(KConfig *config) | |||
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, |
@@ -402,2 +444,3 @@ void KPrefs::readConfig() | |||
402 | usrReadConfig(); | 444 | usrReadConfig(); |
445 | //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1()); | ||
403 | } | 446 | } |
@@ -412,3 +455,3 @@ void KPrefs::writeConfig() | |||
412 | usrWriteConfig(); | 455 | usrWriteConfig(); |
413 | 456 | //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1()); | |
414 | mConfig->sync(); | 457 | mConfig->sync(); |
@@ -442,2 +485,7 @@ void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaul | |||
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) |