-rw-r--r-- | libkdepim/kprefswidget.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libkdepim/kprefswidget.cpp b/libkdepim/kprefswidget.cpp index be9ad30..f6a0b38 100644 --- a/libkdepim/kprefswidget.cpp +++ b/libkdepim/kprefswidget.cpp | |||
@@ -99,329 +99,330 @@ KPrefsWidColor::KPrefsWidColor(const QString &text,QColor *reference, | |||
99 | } | 99 | } |
100 | 100 | ||
101 | KPrefsWidColor::~KPrefsWidColor() | 101 | KPrefsWidColor::~KPrefsWidColor() |
102 | { | 102 | { |
103 | // kdDebug(5300) << "KPrefsWidColor::~KPrefsWidColor()" << endl; | 103 | // kdDebug(5300) << "KPrefsWidColor::~KPrefsWidColor()" << endl; |
104 | } | 104 | } |
105 | 105 | ||
106 | void KPrefsWidColor::readConfig() | 106 | void KPrefsWidColor::readConfig() |
107 | { | 107 | { |
108 | mButton->setColor(*mReference); | 108 | mButton->setColor(*mReference); |
109 | } | 109 | } |
110 | 110 | ||
111 | void KPrefsWidColor::writeConfig() | 111 | void KPrefsWidColor::writeConfig() |
112 | { | 112 | { |
113 | *mReference = mButton->color(); | 113 | *mReference = mButton->color(); |
114 | } | 114 | } |
115 | 115 | ||
116 | QLabel *KPrefsWidColor::label() | 116 | QLabel *KPrefsWidColor::label() |
117 | { | 117 | { |
118 | return mLabel; | 118 | return mLabel; |
119 | } | 119 | } |
120 | 120 | ||
121 | KColorButton *KPrefsWidColor::button() | 121 | KColorButton *KPrefsWidColor::button() |
122 | { | 122 | { |
123 | return mButton; | 123 | return mButton; |
124 | } | 124 | } |
125 | 125 | ||
126 | KPrefsWidFont::KPrefsWidFont(const QString &sampleText,const QString &labelText, | 126 | KPrefsWidFont::KPrefsWidFont(const QString &sampleText,const QString &labelText, |
127 | QFont *reference,QWidget *parent) | 127 | QFont *reference,QWidget *parent) |
128 | { | 128 | { |
129 | mReference = reference; | 129 | mReference = reference; |
130 | 130 | ||
131 | mLabel = new QLabel(labelText, parent); | 131 | mLabel = new QLabel(labelText, parent); |
132 | 132 | ||
133 | mPreview = new QLabel(sampleText,parent); | 133 | mPreview = new QLabel(sampleText,parent); |
134 | mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 134 | mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
135 | 135 | ||
136 | mButton = new QPushButton(i18n("Choose..."), parent); | 136 | mButton = new QPushButton(i18n("Choose..."), parent); |
137 | connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); | 137 | connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); |
138 | mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); | 138 | mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); |
139 | mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); | 139 | mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); |
140 | } | 140 | } |
141 | 141 | ||
142 | KPrefsWidFont::~KPrefsWidFont() | 142 | KPrefsWidFont::~KPrefsWidFont() |
143 | { | 143 | { |
144 | } | 144 | } |
145 | 145 | ||
146 | void KPrefsWidFont::readConfig() | 146 | void KPrefsWidFont::readConfig() |
147 | { | 147 | { |
148 | mPreview->setFont(*mReference); | 148 | mPreview->setFont(*mReference); |
149 | } | 149 | } |
150 | 150 | ||
151 | void KPrefsWidFont::writeConfig() | 151 | void KPrefsWidFont::writeConfig() |
152 | { | 152 | { |
153 | *mReference = mPreview->font(); | 153 | *mReference = mPreview->font(); |
154 | } | 154 | } |
155 | 155 | ||
156 | QLabel *KPrefsWidFont::label() | 156 | QLabel *KPrefsWidFont::label() |
157 | { | 157 | { |
158 | return mLabel; | 158 | return mLabel; |
159 | } | 159 | } |
160 | 160 | ||
161 | QLabel *KPrefsWidFont::preview() | 161 | QLabel *KPrefsWidFont::preview() |
162 | { | 162 | { |
163 | return mPreview; | 163 | return mPreview; |
164 | } | 164 | } |
165 | 165 | ||
166 | QPushButton *KPrefsWidFont::button() | 166 | QPushButton *KPrefsWidFont::button() |
167 | { | 167 | { |
168 | return mButton; | 168 | return mButton; |
169 | } | 169 | } |
170 | 170 | ||
171 | void KPrefsWidFont::selectFont() | 171 | void KPrefsWidFont::selectFont() |
172 | { | 172 | { |
173 | QFont myFont(mPreview->font()); | 173 | QFont myFont(mPreview->font()); |
174 | bool ok; | 174 | bool ok; |
175 | myFont = KFontDialog::getFont(myFont, ok); | 175 | myFont = KFontDialog::getFont(myFont, ok); |
176 | if ( ok ) { | 176 | if ( ok ) { |
177 | mPreview->setFont(myFont); | 177 | mPreview->setFont(myFont); |
178 | emit modified(); | 178 | emit modified(); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | KPrefsWidTime::KPrefsWidTime(const QString &text,int *reference, | 183 | KPrefsWidTime::KPrefsWidTime(const QString &text,int *reference, |
184 | QWidget *parent) | 184 | QWidget *parent) |
185 | { | 185 | { |
186 | mReference = reference; | 186 | mReference = reference; |
187 | 187 | ||
188 | mLabel = new QLabel(text,parent); | 188 | mLabel = new QLabel(text,parent); |
189 | mSpin = new QSpinBox(0,23,1,parent); | 189 | mSpin = new QSpinBox(0,23,1,parent); |
190 | mSpin->setSuffix(":00"); | 190 | mSpin->setSuffix(":00"); |
191 | connect( mSpin, SIGNAL( valueChanged(int)), SIGNAL( modified() ) ); | 191 | connect( mSpin, SIGNAL( valueChanged(int)), SIGNAL( modified() ) ); |
192 | 192 | ||
193 | } | 193 | } |
194 | 194 | ||
195 | void KPrefsWidTime::readConfig() | 195 | void KPrefsWidTime::readConfig() |
196 | { | 196 | { |
197 | mSpin->setValue(*mReference); | 197 | mSpin->setValue(*mReference); |
198 | } | 198 | } |
199 | 199 | ||
200 | void KPrefsWidTime::writeConfig() | 200 | void KPrefsWidTime::writeConfig() |
201 | { | 201 | { |
202 | *mReference = mSpin->value(); | 202 | *mReference = mSpin->value(); |
203 | } | 203 | } |
204 | 204 | ||
205 | QLabel *KPrefsWidTime::label() | 205 | QLabel *KPrefsWidTime::label() |
206 | { | 206 | { |
207 | return mLabel; | 207 | return mLabel; |
208 | } | 208 | } |
209 | 209 | ||
210 | QSpinBox *KPrefsWidTime::spinBox() | 210 | QSpinBox *KPrefsWidTime::spinBox() |
211 | { | 211 | { |
212 | return mSpin; | 212 | return mSpin; |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | KPrefsWidRadios::KPrefsWidRadios(const QString &text,int *reference, | 216 | KPrefsWidRadios::KPrefsWidRadios(const QString &text,int *reference, |
217 | QWidget *parent) | 217 | QWidget *parent) |
218 | { | 218 | { |
219 | mReference = reference; | 219 | mReference = reference; |
220 | 220 | ||
221 | mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); | 221 | mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); |
222 | connect( mBox, SIGNAL( clicked(int)), SIGNAL( modified() ) ); | 222 | connect( mBox, SIGNAL( clicked(int)), SIGNAL( modified() ) ); |
223 | } | 223 | } |
224 | 224 | ||
225 | KPrefsWidRadios::~KPrefsWidRadios() | 225 | KPrefsWidRadios::~KPrefsWidRadios() |
226 | { | 226 | { |
227 | } | 227 | } |
228 | 228 | ||
229 | void KPrefsWidRadios::addRadio(const QString &text) | 229 | void KPrefsWidRadios::addRadio(const QString &text) |
230 | { | 230 | { |
231 | new QRadioButton(text,mBox); | 231 | new QRadioButton(text,mBox); |
232 | } | 232 | } |
233 | 233 | ||
234 | QButtonGroup *KPrefsWidRadios::groupBox() | 234 | QButtonGroup *KPrefsWidRadios::groupBox() |
235 | { | 235 | { |
236 | return mBox; | 236 | return mBox; |
237 | } | 237 | } |
238 | 238 | ||
239 | void KPrefsWidRadios::readConfig() | 239 | void KPrefsWidRadios::readConfig() |
240 | { | 240 | { |
241 | mBox->setButton(*mReference); | 241 | mBox->setButton(*mReference); |
242 | } | 242 | } |
243 | 243 | ||
244 | void KPrefsWidRadios::writeConfig() | 244 | void KPrefsWidRadios::writeConfig() |
245 | { | 245 | { |
246 | *mReference = mBox->id(mBox->selected()); | 246 | *mReference = mBox->id(mBox->selected()); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | KPrefsWidString::KPrefsWidString(const QString &text,QString *reference, | 250 | KPrefsWidString::KPrefsWidString(const QString &text,QString *reference, |
251 | QWidget *parent, QLineEdit::EchoMode echomode) | 251 | QWidget *parent, QLineEdit::EchoMode echomode) |
252 | { | 252 | { |
253 | mReference = reference; | 253 | mReference = reference; |
254 | 254 | ||
255 | mLabel = new QLabel(text,parent); | 255 | mLabel = new QLabel(text,parent); |
256 | mEdit = new QLineEdit(parent); | 256 | mEdit = new QLineEdit(parent); |
257 | mEdit->setEchoMode( echomode ); | 257 | mEdit->setEchoMode( echomode ); |
258 | connect( mEdit, SIGNAL( textChanged(const QString&) ), SIGNAL( modified() ) ); | 258 | connect( mEdit, SIGNAL( textChanged(const QString&) ), SIGNAL( modified() ) ); |
259 | 259 | ||
260 | } | 260 | } |
261 | 261 | ||
262 | KPrefsWidString::~KPrefsWidString() | 262 | KPrefsWidString::~KPrefsWidString() |
263 | { | 263 | { |
264 | } | 264 | } |
265 | 265 | ||
266 | void KPrefsWidString::readConfig() | 266 | void KPrefsWidString::readConfig() |
267 | { | 267 | { |
268 | mEdit->setText(*mReference); | 268 | mEdit->setText(*mReference); |
269 | } | 269 | } |
270 | 270 | ||
271 | void KPrefsWidString::writeConfig() | 271 | void KPrefsWidString::writeConfig() |
272 | { | 272 | { |
273 | *mReference = mEdit->text(); | 273 | *mReference = mEdit->text(); |
274 | } | 274 | } |
275 | 275 | ||
276 | QLabel *KPrefsWidString::label() | 276 | QLabel *KPrefsWidString::label() |
277 | { | 277 | { |
278 | return mLabel; | 278 | return mLabel; |
279 | } | 279 | } |
280 | 280 | ||
281 | QLineEdit *KPrefsWidString::lineEdit() | 281 | QLineEdit *KPrefsWidString::lineEdit() |
282 | { | 282 | { |
283 | return mEdit; | 283 | return mEdit; |
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | KPrefsWidget::KPrefsWidget(KPrefs *prefs,QWidget *parent,const char *name) : | 287 | KPrefsWidget::KPrefsWidget(KPrefs *prefs,QWidget *parent,const char *name) : |
288 | QWidget(parent, name ) | 288 | QWidget(parent, name ) |
289 | { | 289 | { |
290 | mPrefs = prefs; | 290 | mPrefs = prefs; |
291 | mPrefsWids.setAutoDelete( true ); | ||
291 | } | 292 | } |
292 | 293 | ||
293 | KPrefsWidget::~KPrefsWidget() | 294 | KPrefsWidget::~KPrefsWidget() |
294 | { | 295 | { |
295 | } | 296 | } |
296 | 297 | ||
297 | void KPrefsWidget::addWid(KPrefsWid *wid) | 298 | void KPrefsWidget::addWid(KPrefsWid *wid) |
298 | { | 299 | { |
299 | mPrefsWids.append(wid); | 300 | mPrefsWids.append(wid); |
300 | connect( wid, SIGNAL( modified() ), this, SLOT( modified() ) ); | 301 | connect( wid, SIGNAL( modified() ), this, SLOT( modified() ) ); |
301 | 302 | ||
302 | } | 303 | } |
303 | 304 | ||
304 | KPrefsWidBool *KPrefsWidget::addWidBool(const QString &text,bool *reference,QWidget *parent) | 305 | KPrefsWidBool *KPrefsWidget::addWidBool(const QString &text,bool *reference,QWidget *parent) |
305 | { | 306 | { |
306 | KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent); | 307 | KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent); |
307 | addWid(w); | 308 | addWid(w); |
308 | return w; | 309 | return w; |
309 | } | 310 | } |
310 | 311 | ||
311 | KPrefsWidTime *KPrefsWidget::addWidTime(const QString &text,int *reference,QWidget *parent) | 312 | KPrefsWidTime *KPrefsWidget::addWidTime(const QString &text,int *reference,QWidget *parent) |
312 | { | 313 | { |
313 | KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent); | 314 | KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent); |
314 | addWid(w); | 315 | addWid(w); |
315 | return w; | 316 | return w; |
316 | } | 317 | } |
317 | 318 | ||
318 | KPrefsWidColor *KPrefsWidget::addWidColor(const QString &text,QColor *reference,QWidget *parent) | 319 | KPrefsWidColor *KPrefsWidget::addWidColor(const QString &text,QColor *reference,QWidget *parent) |
319 | { | 320 | { |
320 | KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent); | 321 | KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent); |
321 | addWid(w); | 322 | addWid(w); |
322 | return w; | 323 | return w; |
323 | } | 324 | } |
324 | 325 | ||
325 | KPrefsWidRadios *KPrefsWidget::addWidRadios(const QString &text,int *reference,QWidget *parent) | 326 | KPrefsWidRadios *KPrefsWidget::addWidRadios(const QString &text,int *reference,QWidget *parent) |
326 | { | 327 | { |
327 | KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent); | 328 | KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent); |
328 | addWid(w); | 329 | addWid(w); |
329 | return w; | 330 | return w; |
330 | } | 331 | } |
331 | 332 | ||
332 | KPrefsWidString *KPrefsWidget::addWidString(const QString &text,QString *reference,QWidget *parent) | 333 | KPrefsWidString *KPrefsWidget::addWidString(const QString &text,QString *reference,QWidget *parent) |
333 | { | 334 | { |
334 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent); | 335 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent); |
335 | addWid(w); | 336 | addWid(w); |
336 | return w; | 337 | return w; |
337 | } | 338 | } |
338 | 339 | ||
339 | KPrefsWidString *KPrefsWidget::addWidPassword(const QString &text,QString *reference,QWidget *parent) | 340 | KPrefsWidString *KPrefsWidget::addWidPassword(const QString &text,QString *reference,QWidget *parent) |
340 | { | 341 | { |
341 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent,QLineEdit::Password); | 342 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent,QLineEdit::Password); |
342 | addWid(w); | 343 | addWid(w); |
343 | return w; | 344 | return w; |
344 | } | 345 | } |
345 | 346 | ||
346 | KPrefsWidFont *KPrefsWidget::addWidFont(const QString &sampleText,const QString &buttonText, | 347 | KPrefsWidFont *KPrefsWidget::addWidFont(const QString &sampleText,const QString &buttonText, |
347 | QFont *reference,QWidget *parent) | 348 | QFont *reference,QWidget *parent) |
348 | { | 349 | { |
349 | KPrefsWidFont *w = new KPrefsWidFont(sampleText,buttonText,reference,parent); | 350 | KPrefsWidFont *w = new KPrefsWidFont(sampleText,buttonText,reference,parent); |
350 | addWid(w); | 351 | addWid(w); |
351 | return w; | 352 | return w; |
352 | } | 353 | } |
353 | 354 | ||
354 | void KPrefsWidget::setDefaults() | 355 | void KPrefsWidget::setDefaults() |
355 | { | 356 | { |
356 | mPrefs->setDefaults(); | 357 | mPrefs->setDefaults(); |
357 | 358 | ||
358 | readConfig(); | 359 | readConfig(); |
359 | } | 360 | } |
360 | 361 | ||
361 | void KPrefsWidget::readConfig() | 362 | void KPrefsWidget::readConfig() |
362 | { | 363 | { |
363 | // kdDebug(5300) << "KPrefsDialog::readConfig()" << endl; | 364 | // kdDebug(5300) << "KPrefsDialog::readConfig()" << endl; |
364 | 365 | ||
365 | KPrefsWid *wid; | 366 | KPrefsWid *wid; |
366 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { | 367 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { |
367 | wid->readConfig(); | 368 | wid->readConfig(); |
368 | } | 369 | } |
369 | 370 | ||
370 | usrReadConfig(); | 371 | usrReadConfig(); |
371 | 372 | ||
372 | emit changed( false ); | 373 | emit changed( false ); |
373 | 374 | ||
374 | } | 375 | } |
375 | 376 | ||
376 | void KPrefsWidget::writeConfig() | 377 | void KPrefsWidget::writeConfig() |
377 | { | 378 | { |
378 | // kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl; | 379 | // kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl; |
379 | 380 | ||
380 | KPrefsWid *wid; | 381 | KPrefsWid *wid; |
381 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { | 382 | for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { |
382 | wid->writeConfig(); | 383 | wid->writeConfig(); |
383 | } | 384 | } |
384 | 385 | ||
385 | usrWriteConfig(); | 386 | usrWriteConfig(); |
386 | 387 | ||
387 | // kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl; | 388 | // kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl; |
388 | 389 | ||
389 | mPrefs->writeConfig(); | 390 | mPrefs->writeConfig(); |
390 | 391 | ||
391 | emit changed( false ); | 392 | emit changed( false ); |
392 | 393 | ||
393 | // kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl; | 394 | // kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl; |
394 | } | 395 | } |
395 | 396 | ||
396 | /*US | 397 | /*US |
397 | void KPrefsWidget::slotApply() | 398 | void KPrefsWidget::slotApply() |
398 | { | 399 | { |
399 | writeConfig(); | 400 | writeConfig(); |
400 | emit configChanged(); | 401 | emit configChanged(); |
401 | } | 402 | } |
402 | 403 | ||
403 | void KPrefsDialog::slotOk() | 404 | void KPrefsDialog::slotOk() |
404 | { | 405 | { |
405 | slotApply(); | 406 | slotApply(); |
406 | QDialog::accept(); | 407 | QDialog::accept(); |
407 | } | 408 | } |
408 | void KPrefsDialog::accept() | 409 | void KPrefsDialog::accept() |
409 | { | 410 | { |
410 | slotOk(); | 411 | slotOk(); |
411 | } | 412 | } |
412 | 413 | ||
413 | void KPrefsDialog::slotDefault() | 414 | void KPrefsDialog::slotDefault() |
414 | { | 415 | { |
415 | if (KMessageBox::warningContinueCancel(this, | 416 | if (KMessageBox::warningContinueCancel(this, |
416 | i18n("You are about to set all\npreferences to default values.\nAll " | 417 | i18n("You are about to set all\npreferences to default values.\nAll " |
417 | "custom modifications will be lost."),i18n("Setting Default Preferences"), | 418 | "custom modifications will be lost."),i18n("Setting Default Preferences"), |
418 | i18n("Continue")) | 419 | i18n("Continue")) |
419 | == KMessageBox::Continue) setDefaults(); | 420 | == KMessageBox::Continue) setDefaults(); |
420 | } | 421 | } |
421 | */ | 422 | */ |
422 | 423 | ||
423 | void KPrefsWidget::modified() | 424 | void KPrefsWidget::modified() |
424 | { | 425 | { |
425 | emit changed( true ); | 426 | emit changed( true ); |
426 | } | 427 | } |
427 | 428 | ||