kalarm

prefdlg.h

00001 /*
00002  *  prefdlg.h  -  program preferences dialog
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2007 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         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            mXtermCount;              // number of terminal window types
00144 };
00145 
00146 
00147 // Email tab of the Preferences dialog
00148 class EmailPrefTab : public PrefsTabBase
00149 {
00150         Q_OBJECT
00151     public:
00152         EmailPrefTab(QVBox*);
00153 
00154         QString      validate();
00155         virtual void restore();
00156         virtual void apply(bool syncToDisc);
00157         virtual void setDefaults();
00158 
00159     private slots:
00160         void         slotEmailClientChanged(int);
00161         void         slotFromAddrChanged(int);
00162         void         slotBccAddrChanged(int);
00163         void         slotAddressChanged()    { mAddressChanged = true; }
00164 
00165     private:
00166         void         setEmailAddress(Preferences::MailFrom, const QString& address);
00167         void         setEmailBccAddress(bool useControlCentre, const QString& address);
00168         QString      validateAddr(ButtonGroup*, QLineEdit* addr, const QString& msg);
00169 
00170         ButtonGroup*   mEmailClient;
00171         ButtonGroup*   mFromAddressGroup;
00172         QLineEdit*     mEmailAddress;
00173         ButtonGroup*   mBccAddressGroup;
00174         QLineEdit*     mEmailBccAddress;
00175         QCheckBox*     mEmailQueuedNotify;
00176         QCheckBox*     mEmailCopyToKMail;
00177         bool           mAddressChanged;
00178         bool           mBccAddressChanged;
00179 };
00180 
00181 
00182 // Edit defaults tab of the Preferences dialog
00183 class EditPrefTab : public PrefsTabBase
00184 {
00185         Q_OBJECT
00186     public:
00187         EditPrefTab(QVBox*);
00188 
00189         QString      validate();
00190         virtual void restore();
00191         virtual void apply(bool syncToDisc);
00192         virtual void setDefaults();
00193 
00194     private slots:
00195         void         slotBrowseSoundFile();
00196 
00197     private:
00198         QCheckBox*      mAutoClose;
00199         QCheckBox*      mConfirmAck;
00200         QComboBox*      mReminderUnits;
00201         SpecialActionsButton* mSpecialActionsButton;
00202         QCheckBox*      mCmdScript;
00203         QCheckBox*      mCmdXterm;
00204         QCheckBox*      mEmailBcc;
00205         QComboBox*      mSound;
00206         QLabel*         mSoundFileLabel;
00207         QLineEdit*      mSoundFile;
00208         QPushButton*    mSoundFileBrowse;
00209         QCheckBox*      mSoundRepeat;
00210         QCheckBox*      mCopyToKOrganizer;
00211         QCheckBox*      mLateCancel;
00212         QComboBox*      mRecurPeriod;
00213         QButtonGroup*   mFeb29;
00214 
00215         static int soundIndex(SoundPicker::Type);
00216         static int recurIndex(RecurrenceEdit::RepeatType);
00217 };
00218 
00219 
00220 // View tab of the Preferences dialog
00221 class ViewPrefTab : public PrefsTabBase
00222 {
00223         Q_OBJECT
00224     public:
00225         ViewPrefTab(QVBox*);
00226 
00227         virtual void restore();
00228         virtual void apply(bool syncToDisc);
00229         virtual void setDefaults();
00230 
00231     private slots:
00232         void         slotListTimeToggled(bool);
00233         void         slotListTimeToToggled(bool);
00234         void         slotTooltipAlarmsToggled(bool);
00235         void         slotTooltipMaxToggled(bool);
00236         void         slotTooltipTimeToggled(bool);
00237         void         slotTooltipTimeToToggled(bool);
00238 
00239     private:
00240         void         setList(bool time, bool timeTo);
00241         void         setTooltip(int maxAlarms, bool time, bool timeTo, const QString& prefix);
00242 
00243         QCheckBox*     mListShowTime;
00244         QCheckBox*     mListShowTimeTo;
00245         QCheckBox*     mTooltipShowAlarms;
00246         QCheckBox*     mTooltipMaxAlarms;
00247         SpinBox*       mTooltipMaxAlarmCount;
00248         QCheckBox*     mTooltipShowTime;
00249         QCheckBox*     mTooltipShowTimeTo;
00250         QLineEdit*     mTooltipTimeToPrefix;
00251         QLabel*        mTooltipTimeToPrefixLabel;
00252         QCheckBox*     mModalMessages;
00253         QCheckBox*     mShowExpiredAlarms;
00254         SpinBox*       mDaemonTrayCheckInterval;
00255 };
00256 
00257 
00258 // Font & Colour tab of the Preferences dialog
00259 class FontColourPrefTab : public PrefsTabBase
00260 {
00261         Q_OBJECT
00262     public:
00263         FontColourPrefTab(QVBox*);
00264 
00265         virtual void restore();
00266         virtual void apply(bool syncToDisc);
00267         virtual void setDefaults();
00268 
00269     private:
00270         FontColourChooser*  mFontChooser;
00271         KColorCombo*        mDisabledColour;
00272         KColorCombo*        mExpiredColour;
00273 };
00274 
00275 #endif // PREFDLG_H
KDE Home | KDE Accessibility Home | Description of Access Keys