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 | |||
@@ -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) |
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 | |||
@@ -26,2 +26,3 @@ | |||
26 | #include <qfont.h> | 26 | #include <qfont.h> |
27 | #include <qsize.h> | ||
27 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
@@ -209,2 +210,16 @@ class KPrefs { | |||
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 | /** |
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 | |||
@@ -69,3 +69,3 @@ void KCMultiDialog::slotDefault() | |||
69 | 69 | ||
70 | int curPageIndex = mMainWidget->activePageIndex(); | 70 | int curPageIndex = activePageIndex(); |
71 | 71 | ||
@@ -209 +209,19 @@ 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 | |||
@@ -75,3 +75,3 @@ public: | |||
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); |
@@ -80,2 +80,5 @@ public: | |||
80 | 80 | ||
81 | bool showPage( int index ); | ||
82 | int activePageIndex() const; | ||
83 | int pageIndex( QWidget *widget ) const; | ||
81 | 84 | ||