kalarm

prefdlg.h

00001 /*
00002  *  prefdlg.h  -  program preferences dialog
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2007 by David Jarvie <djarvie@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef PREFDLG_H
00022 #define PREFDLG_H
00023 
00024 #include <qsize.h>
00025 #include <qdatetime.h>
00026 #include <ktabctl.h>
00027 #include <kdialogbase.h>
00028 
00029 #include "preferences.h"
00030 #include "recurrenceedit.h"
00031 #include "soundpicker.h"
00032 
00033 class QButtonGroup;
00034 class QCheckBox;
00035 class QRadioButton;
00036 class QPushButton;
00037 class QComboBox;
00038 class QLineEdit;
00039 class KColorCombo;
00040 class FontColourChooser;
00041 class ButtonGroup;
00042 class TimeEdit;
00043 class SpinBox;
00044 class SpecialActionsButton;
00045 
00046 class FontColourPrefTab;
00047 class EditPrefTab;
00048 class EmailPrefTab;
00049 class ViewPrefTab;
00050 class MiscPrefTab;
00051 
00052 
00053 // The Preferences dialog
00054 class KAlarmPrefDlg : public KDialogBase
00055 {
00056         Q_OBJECT
00057     public:
00058         static void display();
00059         ~KAlarmPrefDlg();
00060 
00061         FontColourPrefTab* mFontColourPage;
00062         EditPrefTab*       mEditPage;
00063         EmailPrefTab*      mEmailPage;
00064         ViewPrefTab*       mViewPage;
00065         MiscPrefTab*       mMiscPage;
00066 
00067     protected slots:
00068         virtual void slotOk();
00069         virtual void slotApply();
00070         virtual void slotHelp();
00071         virtual void slotDefault();
00072         virtual void slotCancel();
00073 
00074     private:
00075         KAlarmPrefDlg();
00076         void            restore();
00077 
00078         static KAlarmPrefDlg* mInstance;
00079         bool            mValid;
00080 };
00081 
00082 // Base class for each tab in the Preferences dialog
00083 class PrefsTabBase : public QWidget
00084 {
00085         Q_OBJECT
00086     public:
00087         PrefsTabBase(QVBox*);
00088 
00089         void         setPreferences();
00090         virtual void restore() = 0;
00091         virtual void apply(bool syncToDisc) = 0;
00092         virtual void setDefaults() = 0;
00093         static int   indentWidth()    { return mIndentWidth; }
00094 
00095     protected:
00096         QVBox*       mPage;
00097 
00098     private:
00099         static int   mIndentWidth;       // indent width for checkboxes etc.
00100 };
00101 
00102 
00103 // Miscellaneous tab of the Preferences dialog
00104 class MiscPrefTab : public PrefsTabBase
00105 {
00106         Q_OBJECT
00107     public:
00108         MiscPrefTab(QVBox*);
00109 
00110         virtual void restore();
00111         virtual void apply(bool syncToDisc);
00112         virtual void setDefaults();
00113 
00114     private slots:
00115         void         slotAutostartDaemonClicked();
00116         void         slotRunModeToggled(bool);
00117         void         slotDisableIfStoppedToggled(bool);
00118         void         slotExpiredToggled(bool);
00119         void         slotClearExpired();
00120         void         slotOtherTerminalToggled(bool);
00121 //#ifdef AUTOSTART_BY_KALARMD
00122         void         slotAutostartToggled(bool);
00123 //#endif
00124 
00125     private:
00126         void         setExpiredControls(int purgeDays);
00127 
00128         QCheckBox*     mAutostartDaemon;
00129         QRadioButton*  mRunInSystemTray;
00130         QRadioButton*  mRunOnDemand;
00131         QCheckBox*     mDisableAlarmsIfStopped;
00132         QCheckBox*     mQuitWarn;
00133         QCheckBox*     mAutostartTrayIcon;
00134         QCheckBox*     mConfirmAlarmDeletion;
00135         QCheckBox*     mKeepExpired;
00136         QCheckBox*     mPurgeExpired;
00137         SpinBox*       mPurgeAfter;
00138         QLabel*        mPurgeAfterLabel;
00139         QPushButton*   mClearExpired;
00140         TimeEdit*      mStartOfDay;
00141         QButtonGroup*  mXtermType;
00142         QLineEdit*     mXtermCommand;
00143         int            mXtermFirst;              // id of first terminal window radio button
00144         int            mXtermCount;              // number of terminal window types
00145 };
00146 
00147 
00148 // Email tab of the Preferences dialog
00149 class EmailPrefTab : public PrefsTabBase
00150 {
00151         Q_OBJECT
00152     public:
00153         EmailPrefTab(QVBox*);
00154 
00155         QString      validate();
00156         virtual void restore();
00157         virtual void apply(bool syncToDisc);
00158         virtual void setDefaults();
00159 
00160     private slots:
00161         void         slotEmailClientChanged(int);
00162         void         slotFromAddrChanged(int);
00163         void         slotBccAddrChanged(int);
00164         void         slotAddressChanged()    { mAddressChanged = true; }
00165 
00166     private:
00167         void         setEmailAddress(Preferences::MailFrom, const QString& address);
00168         void         setEmailBccAddress(bool useControlCentre, const QString& address);
00169         QString      validateAddr(ButtonGroup*, QLineEdit* addr, const QString& msg);
00170 
00171         ButtonGroup*   mEmailClient;
00172         ButtonGroup*   mFromAddressGroup;
00173         QLineEdit*     mEmailAddress;
00174         ButtonGroup*   mBccAddressGroup;
00175         QLineEdit*     mEmailBccAddress;
00176         QCheckBox*     mEmailQueuedNotify;
00177         QCheckBox*     mEmailCopyToKMail;
00178         bool           mAddressChanged;
00179         bool           mBccAddressChanged;
00180 };
00181 
00182 
00183 // Edit defaults tab of the Preferences dialog
00184 class EditPrefTab : public PrefsTabBase
00185 {
00186         Q_OBJECT
00187     public:
00188         EditPrefTab(QVBox*);
00189 
00190         QString      validate();
00191         virtual void restore();
00192         virtual void apply(bool syncToDisc);
00193         virtual void setDefaults();
00194 
00195     private slots:
00196         void         slotBrowseSoundFile();
00197 
00198     private:
00199         QCheckBox*      mAutoClose;
00200         QCheckBox*      mConfirmAck;
00201         QComboBox*      mReminderUnits;
00202         SpecialActionsButton* mSpecialActionsButton;
00203         QCheckBox*      mCmdScript;
00204         QCheckBox*      mCmdXterm;
00205         QCheckBox*      mEmailBcc;
00206         QComboBox*      mSound;
00207         QLabel*         mSoundFileLabel;
00208         QLineEdit*      mSoundFile;
00209         QPushButton*    mSoundFileBrowse;
00210         QCheckBox*      mSoundRepeat;
00211         QCheckBox*      mCopyToKOrganizer;
00212         QCheckBox*      mLateCancel;
00213         QComboBox*      mRecurPeriod;
00214         QButtonGroup*   mFeb29;
00215 
00216         static int soundIndex(SoundPicker::Type);
00217         static int recurIndex(RecurrenceEdit::RepeatType);
00218 };
00219 
00220 
00221 // View tab of the Preferences dialog
00222 class ViewPrefTab : public PrefsTabBase
00223 {
00224         Q_OBJECT
00225     public:
00226         ViewPrefTab(QVBox*);
00227 
00228         virtual void restore();
00229         virtual void apply(bool syncToDisc);
00230         virtual void setDefaults();
00231 
00232     private slots:
00233         void         slotTooltipAlarmsToggled(bool);
00234         void         slotTooltipMaxToggled(bool);
00235         void         slotTooltipTimeToggled(bool);
00236         void         slotTooltipTimeToToggled(bool);
00237 
00238     private:
00239         void         setTooltip(int maxAlarms, bool time, bool timeTo, const QString& prefix);
00240 
00241         QCheckBox*     mTooltipShowAlarms;
00242         QCheckBox*     mTooltipMaxAlarms;
00243         SpinBox*       mTooltipMaxAlarmCount;
00244         QCheckBox*     mTooltipShowTime;
00245         QCheckBox*     mTooltipShowTimeTo;
00246         QLineEdit*     mTooltipTimeToPrefix;
00247         QLabel*        mTooltipTimeToPrefixLabel;
00248         QCheckBox*     mModalMessages;
00249         SpinBox*       mDaemonTrayCheckInterval;
00250 };
00251 
00252 
00253 // Font & Colour tab of the Preferences dialog
00254 class FontColourPrefTab : public PrefsTabBase
00255 {
00256         Q_OBJECT
00257     public:
00258         FontColourPrefTab(QVBox*);
00259 
00260         virtual void restore();
00261         virtual void apply(bool syncToDisc);
00262         virtual void setDefaults();
00263 
00264     private:
00265         FontColourChooser*  mFontChooser;
00266         KColorCombo*        mDisabledColour;
00267         KColorCombo*        mExpiredColour;
00268 };
00269 
00270 #endif // PREFDLG_H
KDE Home | KDE Accessibility Home | Description of Access Keys