kalarm

prefdlg.h

00001 /*
00002  *  prefdlg.h  -  program preferences dialog
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2006 by David Jarvie <software@astrojar.org.uk>
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         KAlarmPrefDlg();
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         void            restore();
00076         bool            mValid;
00077 };
00078 
00079 // Base class for each tab in the Preferences dialog
00080 class PrefsTabBase : public QWidget
00081 {
00082         Q_OBJECT
00083     public:
00084         PrefsTabBase(QVBox*);
00085 
00086         void         setPreferences();
00087         virtual void restore() = 0;
00088         virtual void apply(bool syncToDisc) = 0;
00089         virtual void setDefaults() = 0;
00090         static int   indentWidth()    { return mIndentWidth; }
00091 
00092     protected:
00093         QVBox*       mPage;
00094 
00095     private:
00096         static int   mIndentWidth;       // indent width for checkboxes etc.
00097 };
00098 
00099 
00100 // Miscellaneous tab of the Preferences dialog
00101 class MiscPrefTab : public PrefsTabBase
00102 {
00103         Q_OBJECT
00104     public:
00105         MiscPrefTab(QVBox*);
00106 
00107         virtual void restore();
00108         virtual void apply(bool syncToDisc);
00109         virtual void setDefaults();
00110 
00111     private slots:
00112         void         slotAutostartDaemonClicked();
00113         void         slotRunModeToggled(bool);
00114         void         slotDisableIfStoppedToggled(bool);
00115         void         slotExpiredToggled(bool);
00116         void         slotClearExpired();
00117         void         slotOtherTerminalToggled(bool);
00118 //#ifdef AUTOSTART_BY_KALARMD
00119         void         slotAutostartToggled(bool);
00120 //#endif
00121 
00122     private:
00123         void         setExpiredControls(int purgeDays);
00124 
00125         QCheckBox*     mAutostartDaemon;
00126         QRadioButton*  mRunInSystemTray;
00127         QRadioButton*  mRunOnDemand;
00128         QCheckBox*     mDisableAlarmsIfStopped;
00129         QCheckBox*     mQuitWarn;
00130         QCheckBox*     mAutostartTrayIcon;
00131         QCheckBox*     mConfirmAlarmDeletion;
00132         QCheckBox*     mKeepExpired;
00133         QCheckBox*     mPurgeExpired;
00134         SpinBox*       mPurgeAfter;
00135         QLabel*        mPurgeAfterLabel;
00136         QPushButton*   mClearExpired;
00137         TimeEdit*      mStartOfDay;
00138         QButtonGroup*  mXtermType;
00139         QLineEdit*     mXtermCommand;
00140         int            mXtermCount;              // number of terminal window types
00141 };
00142 
00143 
00144 // Email tab of the Preferences dialog
00145 class EmailPrefTab : public PrefsTabBase
00146 {
00147         Q_OBJECT
00148     public:
00149         EmailPrefTab(QVBox*);
00150 
00151         QString      validate();
00152         virtual void restore();
00153         virtual void apply(bool syncToDisc);
00154         virtual void setDefaults();
00155 
00156     private slots:
00157         void         slotEmailClientChanged(int);
00158         void         slotFromAddrChanged(int);
00159         void         slotBccAddrChanged(int);
00160         void         slotAddressChanged()    { mAddressChanged = true; }
00161 
00162     private:
00163         void         setEmailAddress(Preferences::MailFrom, const QString& address);
00164         void         setEmailBccAddress(bool useControlCentre, const QString& address);
00165         QString      validateAddr(ButtonGroup*, QLineEdit* addr, const QString& msg);
00166 
00167         ButtonGroup*   mEmailClient;
00168         ButtonGroup*   mFromAddressGroup;
00169         QLineEdit*     mEmailAddress;
00170         ButtonGroup*   mBccAddressGroup;
00171         QLineEdit*     mEmailBccAddress;
00172         QCheckBox*     mEmailQueuedNotify;
00173         QCheckBox*     mEmailCopyToKMail;
00174         bool           mAddressChanged;
00175         bool           mBccAddressChanged;
00176 };
00177 
00178 
00179 // Edit defaults tab of the Preferences dialog
00180 class EditPrefTab : public PrefsTabBase
00181 {
00182         Q_OBJECT
00183     public:
00184         EditPrefTab(QVBox*);
00185 
00186         QString      validate();
00187         virtual void restore();
00188         virtual void apply(bool syncToDisc);
00189         virtual void setDefaults();
00190 
00191     private slots:
00192         void         slotBrowseSoundFile();
00193 
00194     private:
00195         QCheckBox*      mAutoClose;
00196         QCheckBox*      mConfirmAck;
00197         QComboBox*      mReminderUnits;
00198         SpecialActionsButton* mSpecialActionsButton;
00199         QCheckBox*      mCmdScript;
00200         QCheckBox*      mCmdXterm;
00201         QCheckBox*      mEmailBcc;
00202         QComboBox*      mSound;
00203         QLabel*         mSoundFileLabel;
00204         QLineEdit*      mSoundFile;
00205         QPushButton*    mSoundFileBrowse;
00206         QCheckBox*      mSoundRepeat;
00207         QCheckBox*      mCopyToKOrganizer;
00208         QCheckBox*      mLateCancel;
00209         QComboBox*      mRecurPeriod;
00210         QButtonGroup*   mFeb29;
00211 
00212         static int soundIndex(SoundPicker::Type);
00213         static int recurIndex(RecurrenceEdit::RepeatType);
00214 };
00215 
00216 
00217 // View tab of the Preferences dialog
00218 class ViewPrefTab : public PrefsTabBase
00219 {
00220         Q_OBJECT
00221     public:
00222         ViewPrefTab(QVBox*);
00223 
00224         virtual void restore();
00225         virtual void apply(bool syncToDisc);
00226         virtual void setDefaults();
00227 
00228     private slots:
00229         void         slotListTimeToggled(bool);
00230         void         slotListTimeToToggled(bool);
00231         void         slotTooltipAlarmsToggled(bool);
00232         void         slotTooltipMaxToggled(bool);
00233         void         slotTooltipTimeToggled(bool);
00234         void         slotTooltipTimeToToggled(bool);
00235 
00236     private:
00237         void         setList(bool time, bool timeTo);
00238         void         setTooltip(int maxAlarms, bool time, bool timeTo, const QString& prefix);
00239 
00240         QCheckBox*     mListShowTime;
00241         QCheckBox*     mListShowTimeTo;
00242         QCheckBox*     mTooltipShowAlarms;
00243         QCheckBox*     mTooltipMaxAlarms;
00244         SpinBox*       mTooltipMaxAlarmCount;
00245         QCheckBox*     mTooltipShowTime;
00246         QCheckBox*     mTooltipShowTimeTo;
00247         QLineEdit*     mTooltipTimeToPrefix;
00248         QLabel*        mTooltipTimeToPrefixLabel;
00249         QCheckBox*     mModalMessages;
00250         QCheckBox*     mShowExpiredAlarms;
00251         SpinBox*       mDaemonTrayCheckInterval;
00252 };
00253 
00254 
00255 // Font & Colour tab of the Preferences dialog
00256 class FontColourPrefTab : public PrefsTabBase
00257 {
00258         Q_OBJECT
00259     public:
00260         FontColourPrefTab(QVBox*);
00261 
00262         virtual void restore();
00263         virtual void apply(bool syncToDisc);
00264         virtual void setDefaults();
00265 
00266     private:
00267         FontColourChooser*  mFontChooser;
00268         KColorCombo*        mDisabledColour;
00269         KColorCombo*        mExpiredColour;
00270 };
00271 
00272 #endif // PREFDLG_H
KDE Home | KDE Accessibility Home | Description of Access Keys