libtdepim

kprefsdialog.h
1/*
2 This file is part of libtdepim.
3
4 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 Copyright (C) 2005 Allen Winter <winter@kde.org>
7
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.
12
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.
17
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.
22*/
23#ifndef KPREFSDIALOG_H
24#define KPREFSDIALOG_H
25
26#include <tqptrlist.h>
27#include <tqlineedit.h>
28#include <tqvaluelist.h>
29#include <tqdatetimeedit.h>
30
31#include <kdialogbase.h>
32#include <tdecmodule.h>
33#include <tdeconfigskeleton.h>
34#include <tdefile.h>
35#include <tdemacros.h>
36
37
38class KColorButton;
39class TQCheckBox;
40class TQComboBox;
41class TQLabel;
42class TQSpinBox;
43class TQButtonGroup;
44class TQTimeEdit;
45class KTimeEdit;
46class KDateEdit;
47class KURLRequester;
48
58class TDE_EXPORT KPrefsWid : public TQObject
59{
60 TQ_OBJECT
61
62 public:
67 virtual void readConfig() = 0;
72 virtual void writeConfig() = 0;
73
77 virtual TQValueList<TQWidget *> widgets() const;
78
79 signals:
83 void changed();
84};
85
92class TDE_EXPORT KPrefsWidBool : public KPrefsWid
93{
94 public:
101 KPrefsWidBool( TDEConfigSkeleton::ItemBool *item, TQWidget *parent );
102
106 TQCheckBox *checkBox();
107
108 void readConfig();
109 void writeConfig();
110
111 TQValueList<TQWidget *> widgets() const;
112
113 private:
114 TDEConfigSkeleton::ItemBool *mItem;
115
116 TQCheckBox *mCheck;
117};
118
126class TDE_EXPORT KPrefsWidInt : public KPrefsWid
127{
128 public:
136 KPrefsWidInt( TDEConfigSkeleton::ItemInt *item, TQWidget *parent );
137
141 TQLabel *label();
142
146 TQSpinBox *spinBox();
147
148 void readConfig();
149 void writeConfig();
150
151 TQValueList<TQWidget *> widgets() const;
152
153 private:
154 TDEConfigSkeleton::ItemInt *mItem;
155
156 TQLabel *mLabel;
157 TQSpinBox *mSpin;
158};
159
167class TDE_EXPORT KPrefsWidTime : public KPrefsWid
168{
169 public:
176 KPrefsWidTime( TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent );
177
181 TQLabel *label();
186
187 void readConfig();
188 void writeConfig();
189
190 private:
191 TDEConfigSkeleton::ItemDateTime *mItem;
192
193 TQLabel *mLabel;
194 KTimeEdit *mTimeEdit;
195};
196
204class TDE_EXPORT KPrefsWidDuration : public KPrefsWid
205{
206 public:
214 KPrefsWidDuration( TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent );
215
219 TQLabel *label();
223 TQTimeEdit *timeEdit();
224
225 void readConfig();
226 void writeConfig();
227
228 private:
229 TDEConfigSkeleton::ItemDateTime *mItem;
230
231 TQLabel *mLabel;
232 TQTimeEdit *mTimeEdit;
233};
234
242class TDE_EXPORT KPrefsWidDate : public KPrefsWid
243{
244 public:
251 KPrefsWidDate( TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent );
252
256 TQLabel *label();
261
262 void readConfig();
263 void writeConfig();
264
265 private:
266 TDEConfigSkeleton::ItemDateTime *mItem;
267
268 TQLabel *mLabel;
269 KDateEdit *mDateEdit;
270};
271
279class TDE_EXPORT KPrefsWidColor : public KPrefsWid
280{
281 TQ_OBJECT
282
283 public:
291 KPrefsWidColor( TDEConfigSkeleton::ItemColor *item, TQWidget *parent );
296
300 TQLabel *label();
304 KColorButton *button();
305
306 void readConfig();
307 void writeConfig();
308
309 private:
310 TDEConfigSkeleton::ItemColor *mItem;
311
312 TQLabel *mLabel;
313 KColorButton *mButton;
314};
315
322class TDE_EXPORT KPrefsWidFont : public KPrefsWid
323{
324 TQ_OBJECT
325
326 public:
335 KPrefsWidFont( TDEConfigSkeleton::ItemFont *item,
336 TQWidget *parent, const TQString &sampleText );
341
345 TQLabel *label();
349 TQFrame *preview();
353 TQPushButton *button();
354
355 void readConfig();
356 void writeConfig();
357
358 protected slots:
359 void selectFont();
360
361 private:
362 TDEConfigSkeleton::ItemFont *mItem;
363
364 TQLabel *mLabel;
365 TQLabel *mPreview;
366 TQPushButton *mButton;
367};
368
380class TDE_EXPORT KPrefsWidRadios : public KPrefsWid
381{
382 public:
390 KPrefsWidRadios( TDEConfigSkeleton::ItemEnum *item, TQWidget *parent );
391 virtual ~KPrefsWidRadios();
392
399 void addRadio( const TQString &text,
400 const TQString &whatsThis = TQString() );
401
405 TQButtonGroup *groupBox();
406
407 void readConfig();
408 void writeConfig();
409
410 TQValueList<TQWidget *> widgets() const;
411
412 private:
413 TDEConfigSkeleton::ItemEnum *mItem;
414
415 TQButtonGroup *mBox;
416};
417
428class TDE_EXPORT KPrefsWidCombo : public KPrefsWid
429{
430 public:
438 KPrefsWidCombo( TDEConfigSkeleton::ItemEnum *item, TQWidget *parent );
439 virtual ~KPrefsWidCombo();
440
441 void readConfig();
442 void writeConfig();
443
444 TQComboBox *comboBox();
445 TQValueList<TQWidget *> widgets() const;
446
447 private:
448 TDEConfigSkeleton::ItemEnum *mItem;
449 TQComboBox *mCombo;
450};
451
452
453
461class TDE_EXPORT KPrefsWidString : public KPrefsWid
462{
463 public:
472 KPrefsWidString( TDEConfigSkeleton::ItemString *item, TQWidget *parent,
473 TQLineEdit::EchoMode echomode=TQLineEdit::Normal );
477 virtual ~KPrefsWidString();
478
482 TQLabel *label();
486 TQLineEdit *lineEdit();
487
488 void readConfig();
489 void writeConfig();
490
491 TQValueList<TQWidget *> widgets() const;
492
493 private:
494 TDEConfigSkeleton::ItemString *mItem;
495
496 TQLabel *mLabel;
497 TQLineEdit *mEdit;
498};
499
500
508class TDE_EXPORT KPrefsWidPath : public KPrefsWid
509{
510 public:
520 KPrefsWidPath( TDEConfigSkeleton::ItemPath *item, TQWidget *parent,
521 const TQString &filter = TQString(), uint mode = KFile::File );
525 virtual ~KPrefsWidPath();
526
530 TQLabel *label();
534 KURLRequester *urlRequester();
535
536 void readConfig();
537 void writeConfig();
538
539 TQValueList<TQWidget *> widgets() const;
540
541 private:
542 TDEConfigSkeleton::ItemPath *mItem;
543
544 TQLabel *mLabel;
545 KURLRequester *mURLRequester;
546};
547
548
557class TDE_EXPORT KPrefsWidManager
558{
559 public:
565 KPrefsWidManager( TDEConfigSkeleton *prefs );
569 virtual ~KPrefsWidManager();
570
571 TDEConfigSkeleton *prefs() const { return mPrefs; }
572
576 virtual void addWid( KPrefsWid * );
577
584 KPrefsWidBool *addWidBool( TDEConfigSkeleton::ItemBool *item,
585 TQWidget *parent );
586
593 KPrefsWidInt *addWidInt( TDEConfigSkeleton::ItemInt *item,
594 TQWidget *parent );
595
602 KPrefsWidDate *addWidDate( TDEConfigSkeleton::ItemDateTime *item,
603 TQWidget *parent );
604
611 KPrefsWidTime *addWidTime( TDEConfigSkeleton::ItemDateTime *item,
612 TQWidget *parent );
613
620 KPrefsWidDuration *addWidDuration( TDEConfigSkeleton::ItemDateTime *item,
621 TQWidget *parent );
622
629 KPrefsWidColor *addWidColor( TDEConfigSkeleton::ItemColor *item,
630 TQWidget *parent );
631
639 KPrefsWidRadios *addWidRadios( TDEConfigSkeleton::ItemEnum *item,
640 TQWidget *parent );
641
649 KPrefsWidCombo *addWidCombo( TDEConfigSkeleton::ItemEnum *item,
650 TQWidget *parent );
651
658 KPrefsWidString *addWidString( TDEConfigSkeleton::ItemString *item,
659 TQWidget *parent );
660
669 KPrefsWidPath *addWidPath ( TDEConfigSkeleton::ItemPath *item, TQWidget *parent,
670 const TQString &filter = TQString(),
671 uint mode = KFile::File );
672
679 KPrefsWidString *addWidPassword ( TDEConfigSkeleton::ItemString *item,
680 TQWidget *parent );
681
690 KPrefsWidFont *addWidFont( TDEConfigSkeleton::ItemFont *item,
691 TQWidget *parent, const TQString &sampleText );
692
694 void setWidDefaults();
695
697 void readWidConfig();
698
700 void writeWidConfig();
701
702 private:
703 TDEConfigSkeleton *mPrefs;
704
705 TQPtrList<KPrefsWid> mPrefsWids;
706};
707
708
721class TDE_EXPORT KPrefsDialog : public KDialogBase, public KPrefsWidManager
722{
723 TQ_OBJECT
724
725 public:
734 KPrefsDialog( TDEConfigSkeleton *prefs, TQWidget *parent = 0, char *name = 0,
735 bool modal = false );
739 virtual ~KPrefsDialog();
740
741 void autoCreate();
742
743 public slots:
745 void setDefaults();
746
748 void readConfig();
749
751 void writeConfig();
752
753 signals:
756
757 protected slots:
759 void slotApply();
760
762 void slotOk();
763
765 void slotDefault();
766
767 protected:
769 virtual void usrReadConfig() {}
771 virtual void usrWriteConfig() {}
772};
773
774
775class TDE_EXPORT KPrefsModule : public TDECModule, public KPrefsWidManager
776{
777 TQ_OBJECT
778
779 public:
780 KPrefsModule( TDEConfigSkeleton *, TQWidget *parent = 0, const char *name = 0 );
781
782 virtual void addWid( KPrefsWid * );
783
784 void load();
785 void save();
786 void defaults();
787
788 protected slots:
789 void slotWidChanged();
790
791 protected:
793 virtual void usrReadConfig() {}
795 virtual void usrWriteConfig() {}
796};
797
798#endif
A date editing widget that consists of an editable combo box.
Definition kdateedit.h:55
void slotApply()
Apply changes to preferences.
void readConfig()
Read preferences from config file.
void writeConfig()
Write preferences to config file.
virtual void usrReadConfig()
Implement this to read custom configuration widgets.
KPrefsDialog(TDEConfigSkeleton *prefs, TQWidget *parent=0, char *name=0, bool modal=false)
Create a KPrefsDialog for a KPrefs object.
void setDefaults()
Set all widgets to default values.
void slotOk()
Accept changes to preferences and close dialog.
void slotDefault()
Set preferences to default values.
void configChanged()
Emitted when the a changed configuration has been stored.
virtual void usrWriteConfig()
Implement this to write custom configuration widgets.
Widgets for bool settings in KPrefsDialog.
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 ...
KPrefsWidBool(TDEConfigSkeleton::ItemBool *item, TQWidget *parent)
Create a bool value control element consisting of a TQCheckbox.
TQCheckBox * checkBox()
Return the TQCheckbox used by this control element.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
Widgets for color settings in KPrefsDialog.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
KColorButton * button()
Return button opening the color dialog.
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...
TQLabel * label()
Return TQLabel for the button.
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.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
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(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Create a control element for selection of an option.
Widgets for time settings in KPrefsDialog.
KPrefsWidDate(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Create a time value control element consisting of a label and a date box.
TQLabel * label()
Return TQLabel used by this widget.
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.
KDateEdit * dateEdit()
Return TQSpinBox used by this widget.
Widgets for duration settings in KPrefsDialog.
TQLabel * label()
Return TQLabel used by this widget.
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.
TQTimeEdit * timeEdit()
Return TQSpinBox used by this widget.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
Widgets for font settings in KPrefsDialog.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
TQFrame * preview()
Return TQFrame used as preview field.
TQLabel * label()
Return TQLabel.
TQPushButton * button()
Return button opening the font dialog.
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...
Widgets for int settings in KPrefsDialog.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
TQLabel * label()
Return TQLabel used by this control element.
TQSpinBox * spinBox()
Return the TQSpinBox used by this control element.
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 ...
KPrefsWidInt(TDEConfigSkeleton::ItemInt *item, TQWidget *parent)
Create a integer value control element consisting of a label and a spinbox.
Class for managing KPrefsWid objects.
KPrefsWidDuration * addWidDuration(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Register a KPrefsWidDuration object.
KPrefsWidColor * addWidColor(TDEConfigSkeleton::ItemColor *item, TQWidget *parent)
Register a KPrefsWidColor object.
KPrefsWidString * addWidString(TDEConfigSkeleton::ItemString *item, TQWidget *parent)
Register a KPrefsWidString object.
KPrefsWidRadios * addWidRadios(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Register a KPrefsWidRadios object.
KPrefsWidTime * addWidTime(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Register a KPrefsWidTime object.
KPrefsWidFont * addWidFont(TDEConfigSkeleton::ItemFont *item, TQWidget *parent, const TQString &sampleText)
Register a KPrefsWidFont object.
KPrefsWidPath * addWidPath(TDEConfigSkeleton::ItemPath *item, TQWidget *parent, const TQString &filter=TQString(), uint mode=KFile::File)
Register a path KPrefsWidPath object.
KPrefsWidBool * addWidBool(TDEConfigSkeleton::ItemBool *item, TQWidget *parent)
Register a KPrefsWidBool object.
void setWidDefaults()
Set all widgets to default values.
KPrefsWidCombo * addWidCombo(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Register a KPrefsWidCombo object.
KPrefsWidManager(TDEConfigSkeleton *prefs)
Create a KPrefsWidManager object for a KPrefs object.
virtual void addWid(KPrefsWid *)
Register a custom KPrefsWid object.
KPrefsWidDate * addWidDate(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Register a KPrefsWidDate object.
void writeWidConfig()
Write preferences to config file.
KPrefsWidString * addWidPassword(TDEConfigSkeleton::ItemString *item, TQWidget *parent)
Register a password KPrefsWidString object, with echomode set to TQLineEdit::Password.
KPrefsWidInt * addWidInt(TDEConfigSkeleton::ItemInt *item, TQWidget *parent)
Register a KPrefsWidInt object.
void readWidConfig()
Read preferences from config file.
Widgets for string settings in KPrefsDialog.
KURLRequester * urlRequester()
Return TQLineEdit used by this widget.
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.
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.
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
TQLabel * label()
Return TQLabel used by this widget.
Widgets for settings represented by a group of radio buttons in KPrefsDialog.
void addRadio(const TQString &text, const TQString &whatsThis=TQString())
Add a radio button.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
KPrefsWidRadios(TDEConfigSkeleton::ItemEnum *item, TQWidget *parent)
Create a control element for selection of an option.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
TQButtonGroup * groupBox()
Return the box widget used by this widget.
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
Widgets for string settings in KPrefsDialog.
void writeConfig()
This function is called to write the current setting of the widget to the stored configuration.
void readConfig()
This function is called to read value of the setting from the stored configuration and display it in ...
TQLineEdit * lineEdit()
Return TQLineEdit used by this widget.
TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
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.
TQLabel * label()
Return TQLabel used by this widget.
Widgets for time settings in KPrefsDialog.
KPrefsWidTime(TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent)
Create a time value control element consisting of a label and a spinbox.
TQLabel * label()
Return TQLabel used by this widget.
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.
KTimeEdit * timeEdit()
Return TQSpinBox used by this widget.
Base class for GUI control elements used by KPrefsDialog.
virtual TQValueList< TQWidget * > widgets() const
Return a list of widgets used by this control element.
void changed()
Emitted when widget value has changed.
virtual void writeConfig()=0
This function is called to write the current setting of the widget to the stored configuration.
virtual void readConfig()=0
This function is called to read value of the setting from the stored configuration and display it in ...
This is a class that provides an easy, user friendly way to edit times.
Definition ktimeedit.h:45