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 
38 class KColorButton;
39 class TQCheckBox;
40 class TQComboBox;
41 class TQLabel;
42 class TQSpinBox;
43 class TQButtonGroup;
44 class TQTimeEdit;
45 class KTimeEdit;
46 class KDateEdit;
47 class KURLRequester;
48 
58 class 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 
92 class 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 
126 class 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 
167 class TDE_EXPORT KPrefsWidTime : public KPrefsWid
168 {
169  public:
176  KPrefsWidTime( TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent );
177 
181  TQLabel *label();
185  KTimeEdit *timeEdit();
186 
187  void readConfig();
188  void writeConfig();
189 
190  private:
191  TDEConfigSkeleton::ItemDateTime *mItem;
192 
193  TQLabel *mLabel;
194  KTimeEdit *mTimeEdit;
195 };
196 
204 class 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 
242 class TDE_EXPORT KPrefsWidDate : public KPrefsWid
243 {
244  public:
251  KPrefsWidDate( TDEConfigSkeleton::ItemDateTime *item, TQWidget *parent );
252 
256  TQLabel *label();
260  KDateEdit *dateEdit();
261 
262  void readConfig();
263  void writeConfig();
264 
265  private:
266  TDEConfigSkeleton::ItemDateTime *mItem;
267 
268  TQLabel *mLabel;
269  KDateEdit *mDateEdit;
270 };
271 
279 class TDE_EXPORT KPrefsWidColor : public KPrefsWid
280 {
281  TQ_OBJECT
282 
283  public:
291  KPrefsWidColor( TDEConfigSkeleton::ItemColor *item, TQWidget *parent );
295  ~KPrefsWidColor();
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 
322 class TDE_EXPORT KPrefsWidFont : public KPrefsWid
323 {
324  TQ_OBJECT
325 
326  public:
335  KPrefsWidFont( TDEConfigSkeleton::ItemFont *item,
336  TQWidget *parent, const TQString &sampleText );
340  ~KPrefsWidFont();
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 
380 class 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 
428 class 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 
461 class 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 
508 class 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 
557 class 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 
721 class 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 
775 class 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
Base class for a preferences dialog.
Definition: kprefsdialog.h:722
virtual void usrReadConfig()
Implement this to read custom configuration widgets.
Definition: kprefsdialog.h:769
void configChanged()
Emitted when the a changed configuration has been stored.
virtual void usrWriteConfig()
Implement this to write custom configuration widgets.
Definition: kprefsdialog.h:771
Widgets for bool settings in KPrefsDialog.
Definition: kprefsdialog.h:93
Widgets for color settings in KPrefsDialog.
Definition: kprefsdialog.h:280
Widgets for settings represented by a combo box in KPrefsDialog.
Definition: kprefsdialog.h:429
Widgets for time settings in KPrefsDialog.
Definition: kprefsdialog.h:243
Widgets for duration settings in KPrefsDialog.
Definition: kprefsdialog.h:205
Widgets for font settings in KPrefsDialog.
Definition: kprefsdialog.h:323
Widgets for int settings in KPrefsDialog.
Definition: kprefsdialog.h:127
Class for managing KPrefsWid objects.
Definition: kprefsdialog.h:558
Widgets for string settings in KPrefsDialog.
Definition: kprefsdialog.h:509
Widgets for settings represented by a group of radio buttons in KPrefsDialog.
Definition: kprefsdialog.h:381
Widgets for string settings in KPrefsDialog.
Definition: kprefsdialog.h:462
Widgets for time settings in KPrefsDialog.
Definition: kprefsdialog.h:168
Base class for GUI control elements used by KPrefsDialog.
Definition: kprefsdialog.h:59
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