26 #include <tqbuttongroup.h> 27 #include <tqlineedit.h> 29 #include <tqspinbox.h> 31 #include <tqcombobox.h> 32 #include <tqcheckbox.h> 33 #include <tqradiobutton.h> 34 #include <tqpushbutton.h> 35 #include <tqdatetimeedit.h> 36 #include <tqwhatsthis.h> 38 #include <kcolorbutton.h> 40 #include <tdelocale.h> 41 #include <tdefontdialog.h> 42 #include <tdemessagebox.h> 43 #include <tdeconfigskeleton.h> 44 #include <kurlrequester.h> 45 #include "ktimeedit.h" 46 #include "kdateedit.h" 48 #include "kprefsdialog.h" 49 #include "kprefsdialog.moc" 53 KPrefsWid *create( TDEConfigSkeletonItem *item, TQWidget *parent )
55 TDEConfigSkeleton::ItemBool *boolItem =
56 dynamic_cast<TDEConfigSkeleton::ItemBool *
>( item );
61 TDEConfigSkeleton::ItemString *stringItem =
62 dynamic_cast<TDEConfigSkeleton::ItemString *
>( item );
67 TDEConfigSkeleton::ItemEnum *enumItem =
68 dynamic_cast<TDEConfigSkeleton::ItemEnum *
>( item );
70 TQValueList<TDEConfigSkeleton::ItemEnum::Choice> choices = enumItem->choices();
71 if ( choices.isEmpty() ) {
72 kdError() <<
"KPrefsWidFactory::create(): Enum has no choices." << endl;
76 TQValueList<TDEConfigSkeleton::ItemEnum::Choice>::ConstIterator it;
77 for( it = choices.begin(); it != choices.end(); ++it ) {
84 TDEConfigSkeleton::ItemInt *intItem =
85 dynamic_cast<TDEConfigSkeleton::ItemInt *
>( item );
98 return TQValueList<TQWidget *>();
105 mCheck =
new TQCheckBox( item->label(), parent);
106 connect( mCheck, TQT_SIGNAL( clicked() ), TQT_SIGNAL(
changed() ) );
107 if ( !item->whatsThis().isNull() ) {
108 TQWhatsThis::add( mCheck, item->whatsThis() );
114 mCheck->setChecked( mItem->value() );
119 mItem->setValue( mCheck->isChecked() );
129 TQValueList<TQWidget *>
widgets;
130 widgets.append( mCheck );
139 mLabel =
new TQLabel( mItem->label()+
':', parent );
140 mSpin =
new TQSpinBox( parent );
141 if ( !item->minValue().isNull() ) {
142 mSpin->setMinValue( item->minValue().toInt() );
144 if ( !item->maxValue().isNull() ) {
145 mSpin->setMaxValue( item->maxValue().toInt() );
147 connect( mSpin, TQT_SIGNAL( valueChanged(
int ) ), TQT_SIGNAL(
changed() ) );
148 mLabel->setBuddy( mSpin );
149 TQString whatsThis = mItem->whatsThis();
150 if ( !whatsThis.isEmpty() ) {
151 TQWhatsThis::add( mLabel, whatsThis );
152 TQWhatsThis::add( mSpin, whatsThis );
158 mSpin->setValue( mItem->value() );
163 mItem->setValue( mSpin->value() );
178 TQValueList<TQWidget *>
widgets;
179 widgets.append( mLabel );
180 widgets.append( mSpin );
189 mButton =
new KColorButton( parent );
190 connect( mButton, TQT_SIGNAL(
changed(
const TQColor & ) ), TQT_SIGNAL(
changed() ) );
191 mLabel =
new TQLabel( mButton, mItem->label()+
':', parent );
192 mLabel->setBuddy( mButton );
193 TQString whatsThis = mItem->whatsThis();
194 if (!whatsThis.isNull()) {
195 TQWhatsThis::add(mButton, whatsThis);
206 mButton->setColor( mItem->value() );
211 mItem->setValue( mButton->color() );
226 TQWidget *parent,
const TQString &sampleText )
229 mLabel =
new TQLabel( mItem->label()+
':', parent );
231 mPreview =
new TQLabel( sampleText, parent );
232 mPreview->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
234 mButton =
new TQPushButton( i18n(
"Choose..."), parent );
235 connect( mButton, TQT_SIGNAL( clicked() ), TQT_SLOT( selectFont() ) );
236 TQString whatsThis = mItem->whatsThis();
237 if (!whatsThis.isNull()) {
238 TQWhatsThis::add(mPreview, whatsThis);
239 TQWhatsThis::add(mButton, whatsThis);
249 mPreview->setFont( mItem->value() );
254 mItem->setValue( mPreview->font() );
272 void KPrefsWidFont::selectFont()
274 TQFont myFont(mPreview->font());
275 int result = TDEFontDialog::getFont(myFont);
276 if (result == TDEFontDialog::Accepted) {
277 mPreview->setFont(myFont);
287 mLabel =
new TQLabel( mItem->label()+
':', parent );
289 mLabel->setBuddy( mTimeEdit );
290 connect( mTimeEdit, TQT_SIGNAL( timeChanged( TQTime ) ), TQT_SIGNAL(
changed() ) );
291 TQString whatsThis = mItem->whatsThis();
292 if ( !whatsThis.isNull() ) {
293 TQWhatsThis::add( mTimeEdit, whatsThis );
299 mTimeEdit->
setTime( mItem->value().time() );
306 TQDateTime dt( mItem->value() );
307 dt.setTime( mTimeEdit->
getTime() );
308 mItem->setValue( dt );
326 mLabel =
new TQLabel( mItem->label()+
':', parent );
327 mTimeEdit =
new TQTimeEdit( parent );
328 mLabel->setBuddy( mTimeEdit );
329 mTimeEdit->setAutoAdvance(
true );
330 mTimeEdit->setDisplay( TQTimeEdit::Hours | TQTimeEdit::Minutes );
331 mTimeEdit->setRange( TQTime( 0, 1 ), TQTime( 24, 0 ) );
333 TQT_SIGNAL( valueChanged(
const TQTime & ) ), TQT_SIGNAL(
changed() ) );
334 TQString whatsThis = mItem->whatsThis();
335 if ( !whatsThis.isNull() ) {
336 TQWhatsThis::add( mTimeEdit, whatsThis );
342 mTimeEdit->setTime( mItem->value().time() );
347 TQDateTime dt( mItem->value() );
348 dt.setTime( mTimeEdit->time() );
349 mItem->setValue( dt );
367 mLabel =
new TQLabel( mItem->label()+
':', parent );
369 mLabel->setBuddy( mDateEdit );
370 connect( mDateEdit, TQT_SIGNAL( dateChanged(
const TQDate& ) ), TQT_SIGNAL(
changed() ) );
371 TQString whatsThis = mItem->whatsThis();
372 if ( !whatsThis.isNull() ) {
373 TQWhatsThis::add( mDateEdit, whatsThis );
379 mDateEdit->
setDate( mItem->value().date().isValid() ? mItem->value().date() : TQDate::currentDate() );
384 TQDateTime dt( mItem->value() );
385 dt.setDate( mDateEdit->
date() );
386 mItem->setValue( dt );
404 mBox =
new TQButtonGroup( 1, Qt::Horizontal, mItem->label(), parent );
405 connect( mBox, TQT_SIGNAL( clicked(
int ) ), TQT_SIGNAL(
changed() ) );
408 KPrefsWidRadios::~KPrefsWidRadios()
414 TQRadioButton *r =
new TQRadioButton(text,mBox);
415 if (!whatsThis.isNull()) {
416 TQWhatsThis::add(r, whatsThis);
427 mBox->setButton( mItem->value() );
432 mItem->setValue( mBox->id( mBox->selected() ) );
437 TQValueList<TQWidget *> w;
446 TQHBox *hbox =
new TQHBox(parent);
447 new TQLabel( mItem->label(), hbox );
448 mCombo =
new TQComboBox( hbox );
449 connect( mCombo, TQT_SIGNAL( activated(
int ) ), TQT_SIGNAL(
changed() ) );
452 KPrefsWidCombo::~KPrefsWidCombo()
458 mCombo->setCurrentItem( mItem->value() );
463 mItem->setValue( mCombo->currentItem() );
468 TQValueList<TQWidget *> w;
473 TQComboBox* KPrefsWidCombo::comboBox()
480 TQLineEdit::EchoMode echomode )
483 mLabel =
new TQLabel( mItem->label()+
':', parent );
484 mEdit =
new TQLineEdit( parent );
485 mLabel->setBuddy( mEdit );
486 connect( mEdit, TQT_SIGNAL( textChanged(
const TQString & ) ),
488 mEdit->setEchoMode( echomode );
489 TQString whatsThis = mItem->whatsThis();
490 if ( !whatsThis.isNull() ) {
491 TQWhatsThis::add( mEdit, whatsThis );
501 mEdit->setText( mItem->value() );
506 mItem->setValue( mEdit->text() );
521 TQValueList<TQWidget *>
widgets;
522 widgets.append( mLabel );
523 widgets.append( mEdit );
529 const TQString &filter, uint mode )
532 mLabel =
new TQLabel( mItem->label()+
':', parent );
533 mURLRequester =
new KURLRequester( parent );
534 mLabel->setBuddy( mURLRequester );
535 mURLRequester->setMode( mode );
536 mURLRequester->setFilter( filter );
537 connect( mURLRequester, TQT_SIGNAL( textChanged(
const TQString & ) ),
539 TQString whatsThis = mItem->whatsThis();
540 if ( !whatsThis.isNull() ) {
541 TQWhatsThis::add( mURLRequester, whatsThis );
551 mURLRequester->setURL( mItem->value() );
556 mItem->setValue( mURLRequester->url() );
566 return mURLRequester;
571 TQValueList<TQWidget *>
widgets;
572 widgets.append( mLabel );
573 widgets.append( mURLRequester );
589 mPrefsWids.append( wid );
636 TQValueList<TDEConfigSkeleton::ItemEnum::Choice> choices;
637 choices = item->choices();
638 TQValueList<TDEConfigSkeleton::ItemEnum::Choice>::ConstIterator it;
639 for( it = choices.begin(); it != choices.end(); ++it ) {
640 w->
addRadio( (*it).label, (*it).whatsThis );
650 TQValueList<TDEConfigSkeleton::ItemEnum::Choice> choices;
651 choices = item->choices();
652 TQValueList<TDEConfigSkeleton::ItemEnum::Choice>::ConstIterator it;
653 for( it = choices.begin(); it != choices.end(); ++it ) {
654 w->comboBox()->insertItem( (*it).label, -1 );
664 TQLineEdit::Normal );
670 TQWidget *parent,
const TQString &filter, uint mode )
687 const TQString &sampleText )
704 kdDebug() <<
"KPrefsWidManager::setWidDefaults()" << endl;
706 bool tmp = mPrefs->useDefaults(
true );
710 mPrefs->useDefaults( tmp );
715 kdDebug(5310) <<
"KPrefsWidManager::readWidConfig()" << endl;
718 for( wid = mPrefsWids.first(); wid; wid = mPrefsWids.next() ) {
725 kdDebug(5310) <<
"KPrefsWidManager::writeWidConfig()" << endl;
728 for( wid = mPrefsWids.first(); wid; wid = mPrefsWids.next() ) {
732 mPrefs->writeConfig();
738 : KDialogBase(IconList,i18n(
"Preferences"),Ok|Apply|Cancel|Default,Ok,parent,
746 connect(
this,TQT_SIGNAL(cancelClicked()),TQT_SLOT(reject()));
753 void KPrefsDialog::autoCreate()
755 TDEConfigSkeletonItem::List items = prefs()->items();
757 TQMap<TQString,TQWidget *> mGroupPages;
758 TQMap<TQString,TQGridLayout *> mGroupLayouts;
759 TQMap<TQString,int> mCurrentRows;
761 TDEConfigSkeletonItem::List::ConstIterator it;
762 for( it = items.begin(); it != items.end(); ++it ) {
763 TQString group = (*it)->group();
764 TQString name = (*it)->name();
766 kdDebug() <<
"ITEMS: " << (*it)->name() << endl;
769 TQGridLayout *layout;
771 if ( !mGroupPages.contains( group ) ) {
772 page = addPage( group );
773 layout =
new TQGridLayout( page );
774 mGroupPages.insert( group, page );
775 mGroupLayouts.insert( group, layout );
777 mCurrentRows.insert( group, currentRow );
779 page = mGroupPages[ group ];
780 layout = mGroupLayouts[ group ];
781 currentRow = mCurrentRows[ group ];
784 KPrefsWid *wid = KPrefsWidFactory::create( *it, page );
787 TQValueList<TQWidget *> widgets = wid->
widgets();
788 if ( widgets.count() == 1 ) {
789 layout->addMultiCellWidget( widgets[ 0 ],
790 currentRow, currentRow, 0, 1 );
791 }
else if ( widgets.count() == 2 ) {
792 layout->addWidget( widgets[ 0 ], currentRow, 0 );
793 layout->addWidget( widgets[ 1 ], currentRow, 1 );
795 kdError() <<
"More widgets than expected: " << widgets.count() << endl;
798 if ( (*it)->isImmutable() ) {
799 TQValueList<TQWidget *>::Iterator it2;
800 for( it2 = widgets.begin(); it2 != widgets.end(); ++it2 ) {
801 (*it2)->setEnabled(
false );
807 mCurrentRows.replace( group, ++currentRow );
850 kdDebug() <<
"KPrefsDialog::slotDefault()" << endl;
852 if (KMessageBox::warningContinueCancel(
this,
853 i18n(
"You are about to set all preferences to default values. All " 854 "custom modifications will be lost."),i18n(
"Setting Default Preferences"),
855 i18n(
"Reset to Defaults"))
860 KPrefsModule::KPrefsModule( TDEConfigSkeleton *prefs, TQWidget *parent,
862 : TDECModule( parent, name ),
865 emit changed(
false );
868 void KPrefsModule::addWid(
KPrefsWid *wid )
872 connect( wid, TQT_SIGNAL( changed() ), TQT_SLOT( slotWidChanged() ) );
875 void KPrefsModule::slotWidChanged()
877 kdDebug(5310) <<
"KPrefsModule::slotWidChanged()" << endl;
879 emit changed(
true );
882 void KPrefsModule::load()
884 kdDebug(5310) <<
"KPrefsModule::load()" << endl;
890 emit changed(
false );
893 void KPrefsModule::save()
895 kdDebug(5310) <<
"KPrefsModule::save()" << endl;
902 void KPrefsModule::defaults()
906 emit changed(
true );
void setWidDefaults()
Set all widgets to default values.
TQLabel * label()
Return TQLabel used by this widget.
virtual void readConfig()=0
This function is called to read value of the setting from the stored configuration and display it in ...
KPrefsWidFont * addWidFont(TDEConfigSkeleton::ItemFont *item, TQWidget *parent, const TQString &sampleText)
Register a KPrefsWidFont object.
KPrefsWidBool(TDEConfigSkeleton::ItemBool *item, TQWidget *parent)
Create a bool value control element consisting of a TQCheckbox.
virtual void addWid(KPrefsWid *)
Register a custom KPrefsWid object.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
KPrefsWidRadios(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Create a control element for selection of an option.
virtual ~KPrefsWidManager()
Destructor.
A date editing widget that consists of an editable combo box.
Widgets for time settings in KPrefsDialog.
KTimeEdit * timeEdit()
Return TQSpinBox used by this widget.
Base class for GUI control elements used by KPrefsDialog.
void readConfig()
Read preferences from config file.
KColorButton * button()
Return button opening the color dialog.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
Widgets for font settings in KPrefsDialog.
virtual void usrReadConfig()
Implement this to read custom configuration widgets.
TQTimeEdit * timeEdit()
Return TQSpinBox used by this widget.
void setTime(TQTime qt)
used to set the time which is displayed to a specific value.
This is a class that provides an easy, user friendly way to edit times.
KDateEdit * dateEdit()
Return TQSpinBox used by this widget.
Widgets for string settings in KPrefsDialog.
TQLabel * label()
Return TQLabel used by this widget.
void writeWidConfig()
Write preferences to config file.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
virtual void writeConfig()=0
This function is called to write the current setting of the widget to the stored configuration.
Widgets for int settings in KPrefsDialog.
TQLineEdit * lineEdit()
Return TQLineEdit used by this widget.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
KPrefsWidBool * addWidBool(TDEConfigSkeleton::ItemBool *item, TQWidget *parent)
Register a KPrefsWidBool object.
KPrefsWidManager(TDEConfigSkeleton *prefs)
Create a KPrefsWidManager object for a KPrefs object.
TQPushButton * button()
Return button opening the font dialog.
KPrefsWidCombo(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Create a control element for selection of an option.
TQLabel * label()
Return TQLabel used by this widget.
Widgets for bool settings in KPrefsDialog.
~KPrefsWidColor()
Destruct color setting widget.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
TQLabel * label()
Return TQLabel used by this control element.
virtual TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
Widgets for time settings in KPrefsDialog.
virtual ~KPrefsDialog()
Destructor.
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
TQCheckBox * checkBox()
Return the TQCheckbox used by this control element.
virtual void usrWriteConfig()
Implement this to write custom configuration widgets.
KPrefsDialog(TDEConfigSkeleton *prefs, TQWidget *parent=0, char *name=0, bool modal=false)
Create a KPrefsDialog for a KPrefs object.
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
TQTime getTime() const
returns the time that is currently set in the timeLineEdit.
KPrefsWidInt(TDEConfigSkeleton::ItemInt *item, TQWidget *parent)
Create a integer value control element consisting of a label and a spinbox.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
Class for managing KPrefsWid objects.
void setDate(const TQDate &date)
Sets the date.
KPrefsWidInt * addWidInt(TDEConfigSkeleton::ItemInt *item, TQWidget *parent)
Register a KPrefsWidInt object.
TQSpinBox * spinBox()
Return the TQSpinBox used by this control element.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
Widgets for settings represented by a combo box in KPrefsDialog.
KPrefsWidString * addWidPassword(TDEConfigSkeleton::ItemString *item, TQWidget *parent)
Register a password KPrefsWidString object, with echomode set to TQLineEdit::Password.
~KPrefsWidFont()
Destruct font setting widget.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
TQLabel * label()
Return TQLabel for the button.
Widgets for settings represented by a group of radio buttons in KPrefsDialog.
TQButtonGroup * groupBox()
Return the box widget used by this widget.
KPrefsWidFont(TDEConfigSkeleton::ItemFont *item, TQWidget *parent, const TQString &sampleText)
Create a font value control element consisting of a test field and a button for opening a font dialog...
KPrefsWidDate * addWidDate(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Register a KPrefsWidDate object.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
KPrefsWidDate(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Create a time value control element consisting of a label and a date box.
void addRadio(const TQString &text, const TQString &whatsThis=TQString())
Add a radio button.
Widgets for color settings in KPrefsDialog.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
void readWidConfig()
Read preferences from config file.
KPrefsWidString(TDEConfigSkeleton::ItemString *item, TQWidget *parent, TQLineEdit::EchoMode echomode=TQLineEdit::Normal)
Create a string value control element consisting of a test label and a line edit. ...
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
KURLRequester * urlRequester()
Return TQLineEdit used by this widget.
virtual ~KPrefsWidString()
Destructor.
TQLabel * label()
Return TQLabel.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
void writeConfig()
Write preferences to config file.
void changed()
Emitted when widget value has changed.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
virtual ~KPrefsWidPath()
Destructor.
KPrefsWidTime * addWidTime(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Register a KPrefsWidTime object.
Widgets for string settings in KPrefsDialog.
KPrefsWidPath * addWidPath(TDEConfigSkeleton::ItemPath *item, TQWidget *parent, const TQString &filter=TQString(), uint mode=KFile::File)
Register a path KPrefsWidPath object.
TQLabel * label()
Return TQLabel used by this widget.
KPrefsWidDuration * addWidDuration(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Register a KPrefsWidDuration object.
TQLabel * label()
Return TQLabel used by this widget.
KPrefsWidRadios * addWidRadios(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Register a KPrefsWidRadios object.
TQFrame * preview()
Return TQFrame used as preview field.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
KPrefsWidCombo * addWidCombo(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Register a KPrefsWidCombo object.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
KPrefsWidPath(TDEConfigSkeleton::ItemPath *item, TQWidget *parent, const TQString &filter=TQString(), uint mode=KFile::File)
Create a string value control element consisting of a test label and a line edit. ...
KPrefsWidString * addWidString(TDEConfigSkeleton::ItemString *item, TQWidget *parent)
Register a KPrefsWidString object.
KPrefsWidColor * addWidColor(TDEConfigSkeleton::ItemColor *item, TQWidget *parent)
Register a KPrefsWidColor object.
Widgets for duration settings in KPrefsDialog.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
void slotOk()
Accept changes to preferences and close dialog.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
KPrefsWidDuration(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Create a duration value control element consisting of a label and a spinbox.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
void configChanged()
Emitted when the a changed configuration has been stored.
void setDefaults()
Set all widgets to default values.
void slotApply()
Apply changes to preferences.
KPrefsWidTime(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Create a time value control element consisting of a label and a spinbox.
KPrefsWidColor(TDEConfigSkeleton::ItemColor *item, TQWidget *parent)
Create a color value control element consisting of a test field and a button for opening a color dial...
void slotDefault()
Set preferences to default values.