-rw-r--r-- | libkdepim/kprefsdialog.cpp | 30 | ||||
-rw-r--r-- | libkdepim/kprefsdialog.h | 26 |
2 files changed, 56 insertions, 0 deletions
diff --git a/libkdepim/kprefsdialog.cpp b/libkdepim/kprefsdialog.cpp index b6ae775..6dc741d 100644 --- a/libkdepim/kprefsdialog.cpp +++ b/libkdepim/kprefsdialog.cpp | |||
@@ -1,410 +1,440 @@ | |||
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 program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // $Id$ | 24 | // $Id$ |
25 | 25 | ||
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qgroupbox.h> | 28 | #include <qgroupbox.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qfont.h> | 31 | #include <qfont.h> |
32 | #include <qslider.h> | 32 | #include <qslider.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qhbox.h> | 36 | #include <qhbox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qframe.h> | 39 | #include <qframe.h> |
40 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
41 | #include <qcheckbox.h> | 41 | #include <qcheckbox.h> |
42 | #include <qradiobutton.h> | 42 | #include <qradiobutton.h> |
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qapplication.h> | 44 | #include <qapplication.h> |
45 | 45 | ||
46 | #include <kcolorbutton.h> | 46 | #include <kcolorbutton.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | #include <klocale.h> | 48 | #include <klocale.h> |
49 | #include <kglobal.h> | 49 | #include <kglobal.h> |
50 | #include <kglobalsettings.h> | ||
50 | #include <kfontdialog.h> | 51 | #include <kfontdialog.h> |
51 | #include <kmessagebox.h> | 52 | #include <kmessagebox.h> |
52 | #include <kcolordialog.h> | 53 | #include <kcolordialog.h> |
53 | #include <kiconloader.h> | 54 | #include <kiconloader.h> |
54 | 55 | ||
55 | #include "kprefs.h" | 56 | #include "kprefs.h" |
57 | #include "kpimglobalprefs.h" | ||
56 | 58 | ||
57 | #include "kprefsdialog.h" | 59 | #include "kprefsdialog.h" |
58 | //#include "kprefsdialog.moc" | 60 | //#include "kprefsdialog.moc" |
59 | 61 | ||
60 | KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference, | 62 | KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference, |
61 | QWidget *parent) | 63 | QWidget *parent) |
62 | { | 64 | { |
63 | mReference = reference; | 65 | mReference = reference; |
64 | 66 | ||
65 | mCheck = new QCheckBox(text,parent); | 67 | mCheck = new QCheckBox(text,parent); |
66 | } | 68 | } |
67 | 69 | ||
68 | void KPrefsDialogWidBool::readConfig() | 70 | void KPrefsDialogWidBool::readConfig() |
69 | { | 71 | { |
70 | mCheck->setChecked(*mReference); | 72 | mCheck->setChecked(*mReference); |
71 | } | 73 | } |
72 | 74 | ||
73 | void KPrefsDialogWidBool::writeConfig() | 75 | void KPrefsDialogWidBool::writeConfig() |
74 | { | 76 | { |
75 | *mReference = mCheck->isChecked(); | 77 | *mReference = mCheck->isChecked(); |
76 | } | 78 | } |
77 | 79 | ||
78 | QCheckBox *KPrefsDialogWidBool::checkBox() | 80 | QCheckBox *KPrefsDialogWidBool::checkBox() |
79 | { | 81 | { |
80 | return mCheck; | 82 | return mCheck; |
81 | } | 83 | } |
82 | 84 | ||
83 | 85 | ||
84 | KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference, | 86 | KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference, |
85 | QWidget *parent) | 87 | QWidget *parent) |
86 | { | 88 | { |
87 | mReference = reference; | 89 | mReference = reference; |
88 | 90 | ||
89 | mButton = new KColorButton(parent); | 91 | mButton = new KColorButton(parent); |
90 | mLabel = new QLabel(mButton, text, parent); | 92 | mLabel = new QLabel(mButton, text, parent); |
91 | mButton->setColor( *mReference ); | 93 | mButton->setColor( *mReference ); |
92 | mButton->setColor( Qt::red ); | 94 | mButton->setColor( Qt::red ); |
93 | 95 | ||
94 | } | 96 | } |
95 | 97 | ||
96 | KPrefsDialogWidColor::~KPrefsDialogWidColor() | 98 | KPrefsDialogWidColor::~KPrefsDialogWidColor() |
97 | { | 99 | { |
98 | // kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl; | 100 | // kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl; |
99 | } | 101 | } |
100 | 102 | ||
101 | void KPrefsDialogWidColor::readConfig() | 103 | void KPrefsDialogWidColor::readConfig() |
102 | { | 104 | { |
103 | mButton->setColor(*mReference); | 105 | mButton->setColor(*mReference); |
104 | } | 106 | } |
105 | 107 | ||
106 | void KPrefsDialogWidColor::writeConfig() | 108 | void KPrefsDialogWidColor::writeConfig() |
107 | { | 109 | { |
108 | *mReference = mButton->color(); | 110 | *mReference = mButton->color(); |
109 | } | 111 | } |
110 | 112 | ||
111 | QLabel *KPrefsDialogWidColor::label() | 113 | QLabel *KPrefsDialogWidColor::label() |
112 | { | 114 | { |
113 | return mLabel; | 115 | return mLabel; |
114 | } | 116 | } |
115 | 117 | ||
116 | KColorButton *KPrefsDialogWidColor::button() | 118 | KColorButton *KPrefsDialogWidColor::button() |
117 | { | 119 | { |
118 | return mButton; | 120 | return mButton; |
119 | } | 121 | } |
120 | 122 | ||
121 | KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, | 123 | KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, |
122 | QFont *reference,QWidget *parent) | 124 | QFont *reference,QWidget *parent) |
123 | { | 125 | { |
124 | mReference = reference; | 126 | mReference = reference; |
125 | 127 | ||
126 | mLabel = new QLabel(labelText, parent); | 128 | mLabel = new QLabel(labelText, parent); |
127 | 129 | ||
128 | mPreview = new QLabel(sampleText,parent); | 130 | mPreview = new QLabel(sampleText,parent); |
129 | mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 131 | mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
130 | 132 | ||
131 | mButton = new QPushButton(i18n("Choose..."), parent); | 133 | mButton = new QPushButton(i18n("Choose..."), parent); |
132 | connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); | 134 | connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); |
133 | mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); | 135 | mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); |
134 | mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); | 136 | mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); |
135 | } | 137 | } |
136 | 138 | ||
137 | KPrefsDialogWidFont::~KPrefsDialogWidFont() | 139 | KPrefsDialogWidFont::~KPrefsDialogWidFont() |
138 | { | 140 | { |
139 | } | 141 | } |
140 | 142 | ||
141 | void KPrefsDialogWidFont::readConfig() | 143 | void KPrefsDialogWidFont::readConfig() |
142 | { | 144 | { |
143 | mPreview->setFont(*mReference); | 145 | mPreview->setFont(*mReference); |
144 | } | 146 | } |
145 | 147 | ||
146 | void KPrefsDialogWidFont::writeConfig() | 148 | void KPrefsDialogWidFont::writeConfig() |
147 | { | 149 | { |
148 | *mReference = mPreview->font(); | 150 | *mReference = mPreview->font(); |
149 | } | 151 | } |
150 | 152 | ||
151 | QLabel *KPrefsDialogWidFont::label() | 153 | QLabel *KPrefsDialogWidFont::label() |
152 | { | 154 | { |
153 | return mLabel; | 155 | return mLabel; |
154 | } | 156 | } |
155 | 157 | ||
156 | QLabel *KPrefsDialogWidFont::preview() | 158 | QLabel *KPrefsDialogWidFont::preview() |
157 | { | 159 | { |
158 | return mPreview; | 160 | return mPreview; |
159 | } | 161 | } |
160 | 162 | ||
161 | QPushButton *KPrefsDialogWidFont::button() | 163 | QPushButton *KPrefsDialogWidFont::button() |
162 | { | 164 | { |
163 | return mButton; | 165 | return mButton; |
164 | } | 166 | } |
165 | 167 | ||
166 | void KPrefsDialogWidFont::selectFont() | 168 | void KPrefsDialogWidFont::selectFont() |
167 | { | 169 | { |
168 | QFont myFont(mPreview->font()); | 170 | QFont myFont(mPreview->font()); |
169 | bool ok; | 171 | bool ok; |
170 | myFont = KFontDialog::getFont(myFont, ok); | 172 | myFont = KFontDialog::getFont(myFont, ok); |
171 | if ( ok ) { | 173 | if ( ok ) { |
172 | mPreview->setFont(myFont); | 174 | mPreview->setFont(myFont); |
173 | } | 175 | } |
174 | } | 176 | } |
175 | 177 | ||
176 | 178 | ||
177 | KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference, | 179 | KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference, |
178 | QWidget *parent) | 180 | QWidget *parent) |
179 | { | 181 | { |
180 | mReference = reference; | 182 | mReference = reference; |
181 | 183 | ||
182 | mLabel = new QLabel(text,parent); | 184 | mLabel = new QLabel(text,parent); |
183 | mSpin = new QSpinBox(0,23,1,parent); | 185 | mSpin = new QSpinBox(0,23,1,parent); |
184 | mSpin->setSuffix(":00"); | 186 | mSpin->setSuffix(":00"); |
185 | } | 187 | } |
186 | 188 | ||
187 | void KPrefsDialogWidTime::readConfig() | 189 | void KPrefsDialogWidTime::readConfig() |
188 | { | 190 | { |
189 | mSpin->setValue(*mReference); | 191 | mSpin->setValue(*mReference); |
190 | } | 192 | } |
191 | 193 | ||
192 | void KPrefsDialogWidTime::writeConfig() | 194 | void KPrefsDialogWidTime::writeConfig() |
193 | { | 195 | { |
194 | *mReference = mSpin->value(); | 196 | *mReference = mSpin->value(); |
195 | } | 197 | } |
196 | 198 | ||
197 | QLabel *KPrefsDialogWidTime::label() | 199 | QLabel *KPrefsDialogWidTime::label() |
198 | { | 200 | { |
199 | return mLabel; | 201 | return mLabel; |
200 | } | 202 | } |
201 | 203 | ||
202 | QSpinBox *KPrefsDialogWidTime::spinBox() | 204 | QSpinBox *KPrefsDialogWidTime::spinBox() |
203 | { | 205 | { |
204 | return mSpin; | 206 | return mSpin; |
205 | } | 207 | } |
206 | 208 | ||
207 | 209 | ||
208 | KPrefsDialogWidRadios::KPrefsDialogWidRadios(const QString &text,int *reference, | 210 | KPrefsDialogWidRadios::KPrefsDialogWidRadios(const QString &text,int *reference, |
209 | QWidget *parent) | 211 | QWidget *parent) |
210 | { | 212 | { |
211 | mReference = reference; | 213 | mReference = reference; |
212 | 214 | ||
213 | mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); | 215 | mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); |
214 | } | 216 | } |
215 | 217 | ||
216 | KPrefsDialogWidRadios::~KPrefsDialogWidRadios() | 218 | KPrefsDialogWidRadios::~KPrefsDialogWidRadios() |
217 | { | 219 | { |
218 | } | 220 | } |
219 | 221 | ||
220 | void KPrefsDialogWidRadios::addRadio(const QString &text) | 222 | void KPrefsDialogWidRadios::addRadio(const QString &text) |
221 | { | 223 | { |
222 | new QRadioButton(text,mBox); | 224 | new QRadioButton(text,mBox); |
223 | } | 225 | } |
224 | 226 | ||
225 | QButtonGroup *KPrefsDialogWidRadios::groupBox() | 227 | QButtonGroup *KPrefsDialogWidRadios::groupBox() |
226 | { | 228 | { |
227 | return mBox; | 229 | return mBox; |
228 | } | 230 | } |
229 | 231 | ||
230 | void KPrefsDialogWidRadios::readConfig() | 232 | void KPrefsDialogWidRadios::readConfig() |
231 | { | 233 | { |
232 | mBox->setButton(*mReference); | 234 | mBox->setButton(*mReference); |
233 | } | 235 | } |
234 | 236 | ||
235 | void KPrefsDialogWidRadios::writeConfig() | 237 | void KPrefsDialogWidRadios::writeConfig() |
236 | { | 238 | { |
237 | *mReference = mBox->id(mBox->selected()); | 239 | *mReference = mBox->id(mBox->selected()); |
238 | } | 240 | } |
239 | 241 | ||
240 | 242 | ||
241 | KPrefsDialogWidString::KPrefsDialogWidString(const QString &text,QString *reference, | 243 | KPrefsDialogWidString::KPrefsDialogWidString(const QString &text,QString *reference, |
242 | QWidget *parent, QLineEdit::EchoMode echomode) | 244 | QWidget *parent, QLineEdit::EchoMode echomode) |
243 | { | 245 | { |
244 | mReference = reference; | 246 | mReference = reference; |
245 | 247 | ||
246 | mLabel = new QLabel(text,parent); | 248 | mLabel = new QLabel(text,parent); |
247 | mEdit = new QLineEdit(parent); | 249 | mEdit = new QLineEdit(parent); |
248 | mEdit->setEchoMode( echomode ); | 250 | mEdit->setEchoMode( echomode ); |
249 | } | 251 | } |
250 | 252 | ||
251 | KPrefsDialogWidString::~KPrefsDialogWidString() | 253 | KPrefsDialogWidString::~KPrefsDialogWidString() |
252 | { | 254 | { |
253 | } | 255 | } |
254 | 256 | ||
255 | void KPrefsDialogWidString::readConfig() | 257 | void KPrefsDialogWidString::readConfig() |
256 | { | 258 | { |
257 | mEdit->setText(*mReference); | 259 | mEdit->setText(*mReference); |
258 | } | 260 | } |
259 | 261 | ||
260 | void KPrefsDialogWidString::writeConfig() | 262 | void KPrefsDialogWidString::writeConfig() |
261 | { | 263 | { |
262 | *mReference = mEdit->text(); | 264 | *mReference = mEdit->text(); |
263 | } | 265 | } |
264 | 266 | ||
265 | QLabel *KPrefsDialogWidString::label() | 267 | QLabel *KPrefsDialogWidString::label() |
266 | { | 268 | { |
267 | return mLabel; | 269 | return mLabel; |
268 | } | 270 | } |
269 | 271 | ||
270 | QLineEdit *KPrefsDialogWidString::lineEdit() | 272 | QLineEdit *KPrefsDialogWidString::lineEdit() |
271 | { | 273 | { |
272 | return mEdit; | 274 | return mEdit; |
273 | } | 275 | } |
274 | 276 | ||
275 | 277 | ||
276 | KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) : | 278 | KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) : |
277 | KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent, | 279 | KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent, |
278 | name,modal,true) | 280 | name,modal,true) |
279 | { | 281 | { |
280 | mPrefs = prefs; | 282 | mPrefs = prefs; |
281 | 283 | ||
282 | // This seems to cause a crash on exit. Investigate later. | 284 | // This seems to cause a crash on exit. Investigate later. |
283 | mPrefsWids.setAutoDelete(true); | 285 | mPrefsWids.setAutoDelete(true); |
284 | 286 | ||
285 | connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault())); | 287 | connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault())); |
286 | //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault())); | 288 | //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault())); |
287 | //connect(this,SIGNAL(cancelClicked()),SLOT(reject())); | 289 | //connect(this,SIGNAL(cancelClicked()),SLOT(reject())); |
288 | } | 290 | } |
289 | 291 | ||
290 | KPrefsDialog::~KPrefsDialog() | 292 | KPrefsDialog::~KPrefsDialog() |
291 | { | 293 | { |
292 | } | 294 | } |
293 | 295 | ||
294 | void KPrefsDialog::addWid(KPrefsDialogWid *wid) | 296 | void KPrefsDialog::addWid(KPrefsDialogWid *wid) |
295 | { | 297 | { |
296 | mPrefsWids.append(wid); | 298 | mPrefsWids.append(wid); |
297 | } | 299 | } |
298 | 300 | ||
299 | KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent) | 301 | KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent) |
300 | { | 302 | { |
301 | KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent); | 303 | KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent); |
302 | addWid(w); | 304 | addWid(w); |
303 | return w; | 305 | return w; |
304 | } | 306 | } |
305 | 307 | ||
306 | KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent) | 308 | KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent) |
307 | { | 309 | { |
308 | KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent); | 310 | KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent); |
309 | addWid(w); | 311 | addWid(w); |
310 | return w; | 312 | return w; |
311 | } | 313 | } |
312 | 314 | ||
313 | KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent) | 315 | KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent) |
314 | { | 316 | { |
315 | KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent); | 317 | KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent); |
316 | addWid(w); | 318 | addWid(w); |
317 | return w; | 319 | return w; |
318 | } | 320 | } |
319 | 321 | ||
320 | KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent) | 322 | KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent) |
321 | { | 323 | { |
322 | KPrefsDialogWidRadios *w = new KPrefsDialogWidRadios(text,reference,parent); | 324 | KPrefsDialogWidRadios *w = new KPrefsDialogWidRadios(text,reference,parent); |
323 | addWid(w); | 325 | addWid(w); |
324 | return w; | 326 | return w; |
325 | } | 327 | } |
326 | 328 | ||
327 | KPrefsDialogWidString *KPrefsDialog::addWidString(const QString &text,QString *reference,QWidget *parent) | 329 | KPrefsDialogWidString *KPrefsDialog::addWidString(const QString &text,QString *reference,QWidget *parent) |
328 | { | 330 | { |
329 | KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent); | 331 | KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent); |
330 | addWid(w); | 332 | addWid(w); |
331 | return w; | 333 | return w; |
332 | } | 334 | } |
333 | 335 | ||
334 | KPrefsDialogWidString *KPrefsDialog::addWidPassword(const QString &text,QString *reference,QWidget *parent) | 336 | KPrefsDialogWidString *KPrefsDialog::addWidPassword(const QString &text,QString *reference,QWidget *parent) |
335 | { | 337 | { |
336 | KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent,QLineEdit::Password); | 338 | KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent,QLineEdit::Password); |
337 | addWid(w); | 339 | addWid(w); |
338 | return w; | 340 | return w; |
339 | } | 341 | } |
340 | 342 | ||
341 | KPrefsDialogWidFont *KPrefsDialog::addWidFont(const QString &sampleText,const QString &buttonText, | 343 | KPrefsDialogWidFont *KPrefsDialog::addWidFont(const QString &sampleText,const QString &buttonText, |
342 | QFont *reference,QWidget *parent) | 344 | QFont *reference,QWidget *parent) |
343 | { | 345 | { |
344 | KPrefsDialogWidFont *w = new KPrefsDialogWidFont(sampleText,buttonText,reference,parent); | 346 | KPrefsDialogWidFont *w = new KPrefsDialogWidFont(sampleText,buttonText,reference,parent); |
345 | addWid(w); | 347 | addWid(w); |
346 | return w; | 348 | return w; |
347 | } | 349 | } |
348 | 350 | ||
349 | void KPrefsDialog::setDefaults() | 351 | void KPrefsDialog::setDefaults() |
350 | { | 352 | { |
351 | mPrefs->setDefaults(); | 353 | mPrefs->setDefaults(); |
352 | 354 | ||
353 | readConfig(); | 355 | readConfig(); |
354 | } | 356 | } |
355 | 357 | ||
356 | void KPrefsDialog::readConfig() | 358 | void KPrefsDialog::readConfig() |
357 | { | 359 | { |
358 | // kdDebug(5300) << "KPrefsDialog::readConfig()" << endl; | 360 | // kdDebug(5300) << "KPrefsDialog::readConfig()" << endl; |
359 | 361 | ||
360 | KPrefsDialogWid *wid; | 362 | KPrefsDialogWid *wid; |
361 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { | 363 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { |
362 | wid->readConfig(); | 364 | wid->readConfig(); |
363 | } | 365 | } |
364 | 366 | ||
365 | usrReadConfig(); | 367 | usrReadConfig(); |
366 | } | 368 | } |
367 | 369 | ||
368 | void KPrefsDialog::writeConfig() | 370 | void KPrefsDialog::writeConfig() |
369 | { | 371 | { |
370 | // kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl; | 372 | // kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl; |
371 | 373 | ||
372 | KPrefsDialogWid *wid; | 374 | KPrefsDialogWid *wid; |
373 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { | 375 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { |
374 | wid->writeConfig(); | 376 | wid->writeConfig(); |
375 | } | 377 | } |
376 | 378 | ||
377 | usrWriteConfig(); | 379 | usrWriteConfig(); |
378 | 380 | ||
379 | // kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl; | 381 | // kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl; |
380 | 382 | ||
381 | mPrefs->writeConfig(); | 383 | mPrefs->writeConfig(); |
382 | 384 | ||
383 | // kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl; | 385 | // kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl; |
384 | } | 386 | } |
385 | 387 | ||
386 | 388 | ||
387 | void KPrefsDialog::slotApply() | 389 | void KPrefsDialog::slotApply() |
388 | { | 390 | { |
389 | writeConfig(); | 391 | writeConfig(); |
390 | emit configChanged(); | 392 | emit configChanged(); |
391 | } | 393 | } |
392 | 394 | ||
393 | void KPrefsDialog::slotOk() | 395 | void KPrefsDialog::slotOk() |
394 | { | 396 | { |
395 | slotApply(); | 397 | slotApply(); |
396 | QDialog::accept(); | 398 | QDialog::accept(); |
397 | } | 399 | } |
398 | void KPrefsDialog::accept() | 400 | void KPrefsDialog::accept() |
399 | { | 401 | { |
400 | slotOk(); | 402 | slotOk(); |
401 | } | 403 | } |
402 | 404 | ||
403 | void KPrefsDialog::slotDefault() | 405 | void KPrefsDialog::slotDefault() |
404 | { | 406 | { |
405 | if (KMessageBox::warningContinueCancel(this, | 407 | if (KMessageBox::warningContinueCancel(this, |
406 | i18n("You are about to set all\npreferences to default values.\nAll " | 408 | i18n("You are about to set all\npreferences to default values.\nAll " |
407 | "custom modifications will be lost."),i18n("Setting Default Preferences"), | 409 | "custom modifications will be lost."),i18n("Setting Default Preferences"), |
408 | i18n("Continue")) | 410 | i18n("Continue")) |
409 | == KMessageBox::Continue) setDefaults(); | 411 | == KMessageBox::Continue) setDefaults(); |
410 | } | 412 | } |
413 | |||
414 | KPimPrefsGlobalDialog::KPimPrefsGlobalDialog(QWidget *parent,char *name,bool modal): KPrefsDialog( KPimGlobalPrefs::instance() ,parent, name, modal ) | ||
415 | { | ||
416 | setFont( KGlobalSettings::generalMaxFont() ); | ||
417 | kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), this, "KPrefsGlobalDialog" ); | ||
418 | setMainWidget( kdelibcfg ); | ||
419 | setCaption( i18n("KDE-Pim Global Settings")); | ||
420 | kdelibcfg->readConfig(); | ||
421 | #ifndef DESKTOP_VERSION | ||
422 | if ( QApplication::desktop()->height() <= 480 ) | ||
423 | hideButtons(); | ||
424 | showMaximized(); | ||
425 | #endif | ||
426 | } | ||
427 | void KPimPrefsGlobalDialog::showTZconfig() | ||
428 | { | ||
429 | kdelibcfg->showTimeZoneTab() ; | ||
430 | } | ||
431 | void KPimPrefsGlobalDialog::usrReadConfig() | ||
432 | { | ||
433 | kdelibcfg->readConfig(); | ||
434 | } | ||
435 | |||
436 | void KPimPrefsGlobalDialog::usrWriteConfig() | ||
437 | { | ||
438 | kdelibcfg->writeConfig(); | ||
439 | } | ||
440 | |||
diff --git a/libkdepim/kprefsdialog.h b/libkdepim/kprefsdialog.h index efcb86a..52ec809 100644 --- a/libkdepim/kprefsdialog.h +++ b/libkdepim/kprefsdialog.h | |||
@@ -1,445 +1,471 @@ | |||
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 program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KPREFSDIALOG_H | 23 | #ifndef _KPREFSDIALOG_H |
24 | #define _KPREFSDIALOG_H | 24 | #define _KPREFSDIALOG_H |
25 | // $Id$ | 25 | // $Id$ |
26 | 26 | ||
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | 29 | ||
30 | #include <kdialogbase.h> | 30 | #include <kdialogbase.h> |
31 | 31 | ||
32 | class KPrefs; | 32 | class KPrefs; |
33 | class KPrefsDialog; | 33 | class KPrefsDialog; |
34 | 34 | ||
35 | class KColorButton; | 35 | class KColorButton; |
36 | class QCheckBox; | 36 | class QCheckBox; |
37 | class QLabel; | 37 | class QLabel; |
38 | class QSpinBox; | 38 | class QSpinBox; |
39 | class QButtonGroup; | 39 | class QButtonGroup; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | @short Base class for widgets used by @ref KPrefsDialog. | 42 | @short Base class for widgets used by @ref KPrefsDialog. |
43 | @author Cornelius Schumacher | 43 | @author Cornelius Schumacher |
44 | @see KPrefsDialog | 44 | @see KPrefsDialog |
45 | 45 | ||
46 | This class provides the interface for the preferences widgets used by | 46 | This class provides the interface for the preferences widgets used by |
47 | KPrefsDialog. | 47 | KPrefsDialog. |
48 | */ | 48 | */ |
49 | class KPrefsDialogWid : public QObject | 49 | class KPrefsDialogWid : public QObject |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | /** | 52 | /** |
53 | This function is called to read value of the setting from the | 53 | This function is called to read value of the setting from the |
54 | stored configuration and display it in the widget. | 54 | stored configuration and display it in the widget. |
55 | */ | 55 | */ |
56 | virtual void readConfig() = 0; | 56 | virtual void readConfig() = 0; |
57 | /** | 57 | /** |
58 | This function is called to write the current setting of the widget to the | 58 | This function is called to write the current setting of the widget to the |
59 | stored configuration. | 59 | stored configuration. |
60 | */ | 60 | */ |
61 | virtual void writeConfig() = 0; | 61 | virtual void writeConfig() = 0; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | /** | 64 | /** |
65 | @short Widget for bool settings in @ref KPrefsDialog. | 65 | @short Widget for bool settings in @ref KPrefsDialog. |
66 | 66 | ||
67 | This class provides a widget for configuring bool values. It is meant to be | 67 | This class provides a widget for configuring bool values. It is meant to be |
68 | used by KPrefsDialog. The user is responsible for the layout management. | 68 | used by KPrefsDialog. The user is responsible for the layout management. |
69 | */ | 69 | */ |
70 | class KPrefsDialogWidBool : public KPrefsDialogWid | 70 | class KPrefsDialogWidBool : public KPrefsDialogWid |
71 | { | 71 | { |
72 | public: | 72 | public: |
73 | /** | 73 | /** |
74 | Create a bool widget consisting of a QCheckbox. | 74 | Create a bool widget consisting of a QCheckbox. |
75 | 75 | ||
76 | @param text Text of QCheckBox. | 76 | @param text Text of QCheckBox. |
77 | @param reference Pointer to variable read and written by this widget. | 77 | @param reference Pointer to variable read and written by this widget. |
78 | @param parent Parent widget. | 78 | @param parent Parent widget. |
79 | */ | 79 | */ |
80 | KPrefsDialogWidBool(const QString &text,bool *reference,QWidget *parent); | 80 | KPrefsDialogWidBool(const QString &text,bool *reference,QWidget *parent); |
81 | 81 | ||
82 | /** | 82 | /** |
83 | Return the QCheckbox used by this widget. | 83 | Return the QCheckbox used by this widget. |
84 | */ | 84 | */ |
85 | QCheckBox *checkBox(); | 85 | QCheckBox *checkBox(); |
86 | 86 | ||
87 | void readConfig(); | 87 | void readConfig(); |
88 | void writeConfig(); | 88 | void writeConfig(); |
89 | 89 | ||
90 | private: | 90 | private: |
91 | bool *mReference; | 91 | bool *mReference; |
92 | 92 | ||
93 | QCheckBox *mCheck; | 93 | QCheckBox *mCheck; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | @short Widget for time settings in @ref KPrefsDialog. | 97 | @short Widget for time settings in @ref KPrefsDialog. |
98 | 98 | ||
99 | This class provides a widget for configuring time values. It is meant to be | 99 | This class provides a widget for configuring time values. It is meant to be |
100 | used by KPrefsDialog. The user is responsible for the layout management. | 100 | used by KPrefsDialog. The user is responsible for the layout management. |
101 | */ | 101 | */ |
102 | class KPrefsDialogWidTime : public KPrefsDialogWid | 102 | class KPrefsDialogWidTime : public KPrefsDialogWid |
103 | { | 103 | { |
104 | public: | 104 | public: |
105 | /** | 105 | /** |
106 | Create a time widget consisting of a label and a spinbox. | 106 | Create a time widget consisting of a label and a spinbox. |
107 | 107 | ||
108 | @param text Text of Label. | 108 | @param text Text of Label. |
109 | @param reference Pointer to variable read and written by this widget. | 109 | @param reference Pointer to variable read and written by this widget. |
110 | @param parent Parent widget. | 110 | @param parent Parent widget. |
111 | */ | 111 | */ |
112 | KPrefsDialogWidTime(const QString &text,int *reference,QWidget *parent); | 112 | KPrefsDialogWidTime(const QString &text,int *reference,QWidget *parent); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | Return QLabel used by this widget. | 115 | Return QLabel used by this widget. |
116 | */ | 116 | */ |
117 | QLabel *label(); | 117 | QLabel *label(); |
118 | /** | 118 | /** |
119 | Return QSpinBox used by this widget. | 119 | Return QSpinBox used by this widget. |
120 | */ | 120 | */ |
121 | QSpinBox *spinBox(); | 121 | QSpinBox *spinBox(); |
122 | 122 | ||
123 | void readConfig(); | 123 | void readConfig(); |
124 | void writeConfig(); | 124 | void writeConfig(); |
125 | 125 | ||
126 | private: | 126 | private: |
127 | int *mReference; | 127 | int *mReference; |
128 | 128 | ||
129 | QLabel *mLabel; | 129 | QLabel *mLabel; |
130 | QSpinBox *mSpin; | 130 | QSpinBox *mSpin; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | /** | 133 | /** |
134 | @short Widget for color settings in @ref KPrefsDialog. | 134 | @short Widget for color settings in @ref KPrefsDialog. |
135 | 135 | ||
136 | This class provides a widget for configuring color values. It is meant to be | 136 | This class provides a widget for configuring color values. It is meant to be |
137 | used by KPrefsDialog. The user is responsible for the layout management. | 137 | used by KPrefsDialog. The user is responsible for the layout management. |
138 | */ | 138 | */ |
139 | class KPrefsDialogWidColor : public KPrefsDialogWid | 139 | class KPrefsDialogWidColor : public KPrefsDialogWid |
140 | { | 140 | { |
141 | public: | 141 | public: |
142 | /** | 142 | /** |
143 | Create a color widget consisting of a test field and a button for opening | 143 | Create a color widget consisting of a test field and a button for opening |
144 | a color dialog. | 144 | a color dialog. |
145 | 145 | ||
146 | @param text Text of button. | 146 | @param text Text of button. |
147 | @param reference Pointer to variable read and written by this widget. | 147 | @param reference Pointer to variable read and written by this widget. |
148 | @param parent Parent widget. | 148 | @param parent Parent widget. |
149 | */ | 149 | */ |
150 | KPrefsDialogWidColor(const QString &text,QColor *reference,QWidget *parent); | 150 | KPrefsDialogWidColor(const QString &text,QColor *reference,QWidget *parent); |
151 | /** | 151 | /** |
152 | Destruct color setting widget. | 152 | Destruct color setting widget. |
153 | */ | 153 | */ |
154 | ~KPrefsDialogWidColor(); | 154 | ~KPrefsDialogWidColor(); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Return QLabel for the button | 157 | Return QLabel for the button |
158 | */ | 158 | */ |
159 | QLabel *label(); | 159 | QLabel *label(); |
160 | /** | 160 | /** |
161 | Return button opening the color dialog. | 161 | Return button opening the color dialog. |
162 | */ | 162 | */ |
163 | KColorButton *button(); | 163 | KColorButton *button(); |
164 | 164 | ||
165 | void readConfig(); | 165 | void readConfig(); |
166 | void writeConfig(); | 166 | void writeConfig(); |
167 | 167 | ||
168 | private: | 168 | private: |
169 | QColor *mReference; | 169 | QColor *mReference; |
170 | 170 | ||
171 | QLabel *mLabel; | 171 | QLabel *mLabel; |
172 | KColorButton *mButton; | 172 | KColorButton *mButton; |
173 | }; | 173 | }; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | @short Widget for font settings in @ref KPrefsDialog. | 176 | @short Widget for font settings in @ref KPrefsDialog. |
177 | 177 | ||
178 | This class provides a widget for configuring font values. It is meant to be | 178 | This class provides a widget for configuring font values. It is meant to be |
179 | used by KPrefsDialog. The user is responsible for the layout management. | 179 | used by KPrefsDialog. The user is responsible for the layout management. |
180 | */ | 180 | */ |
181 | class KPrefsDialogWidFont : public KPrefsDialogWid | 181 | class KPrefsDialogWidFont : public KPrefsDialogWid |
182 | { | 182 | { |
183 | Q_OBJECT | 183 | Q_OBJECT |
184 | public: | 184 | public: |
185 | /** | 185 | /** |
186 | Create a font widget consisting of a test field and a button for opening | 186 | Create a font widget consisting of a test field and a button for opening |
187 | a font dialog. | 187 | a font dialog. |
188 | 188 | ||
189 | @param label Text of label. | 189 | @param label Text of label. |
190 | @param reference Pointer to variable read and written by this widget. | 190 | @param reference Pointer to variable read and written by this widget. |
191 | @param parent Parent widget. | 191 | @param parent Parent widget. |
192 | */ | 192 | */ |
193 | KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, | 193 | KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, |
194 | QFont *reference,QWidget *parent); | 194 | QFont *reference,QWidget *parent); |
195 | /** | 195 | /** |
196 | Destruct font setting widget. | 196 | Destruct font setting widget. |
197 | */ | 197 | */ |
198 | ~KPrefsDialogWidFont(); | 198 | ~KPrefsDialogWidFont(); |
199 | 199 | ||
200 | /** | 200 | /** |
201 | Return label. | 201 | Return label. |
202 | */ | 202 | */ |
203 | QLabel *label(); | 203 | QLabel *label(); |
204 | /** | 204 | /** |
205 | Return QFrame used as preview field. | 205 | Return QFrame used as preview field. |
206 | */ | 206 | */ |
207 | QLabel *preview(); | 207 | QLabel *preview(); |
208 | /** | 208 | /** |
209 | Return button opening the font dialog. | 209 | Return button opening the font dialog. |
210 | */ | 210 | */ |
211 | QPushButton *button(); | 211 | QPushButton *button(); |
212 | 212 | ||
213 | void readConfig(); | 213 | void readConfig(); |
214 | void writeConfig(); | 214 | void writeConfig(); |
215 | 215 | ||
216 | protected slots: | 216 | protected slots: |
217 | void selectFont(); | 217 | void selectFont(); |
218 | 218 | ||
219 | private: | 219 | private: |
220 | QFont *mReference; | 220 | QFont *mReference; |
221 | 221 | ||
222 | QLabel *mLabel; | 222 | QLabel *mLabel; |
223 | QLabel *mPreview; | 223 | QLabel *mPreview; |
224 | QPushButton *mButton; | 224 | QPushButton *mButton; |
225 | }; | 225 | }; |
226 | 226 | ||
227 | /** | 227 | /** |
228 | @short Widget for settings represented by a group of radio buttons in | 228 | @short Widget for settings represented by a group of radio buttons in |
229 | @ref KPrefsDialog. | 229 | @ref KPrefsDialog. |
230 | 230 | ||
231 | This class provides a widget for configuring selections. It is meant to be | 231 | This class provides a widget for configuring selections. It is meant to be |
232 | used by KPrefsDialog. The user is responsible for the layout management. The | 232 | used by KPrefsDialog. The user is responsible for the layout management. The |
233 | setting is interpreted as an int value, corresponding to the position of the | 233 | setting is interpreted as an int value, corresponding to the position of the |
234 | radio button. The position of the button is defined by the sequence of @ref | 234 | radio button. The position of the button is defined by the sequence of @ref |
235 | addRadio() calls, starting with 0. | 235 | addRadio() calls, starting with 0. |
236 | */ | 236 | */ |
237 | class KPrefsDialogWidRadios : public KPrefsDialogWid | 237 | class KPrefsDialogWidRadios : public KPrefsDialogWid |
238 | { | 238 | { |
239 | public: | 239 | public: |
240 | /** | 240 | /** |
241 | Create a widget for selection of an option. It consists of a box with | 241 | Create a widget for selection of an option. It consists of a box with |
242 | several radio buttons. | 242 | several radio buttons. |
243 | 243 | ||
244 | @param text Text of main box. | 244 | @param text Text of main box. |
245 | @param reference Pointer to variable read and written by this widget. | 245 | @param reference Pointer to variable read and written by this widget. |
246 | @param parent Parent widget. | 246 | @param parent Parent widget. |
247 | */ | 247 | */ |
248 | KPrefsDialogWidRadios(const QString &text,int *reference,QWidget *parent); | 248 | KPrefsDialogWidRadios(const QString &text,int *reference,QWidget *parent); |
249 | virtual ~KPrefsDialogWidRadios(); | 249 | virtual ~KPrefsDialogWidRadios(); |
250 | 250 | ||
251 | /** | 251 | /** |
252 | Add a radio button. | 252 | Add a radio button. |
253 | 253 | ||
254 | @param text Text of the button. | 254 | @param text Text of the button. |
255 | */ | 255 | */ |
256 | void addRadio(const QString &text); | 256 | void addRadio(const QString &text); |
257 | 257 | ||
258 | /** | 258 | /** |
259 | Return the box widget used by this widget. | 259 | Return the box widget used by this widget. |
260 | */ | 260 | */ |
261 | QButtonGroup *groupBox(); | 261 | QButtonGroup *groupBox(); |
262 | 262 | ||
263 | void readConfig(); | 263 | void readConfig(); |
264 | void writeConfig(); | 264 | void writeConfig(); |
265 | 265 | ||
266 | private: | 266 | private: |
267 | int *mReference; | 267 | int *mReference; |
268 | 268 | ||
269 | QButtonGroup *mBox; | 269 | QButtonGroup *mBox; |
270 | }; | 270 | }; |
271 | 271 | ||
272 | 272 | ||
273 | /** | 273 | /** |
274 | @short Widget for string settings in @ref KPrefsDialog. | 274 | @short Widget for string settings in @ref KPrefsDialog. |
275 | 275 | ||
276 | This class provides a widget for configuring string values. It is meant to be | 276 | This class provides a widget for configuring string values. It is meant to be |
277 | used by KPrefsDialog. The user is responsible for the layout management. | 277 | used by KPrefsDialog. The user is responsible for the layout management. |
278 | */ | 278 | */ |
279 | class KPrefsDialogWidString : public KPrefsDialogWid | 279 | class KPrefsDialogWidString : public KPrefsDialogWid |
280 | { | 280 | { |
281 | public: | 281 | public: |
282 | /** | 282 | /** |
283 | Create a string widget consisting of a test label and a line edit. | 283 | Create a string widget consisting of a test label and a line edit. |
284 | 284 | ||
285 | @param text Text of label. | 285 | @param text Text of label. |
286 | @param reference Pointer to variable read and written by this widget. | 286 | @param reference Pointer to variable read and written by this widget. |
287 | @param parent Parent widget. | 287 | @param parent Parent widget. |
288 | */ | 288 | */ |
289 | KPrefsDialogWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); | 289 | KPrefsDialogWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); |
290 | /** | 290 | /** |
291 | Destructor. | 291 | Destructor. |
292 | */ | 292 | */ |
293 | virtual ~KPrefsDialogWidString(); | 293 | virtual ~KPrefsDialogWidString(); |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Return label used by this widget. | 296 | Return label used by this widget. |
297 | */ | 297 | */ |
298 | QLabel *label(); | 298 | QLabel *label(); |
299 | /** | 299 | /** |
300 | Return QLineEdit used by this widget. | 300 | Return QLineEdit used by this widget. |
301 | */ | 301 | */ |
302 | QLineEdit *lineEdit(); | 302 | QLineEdit *lineEdit(); |
303 | 303 | ||
304 | void readConfig(); | 304 | void readConfig(); |
305 | void writeConfig(); | 305 | void writeConfig(); |
306 | 306 | ||
307 | private: | 307 | private: |
308 | QString *mReference; | 308 | QString *mReference; |
309 | 309 | ||
310 | QLabel *mLabel; | 310 | QLabel *mLabel; |
311 | QLineEdit *mEdit; | 311 | QLineEdit *mEdit; |
312 | }; | 312 | }; |
313 | 313 | ||
314 | 314 | ||
315 | /** | 315 | /** |
316 | @short Base class for a preferences dialog. | 316 | @short Base class for a preferences dialog. |
317 | 317 | ||
318 | This class provides the framework for a preferences dialog. You have to | 318 | This class provides the framework for a preferences dialog. You have to |
319 | subclass it and add the code to create the actual configuration widgets and | 319 | subclass it and add the code to create the actual configuration widgets and |
320 | do the layout management. | 320 | do the layout management. |
321 | 321 | ||
322 | KPrefsDialog provides functions to add subclasses of @ref KPrefsDialogWid. For | 322 | KPrefsDialog provides functions to add subclasses of @ref KPrefsDialogWid. For |
323 | these widgets the reading, writing and setting to default values is handled | 323 | these widgets the reading, writing and setting to default values is handled |
324 | automatically. Custom widgets have to be handled in the functions @ref | 324 | automatically. Custom widgets have to be handled in the functions @ref |
325 | usrReadConfig() and @ref usrWriteConfig(). | 325 | usrReadConfig() and @ref usrWriteConfig(). |
326 | */ | 326 | */ |
327 | class KPrefsDialog : public KDialogBase | 327 | class KPrefsDialog : public KDialogBase |
328 | { | 328 | { |
329 | Q_OBJECT | 329 | Q_OBJECT |
330 | public: | 330 | public: |
331 | /** | 331 | /** |
332 | Create a KPrefsDialog for a KPrefs object. | 332 | Create a KPrefsDialog for a KPrefs object. |
333 | 333 | ||
334 | @param prefs KPrefs object used to access te configuration. | 334 | @param prefs KPrefs object used to access te configuration. |
335 | @param parent Parent widget. | 335 | @param parent Parent widget. |
336 | @param name Widget name. | 336 | @param name Widget name. |
337 | @param modal true, if dialog has to be modal, false for non-modal. | 337 | @param modal true, if dialog has to be modal, false for non-modal. |
338 | */ | 338 | */ |
339 | KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false); | 339 | KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false); |
340 | /** | 340 | /** |
341 | Destructor. | 341 | Destructor. |
342 | */ | 342 | */ |
343 | virtual ~KPrefsDialog(); | 343 | virtual ~KPrefsDialog(); |
344 | 344 | ||
345 | /** | 345 | /** |
346 | Register a custom KPrefsDialogWid object. | 346 | Register a custom KPrefsDialogWid object. |
347 | */ | 347 | */ |
348 | void addWid(KPrefsDialogWid *); | 348 | void addWid(KPrefsDialogWid *); |
349 | /** | 349 | /** |
350 | Register a @ref KPrefsDialogWidBool object. | 350 | Register a @ref KPrefsDialogWidBool object. |
351 | 351 | ||
352 | @param text Text of bool widget. | 352 | @param text Text of bool widget. |
353 | @param reference Reference to variable storing the setting. | 353 | @param reference Reference to variable storing the setting. |
354 | @param parent Parent widget. | 354 | @param parent Parent widget. |
355 | */ | 355 | */ |
356 | KPrefsDialogWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); | 356 | KPrefsDialogWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); |
357 | /** | 357 | /** |
358 | Register a @ref KPrefsDialogWidTime object. | 358 | Register a @ref KPrefsDialogWidTime object. |
359 | 359 | ||
360 | @param text Text of time widget. | 360 | @param text Text of time widget. |
361 | @param reference Reference to variable storing the setting. | 361 | @param reference Reference to variable storing the setting. |
362 | @param parent Parent widget. | 362 | @param parent Parent widget. |
363 | */ | 363 | */ |
364 | KPrefsDialogWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); | 364 | KPrefsDialogWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); |
365 | /** | 365 | /** |
366 | Register a @ref KPrefsDialogWidColor object. | 366 | Register a @ref KPrefsDialogWidColor object. |
367 | 367 | ||
368 | @param text Text of color widget. | 368 | @param text Text of color widget. |
369 | @param reference Reference to variable storing the setting. | 369 | @param reference Reference to variable storing the setting. |
370 | @param parent Parent widget. | 370 | @param parent Parent widget. |
371 | */ | 371 | */ |
372 | KPrefsDialogWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); | 372 | KPrefsDialogWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); |
373 | /** | 373 | /** |
374 | Register a @ref KPrefsDialogWidRadios object. | 374 | Register a @ref KPrefsDialogWidRadios object. |
375 | 375 | ||
376 | @param text Text of radio button box widget. | 376 | @param text Text of radio button box widget. |
377 | @param reference Reference to variable storing the setting. | 377 | @param reference Reference to variable storing the setting. |
378 | @param parent Parent widget. | 378 | @param parent Parent widget. |
379 | */ | 379 | */ |
380 | KPrefsDialogWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); | 380 | KPrefsDialogWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); |
381 | /** | 381 | /** |
382 | Register a @ref KPrefsDialogWidString object. | 382 | Register a @ref KPrefsDialogWidString object. |
383 | 383 | ||
384 | @param text Text of string widget. | 384 | @param text Text of string widget. |
385 | @param reference Reference to variable storing the setting. | 385 | @param reference Reference to variable storing the setting. |
386 | @param parent Parent widget. | 386 | @param parent Parent widget. |
387 | */ | 387 | */ |
388 | KPrefsDialogWidString *addWidString(const QString &text,QString *reference,QWidget *parent); | 388 | KPrefsDialogWidString *addWidString(const QString &text,QString *reference,QWidget *parent); |
389 | /** | 389 | /** |
390 | Register a password @ref KPrefsDialogWidString object, with echomode set to QLineEdit::Password. | 390 | Register a password @ref KPrefsDialogWidString object, with echomode set to QLineEdit::Password. |
391 | 391 | ||
392 | @param text Text of string widget. | 392 | @param text Text of string widget. |
393 | @param reference Reference to variable storing the setting. | 393 | @param reference Reference to variable storing the setting. |
394 | @param parent Parent widget. | 394 | @param parent Parent widget. |
395 | */ | 395 | */ |
396 | KPrefsDialogWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); | 396 | KPrefsDialogWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); |
397 | /** | 397 | /** |
398 | Register a @ref KPrefsDialogWidFont object. | 398 | Register a @ref KPrefsDialogWidFont object. |
399 | 399 | ||
400 | @param sampleText Sample text of font widget. | 400 | @param sampleText Sample text of font widget. |
401 | @param buttonText Button text of font widget. | 401 | @param buttonText Button text of font widget. |
402 | @param reference Reference to variable storing the setting. | 402 | @param reference Reference to variable storing the setting. |
403 | @param parent Parent widget. | 403 | @param parent Parent widget. |
404 | */ | 404 | */ |
405 | KPrefsDialogWidFont *addWidFont(const QString &sampleText,const QString &buttonText, | 405 | KPrefsDialogWidFont *addWidFont(const QString &sampleText,const QString &buttonText, |
406 | QFont *reference,QWidget *parent); | 406 | QFont *reference,QWidget *parent); |
407 | 407 | ||
408 | public slots: | 408 | public slots: |
409 | /** Set all widgets to default values. */ | 409 | /** Set all widgets to default values. */ |
410 | void setDefaults(); | 410 | void setDefaults(); |
411 | 411 | ||
412 | /** Read preferences from config file. */ | 412 | /** Read preferences from config file. */ |
413 | void readConfig(); | 413 | void readConfig(); |
414 | 414 | ||
415 | /** Write preferences to config file. */ | 415 | /** Write preferences to config file. */ |
416 | void writeConfig(); | 416 | void writeConfig(); |
417 | 417 | ||
418 | signals: | 418 | signals: |
419 | /** Emitted when the a changed configuration has been stored. */ | 419 | /** Emitted when the a changed configuration has been stored. */ |
420 | void configChanged(); | 420 | void configChanged(); |
421 | 421 | ||
422 | protected slots: | 422 | protected slots: |
423 | /** Apply changes to preferences */ | 423 | /** Apply changes to preferences */ |
424 | void slotApply(); | 424 | void slotApply(); |
425 | 425 | ||
426 | void accept(); | 426 | void accept(); |
427 | /** Accept changes to preferences and close dialog */ | 427 | /** Accept changes to preferences and close dialog */ |
428 | void slotOk(); | 428 | void slotOk(); |
429 | 429 | ||
430 | /** Set preferences to default values */ | 430 | /** Set preferences to default values */ |
431 | void slotDefault(); | 431 | void slotDefault(); |
432 | 432 | ||
433 | protected: | 433 | protected: |
434 | /** Implement this to read custom configuration widgets. */ | 434 | /** Implement this to read custom configuration widgets. */ |
435 | virtual void usrReadConfig() {} | 435 | virtual void usrReadConfig() {} |
436 | /** Implement this to write custom configuration widgets. */ | 436 | /** Implement this to write custom configuration widgets. */ |
437 | virtual void usrWriteConfig() {} | 437 | virtual void usrWriteConfig() {} |
438 | 438 | ||
439 | private: | 439 | private: |
440 | KPrefs *mPrefs; | 440 | KPrefs *mPrefs; |
441 | 441 | ||
442 | QPtrList<KPrefsDialogWid> mPrefsWids; | 442 | QPtrList<KPrefsDialogWid> mPrefsWids; |
443 | }; | 443 | }; |
444 | 444 | ||
445 | |||
446 | #include "kcmconfigs/kdepimconfigwidget.h" | ||
447 | class KPimPrefsGlobalDialog : public KPrefsDialog | ||
448 | { | ||
449 | Q_OBJECT | ||
450 | public: | ||
451 | KPimPrefsGlobalDialog(QWidget *parent=0,char *name=0,bool modal=true); | ||
452 | /** | ||
453 | Destructor. | ||
454 | */ | ||
455 | void showTZconfig(); | ||
456 | |||
457 | public slots: | ||
458 | |||
459 | signals: | ||
460 | protected slots: | ||
461 | |||
462 | protected: | ||
463 | void usrReadConfig(); | ||
464 | virtual void usrWriteConfig() ; | ||
465 | |||
466 | private: | ||
467 | KDEPIMConfigWidget* kdelibcfg; | ||
468 | |||
469 | }; | ||
470 | |||
445 | #endif | 471 | #endif |