2 This file is part of libkdepim.
4 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 Copyright (C) 2005,2008,2011 Allen Winter <winter@kde.org>
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
23 //krazy:excludeall=tipsandthis
25 #include "kprefsdialog.h"
27 #include <KColorButton>
29 #include <KConfigSkeleton>
30 #include <KDateComboBox>
32 #include <KFontDialog>
35 #include <KMessageBox>
36 #include <KPageWidget>
37 #include <KTimeComboBox>
38 #include <KUrlRequester>
43 #include <QGridLayout>
46 #include <QPushButton>
47 #include <QRadioButton>
50 #include <QButtonGroup>
54 #include "kprefsdialog.moc"
58 namespace KPrefsWidFactory
{
59 KPrefsWid
*create( KConfigSkeletonItem
*item
, QWidget
*parent
)
61 KConfigSkeleton::ItemBool
*boolItem
=
62 dynamic_cast<KConfigSkeleton::ItemBool
*>( item
);
64 return new KPrefsWidBool( boolItem
, parent
);
67 KConfigSkeleton::ItemString
*stringItem
=
68 dynamic_cast<KConfigSkeleton::ItemString
*>( item
);
70 return new KPrefsWidString( stringItem
, parent
);
73 KConfigSkeleton::ItemEnum
*enumItem
=
74 dynamic_cast<KConfigSkeleton::ItemEnum
*>( item
);
76 QList
<KConfigSkeleton::ItemEnum::Choice
> choices
= enumItem
->choices();
77 if ( choices
.isEmpty() ) {
78 kError() << "Enum has no choices.";
81 KPrefsWidRadios
*radios
= new KPrefsWidRadios( enumItem
, parent
);
82 QList
<KConfigSkeleton::ItemEnum::Choice
>::ConstIterator it
;
84 for ( it
= choices
.constBegin(); it
!= choices
.constEnd(); ++it
) {
85 radios
->addRadio( value
++, (*it
).label
);
91 KConfigSkeleton::ItemInt
*intItem
= dynamic_cast<KConfigSkeleton::ItemInt
*>( item
);
93 return new KPrefsWidInt( intItem
, parent
);
99 } // namespace KPrefsWidFactory
101 QList
<QWidget
*> KPrefsWid::widgets() const
103 return QList
<QWidget
*>();
106 KPrefsWidBool::KPrefsWidBool( KConfigSkeleton::ItemBool
*item
, QWidget
*parent
)
109 mCheck
= new QCheckBox( mItem
->label(), parent
);
110 connect( mCheck
, SIGNAL(clicked()), SIGNAL(changed()) );
111 QString toolTip
= mItem
->toolTip();
112 if ( !toolTip
.isEmpty() ) {
113 mCheck
->setToolTip( toolTip
);
115 QString whatsThis
= mItem
->whatsThis();
116 if ( !whatsThis
.isEmpty() ) {
117 mCheck
->setWhatsThis( whatsThis
);
121 void KPrefsWidBool::readConfig()
123 mCheck
->setChecked( mItem
->value() );
126 void KPrefsWidBool::writeConfig()
128 mItem
->setValue( mCheck
->isChecked() );
131 QCheckBox
*KPrefsWidBool::checkBox()
136 QList
<QWidget
*> KPrefsWidBool::widgets() const
138 QList
<QWidget
*> widgets
;
139 widgets
.append( mCheck
);
143 KPrefsWidInt::KPrefsWidInt( KConfigSkeleton::ItemInt
*item
, QWidget
*parent
)
146 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
147 mSpin
= new QSpinBox( parent
);
148 if ( !mItem
->minValue().isNull() ) {
149 mSpin
->setMinimum( mItem
->minValue().toInt() );
151 if ( !mItem
->maxValue().isNull() ) {
152 mSpin
->setMaximum( mItem
->maxValue().toInt() );
154 connect( mSpin
, SIGNAL(valueChanged(int)), SIGNAL(changed()) );
155 mLabel
->setBuddy( mSpin
);
156 QString toolTip
= mItem
->toolTip();
157 if ( !toolTip
.isEmpty() ) {
158 mLabel
->setToolTip( toolTip
);
159 mSpin
->setToolTip( toolTip
);
161 QString whatsThis
= mItem
->whatsThis();
162 if ( !whatsThis
.isEmpty() ) {
163 mLabel
->setWhatsThis( whatsThis
);
164 mSpin
->setWhatsThis( whatsThis
);
168 void KPrefsWidInt::readConfig()
170 mSpin
->setValue( mItem
->value() );
173 void KPrefsWidInt::writeConfig()
175 mItem
->setValue( mSpin
->value() );
178 QLabel
*KPrefsWidInt::label()
183 QSpinBox
*KPrefsWidInt::spinBox()
188 QList
<QWidget
*> KPrefsWidInt::widgets() const
190 QList
<QWidget
*> widgets
;
191 widgets
.append( mLabel
);
192 widgets
.append( mSpin
);
196 KPrefsWidColor::KPrefsWidColor( KConfigSkeleton::ItemColor
*item
, QWidget
*parent
)
199 mButton
= new KColorButton( parent
);
200 connect( mButton
, SIGNAL(changed(QColor
)), SIGNAL(changed()) );
201 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
202 mLabel
->setBuddy( mButton
);
203 QString toolTip
= mItem
->toolTip();
204 if ( !toolTip
.isEmpty() ) {
205 mButton
->setToolTip( toolTip
);
207 QString whatsThis
= mItem
->whatsThis();
208 if ( !whatsThis
.isEmpty() ) {
209 mButton
->setWhatsThis( whatsThis
);
213 KPrefsWidColor::~KPrefsWidColor()
217 void KPrefsWidColor::readConfig()
219 mButton
->setColor( mItem
->value() );
222 void KPrefsWidColor::writeConfig()
224 mItem
->setValue( mButton
->color() );
227 QLabel
*KPrefsWidColor::label()
232 KColorButton
*KPrefsWidColor::button()
237 KPrefsWidFont::KPrefsWidFont( KConfigSkeleton::ItemFont
*item
,
238 QWidget
*parent
, const QString
&sampleText
)
241 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
243 mPreview
= new QLabel( sampleText
, parent
);
244 mPreview
->setFrameStyle( QFrame::Panel
| QFrame::Sunken
);
246 mButton
= new QPushButton( i18n( "Choose..." ), parent
);
247 connect( mButton
, SIGNAL(clicked()), SLOT(selectFont()) );
248 QString toolTip
= mItem
->toolTip();
249 if ( !toolTip
.isEmpty() ) {
250 mPreview
->setToolTip( toolTip
);
251 mButton
->setToolTip( toolTip
);
253 QString whatsThis
= mItem
->whatsThis();
254 if ( !whatsThis
.isEmpty() ) {
255 mPreview
->setWhatsThis( whatsThis
);
256 mButton
->setWhatsThis( whatsThis
);
260 KPrefsWidFont::~KPrefsWidFont()
264 void KPrefsWidFont::readConfig()
266 mPreview
->setFont( mItem
->value() );
269 void KPrefsWidFont::writeConfig()
271 mItem
->setValue( mPreview
->font() );
274 QLabel
*KPrefsWidFont::label()
279 QFrame
*KPrefsWidFont::preview()
284 QPushButton
*KPrefsWidFont::button()
289 void KPrefsWidFont::selectFont()
291 #ifndef QT_NO_FONTDIALOG
292 QFont
myFont( mPreview
->font() );
293 int result
= KFontDialog::getFont( myFont
);
294 if ( result
== KFontDialog::Accepted
) {
295 mPreview
->setFont( myFont
);
301 KPrefsWidTime::KPrefsWidTime( KConfigSkeleton::ItemDateTime
*item
, QWidget
*parent
)
304 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
305 mTimeEdit
= new KTimeComboBox( parent
);
306 mLabel
->setBuddy( mTimeEdit
);
307 connect( mTimeEdit
, SIGNAL(timeEdited(QTime
)), SIGNAL(changed()) );
308 QString toolTip
= mItem
->toolTip();
309 if ( !toolTip
.isEmpty() ) {
310 mTimeEdit
->setToolTip( toolTip
);
312 QString whatsThis
= mItem
->whatsThis();
313 if ( !whatsThis
.isEmpty() ) {
314 mTimeEdit
->setWhatsThis( whatsThis
);
318 void KPrefsWidTime::readConfig()
320 mTimeEdit
->setTime( mItem
->value().time() );
323 void KPrefsWidTime::writeConfig()
325 // Don't overwrite the date value of the QDateTime, so we can use a
326 // KPrefsWidTime and a KPrefsWidDate on the same config entry!
327 QDateTime
dt( mItem
->value() );
328 dt
.setTime( mTimeEdit
->time() );
329 mItem
->setValue( dt
);
332 QLabel
*KPrefsWidTime::label()
337 KTimeComboBox
*KPrefsWidTime::timeEdit()
342 KPrefsWidDuration::KPrefsWidDuration( KConfigSkeleton::ItemDateTime
*item
,
343 const QString
&format
, QWidget
*parent
)
346 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
347 mTimeEdit
= new QTimeEdit( parent
);
348 mLabel
->setBuddy( mTimeEdit
);
349 if ( format
.isEmpty() ) {
350 mTimeEdit
->setDisplayFormat( QLatin1String( "hh:mm:ss" ) );
352 mTimeEdit
->setDisplayFormat( format
);
354 mTimeEdit
->setMinimumTime( QTime( 0, 1 ) ); // [1 min]
355 mTimeEdit
->setMaximumTime( QTime( 24, 0 ) ); // [24 hr]
356 connect( mTimeEdit
, SIGNAL(timeEdited(QTime
)), SIGNAL(changed()) );
357 QString toolTip
= mItem
->toolTip();
358 if ( !toolTip
.isEmpty() ) {
359 mTimeEdit
->setToolTip( toolTip
);
361 QString whatsThis
= mItem
->whatsThis();
362 if ( !whatsThis
.isEmpty() ) {
363 mTimeEdit
->setWhatsThis( whatsThis
);
367 void KPrefsWidDuration::readConfig()
369 mTimeEdit
->setTime( mItem
->value().time() );
372 void KPrefsWidDuration::writeConfig()
374 QDateTime
dt( mItem
->value() );
375 dt
.setTime( mTimeEdit
->time() );
376 mItem
->setValue( dt
);
379 QLabel
*KPrefsWidDuration::label()
384 QTimeEdit
*KPrefsWidDuration::timeEdit()
389 KPrefsWidDate::KPrefsWidDate( KConfigSkeleton::ItemDateTime
*item
, QWidget
*parent
)
392 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
393 mDateEdit
= new KDateComboBox( parent
);
394 mLabel
->setBuddy( mDateEdit
);
395 connect( mDateEdit
, SIGNAL(dateEdited(QDate
)), SIGNAL(changed()) );
396 QString toolTip
= mItem
->toolTip();
397 if ( !toolTip
.isEmpty() ) {
398 mDateEdit
->setToolTip( toolTip
);
400 QString whatsThis
= mItem
->whatsThis();
401 if ( !whatsThis
.isEmpty() ) {
402 mDateEdit
->setWhatsThis( whatsThis
);
406 void KPrefsWidDate::readConfig()
408 if ( !mItem
->value().date().isValid() ) {
409 mItem
->setValue( QDateTime::currentDateTime() );
411 mDateEdit
->setDate( mItem
->value().date().isValid() ?
412 mItem
->value().date() : QDate::currentDate() );
415 void KPrefsWidDate::writeConfig()
417 QDateTime
dt( mItem
->value() );
418 dt
.setDate( mDateEdit
->date() );
419 mItem
->setValue( dt
);
420 if ( !mItem
->value().date().isValid() ) {
421 mItem
->setValue( QDateTime::currentDateTime() );
425 QLabel
*KPrefsWidDate::label()
430 KDateComboBox
*KPrefsWidDate::dateEdit()
435 KPrefsWidRadios::KPrefsWidRadios( KConfigSkeleton::ItemEnum
*item
, QWidget
*parent
)
438 mBox
= new QGroupBox( mItem
->label(), parent
);
439 new QVBoxLayout( mBox
);
440 mGroup
= new QButtonGroup( parent
);
441 connect( mGroup
, SIGNAL(buttonClicked(int)), SIGNAL(changed()) );
444 KPrefsWidRadios::~KPrefsWidRadios()
448 void KPrefsWidRadios::addRadio( int value
, const QString
&text
, const QString
&toolTip
,
449 const QString
&whatsThis
)
451 QRadioButton
*r
= new QRadioButton( text
, mBox
);
452 mBox
->layout()->addWidget( r
);
453 mGroup
->addButton( r
, value
);
454 if ( !toolTip
.isEmpty() ) {
455 r
->setToolTip( toolTip
);
457 if ( !whatsThis
.isEmpty() ) {
458 r
->setWhatsThis( whatsThis
);
462 QGroupBox
*KPrefsWidRadios::groupBox() const
467 void KPrefsWidRadios::readConfig()
469 if ( !mGroup
->button( mItem
->value() ) )
471 mGroup
->button( mItem
->value() )->setChecked( true );
474 void KPrefsWidRadios::writeConfig()
476 mItem
->setValue( mGroup
->checkedId() );
479 QList
<QWidget
*> KPrefsWidRadios::widgets() const
486 KPrefsWidCombo::KPrefsWidCombo( KConfigSkeleton::ItemEnum
*item
, QWidget
*parent
)
489 KHBox
*hbox
= new KHBox( parent
);
490 new QLabel( mItem
->label(), hbox
);
491 mCombo
= new KComboBox( hbox
);
492 connect( mCombo
, SIGNAL(activated(int)), SIGNAL(changed()) );
495 KPrefsWidCombo::~KPrefsWidCombo()
499 void KPrefsWidCombo::readConfig()
501 mCombo
->setCurrentIndex( mItem
->value() );
504 void KPrefsWidCombo::writeConfig()
506 mItem
->setValue( mCombo
->currentIndex() );
509 QList
<QWidget
*> KPrefsWidCombo::widgets() const
516 KComboBox
*KPrefsWidCombo::comboBox()
521 KPrefsWidString::KPrefsWidString( KConfigSkeleton::ItemString
*item
, QWidget
*parent
,
522 KLineEdit::EchoMode echomode
)
525 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
526 mEdit
= new KLineEdit( parent
);
527 mLabel
->setBuddy( mEdit
);
528 connect( mEdit
, SIGNAL(textChanged(QString
)), SIGNAL(changed()) );
529 mEdit
->setEchoMode( echomode
);
530 QString toolTip
= mItem
->toolTip();
531 if ( !toolTip
.isEmpty() ) {
532 mEdit
->setToolTip( toolTip
);
534 QString whatsThis
= mItem
->whatsThis();
535 if ( !whatsThis
.isEmpty() ) {
536 mEdit
->setWhatsThis( whatsThis
);
540 KPrefsWidString::~KPrefsWidString()
544 void KPrefsWidString::readConfig()
546 mEdit
->setText( mItem
->value() );
549 void KPrefsWidString::writeConfig()
551 mItem
->setValue( mEdit
->text() );
554 QLabel
*KPrefsWidString::label()
559 KLineEdit
*KPrefsWidString::lineEdit()
564 QList
<QWidget
*> KPrefsWidString::widgets() const
566 QList
<QWidget
*> widgets
;
567 widgets
.append( mLabel
);
568 widgets
.append( mEdit
);
572 KPrefsWidPath::KPrefsWidPath( KConfigSkeleton::ItemPath
*item
, QWidget
*parent
,
573 const QString
&filter
, KFile::Modes mode
)
576 mLabel
= new QLabel( mItem
->label() + QLatin1Char( ':' ), parent
);
577 mURLRequester
= new KUrlRequester( parent
);
578 mLabel
->setBuddy( mURLRequester
);
579 mURLRequester
->setMode( mode
);
580 mURLRequester
->setFilter( filter
);
581 connect( mURLRequester
, SIGNAL(textChanged(QString
)), SIGNAL(changed()) );
582 QString toolTip
= mItem
->toolTip();
583 if ( !toolTip
.isEmpty() ) {
584 mURLRequester
->setToolTip( toolTip
);
586 QString whatsThis
= mItem
->whatsThis();
587 if ( !whatsThis
.isEmpty() ) {
588 mURLRequester
->setWhatsThis( whatsThis
);
592 KPrefsWidPath::~KPrefsWidPath()
596 void KPrefsWidPath::readConfig()
598 mURLRequester
->setUrl( KUrl( mItem
->value() ) );
601 void KPrefsWidPath::writeConfig()
603 mItem
->setValue( mURLRequester
->url().path() );
606 QLabel
*KPrefsWidPath::label()
611 KUrlRequester
*KPrefsWidPath::urlRequester()
613 return mURLRequester
;
616 QList
<QWidget
*> KPrefsWidPath::widgets() const
618 QList
<QWidget
*> widgets
;
619 widgets
.append( mLabel
);
620 widgets
.append( mURLRequester
);
624 KPrefsWidManager::KPrefsWidManager( KConfigSkeleton
*prefs
)
629 KPrefsWidManager::~KPrefsWidManager()
631 qDeleteAll( mPrefsWids
);
635 void KPrefsWidManager::addWid( KPrefsWid
*wid
)
637 mPrefsWids
.append( wid
);
640 KPrefsWidBool
*KPrefsWidManager::addWidBool( KConfigSkeleton::ItemBool
*item
,
643 KPrefsWidBool
*w
= new KPrefsWidBool( item
, parent
);
648 KPrefsWidTime
*KPrefsWidManager::addWidTime( KConfigSkeleton::ItemDateTime
*item
,
651 KPrefsWidTime
*w
= new KPrefsWidTime( item
, parent
);
656 KPrefsWidDuration
*KPrefsWidManager::addWidDuration( KConfigSkeleton::ItemDateTime
*item
,
657 const QString
&format
,
660 KPrefsWidDuration
*w
= new KPrefsWidDuration( item
, format
, parent
);
665 KPrefsWidDate
*KPrefsWidManager::addWidDate( KConfigSkeleton::ItemDateTime
*item
,
668 KPrefsWidDate
*w
= new KPrefsWidDate( item
, parent
);
673 KPrefsWidColor
*KPrefsWidManager::addWidColor( KConfigSkeleton::ItemColor
*item
,
676 KPrefsWidColor
*w
= new KPrefsWidColor( item
, parent
);
681 KPrefsWidRadios
*KPrefsWidManager::addWidRadios( KConfigSkeleton::ItemEnum
*item
,
684 KPrefsWidRadios
*w
= new KPrefsWidRadios( item
, parent
);
685 QList
<KConfigSkeleton::ItemEnum::Choice2
> choices
;
686 choices
= item
->choices2();
687 QList
<KConfigSkeleton::ItemEnum::Choice2
>::ConstIterator it
;
689 for ( it
= choices
.constBegin(); it
!= choices
.constEnd(); ++it
) {
690 w
->addRadio( value
++, (*it
).label
, (*it
).toolTip
, (*it
).whatsThis
);
696 KPrefsWidCombo
*KPrefsWidManager::addWidCombo( KConfigSkeleton::ItemEnum
*item
,
699 KPrefsWidCombo
*w
= new KPrefsWidCombo( item
, parent
);
700 QList
<KConfigSkeleton::ItemEnum::Choice
> choices
;
701 choices
= item
->choices();
702 QList
<KConfigSkeleton::ItemEnum::Choice
>::ConstIterator it
;
703 for ( it
= choices
.constBegin(); it
!= choices
.constEnd(); ++it
) {
704 w
->comboBox()->addItem( (*it
).label
);
710 KPrefsWidString
*KPrefsWidManager::addWidString( KConfigSkeleton::ItemString
*item
,
713 KPrefsWidString
*w
= new KPrefsWidString( item
, parent
, KLineEdit::Normal
);
718 KPrefsWidPath
*KPrefsWidManager::addWidPath( KConfigSkeleton::ItemPath
*item
,
720 const QString
&filter
,
723 KPrefsWidPath
*w
= new KPrefsWidPath( item
, parent
, filter
, mode
);
728 KPrefsWidString
*KPrefsWidManager::addWidPassword( KConfigSkeleton::ItemString
*item
,
731 KPrefsWidString
*w
= new KPrefsWidString( item
, parent
, KLineEdit::Password
);
736 KPrefsWidFont
*KPrefsWidManager::addWidFont( KConfigSkeleton::ItemFont
*item
,
738 const QString
&sampleText
)
740 KPrefsWidFont
*w
= new KPrefsWidFont( item
, parent
, sampleText
);
745 KPrefsWidInt
*KPrefsWidManager::addWidInt( KConfigSkeleton::ItemInt
*item
,
748 KPrefsWidInt
*w
= new KPrefsWidInt( item
, parent
);
753 void KPrefsWidManager::setWidDefaults()
755 bool tmp
= mPrefs
->useDefaults( true );
757 mPrefs
->useDefaults( tmp
);
760 void KPrefsWidManager::readWidConfig()
762 QList
<KPrefsWid
*>::Iterator it
;
763 for ( it
= mPrefsWids
.begin(); it
!= mPrefsWids
.end(); ++it
) {
768 void KPrefsWidManager::writeWidConfig()
770 QList
<KPrefsWid
*>::Iterator it
;
771 for ( it
= mPrefsWids
.begin(); it
!= mPrefsWids
.end(); ++it
) {
772 (*it
)->writeConfig();
775 mPrefs
->writeConfig();
778 KPrefsDialog::KPrefsDialog( KConfigSkeleton
*prefs
, QWidget
*parent
, bool modal
)
779 : KPageDialog( parent
),
780 KPrefsWidManager( prefs
)
783 setCaption( i18n( "Preferences" ) );
784 setButtons( Ok
|Apply
|Cancel
|Default
);
785 setDefaultButton( Ok
);
787 showButtonSeparator( true );
788 connect( this, SIGNAL(okClicked()), SLOT(slotOk()) );
789 connect( this, SIGNAL(applyClicked()), SLOT(slotApply()) );
790 connect( this, SIGNAL(defaultClicked()), SLOT(slotDefault()) );
791 connect( this, SIGNAL(cancelClicked()), SLOT(reject()) );
794 KPrefsDialog::~KPrefsDialog()
799 void KPrefsDialog::autoCreate()
801 KConfigSkeletonItem::List items
= prefs()->items();
803 QMap
<QString
,QWidget
*> mGroupPages
;
804 QMap
<QString
,QGridLayout
*> mGroupLayouts
;
805 QMap
<QString
,int> mCurrentRows
;
807 KConfigSkeletonItem::List::ConstIterator it
;
808 for ( it
= items
.constBegin(); it
!= items
.constEnd(); ++it
) {
809 QString group
= (*it
)->group();
810 QString name
= (*it
)->name();
815 if ( !mGroupPages
.contains( group
) ) {
816 page
= new QWidget( this );
817 addPage( page
, group
);
818 layout
= new QGridLayout( page
);
819 mGroupPages
.insert( group
, page
);
820 mGroupLayouts
.insert( group
, layout
);
822 mCurrentRows
.insert( group
, currentRow
);
824 page
= mGroupPages
[ group
];
825 layout
= mGroupLayouts
[ group
];
826 currentRow
= mCurrentRows
[ group
];
829 KPrefsWid
*wid
= KPrefsWidFactory::create( *it
, page
);
832 QList
<QWidget
*> widgets
= wid
->widgets();
833 if ( widgets
.count() == 1 ) {
834 layout
->addWidget( widgets
[ 0 ], currentRow
, currentRow
, 0, 1 );
835 } else if ( widgets
.count() == 2 ) {
836 layout
->addWidget( widgets
[ 0 ], currentRow
, 0 );
837 layout
->addWidget( widgets
[ 1 ], currentRow
, 1 );
839 kError() <<"More widgets than expected:" << widgets
.count();
842 if ( (*it
)->isImmutable() ) {
843 QList
<QWidget
*>::Iterator it2
;
844 for ( it2
= widgets
.begin(); it2
!= widgets
.end(); ++it2
) {
845 (*it2
)->setEnabled( false );
849 mCurrentRows
.insert( group
, ++currentRow
);
856 void KPrefsDialog::setDefaults()
861 void KPrefsDialog::readConfig()
867 void KPrefsDialog::writeConfig()
874 void KPrefsDialog::slotApply()
878 emit
configChanged();
881 void KPrefsDialog::slotOk()
887 void KPrefsDialog::slotDefault()
889 if ( KMessageBox::warningContinueCancel(
891 i18n( "You are about to set all preferences to default values. "
892 "All custom modifications will be lost." ),
893 i18n( "Setting Default Preferences" ),
894 KGuiItem( i18n( "Reset to Defaults" ) ) ) == KMessageBox::Continue
) {
899 KPrefsModule::KPrefsModule( KConfigSkeleton
*prefs
, const KComponentData
&instance
,
900 QWidget
*parent
, const QVariantList
&args
)
901 : KCModule( instance
, parent
, args
),
902 KPrefsWidManager( prefs
)
904 emit
changed( false );
907 void KPrefsModule::addWid( KPrefsWid
*wid
)
909 KPrefsWidManager::addWid( wid
);
910 connect( wid
, SIGNAL(changed()), SLOT(slotWidChanged()) );
913 void KPrefsModule::slotWidChanged()
915 emit
changed( true );
918 void KPrefsModule::load()
923 emit
changed( false );
926 void KPrefsModule::save()
932 void KPrefsModule::defaults()
936 emit
changed( true );