kalarm

editdlg.h

00001 /*
00002  *  editdlg.h  -  dialogue to create or modify an alarm or alarm template
00003  *  Program:  kalarm
00004  *  Copyright (C) 2001 - 2005 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 EDITDLG_H
00022 #define EDITDLG_H
00023 
00024 #include <qdatetime.h>
00025 #include <qlineedit.h>
00026 
00027 #include <kdialogbase.h>
00028 
00029 #include "alarmevent.h"
00030 #include "alarmtext.h"
00031 #include "datetime.h"
00032 #include "soundpicker.h"
00033 
00034 class QButton;
00035 class QGroupBox;
00036 class QComboBox;
00037 class QTabWidget;
00038 class QVBox;
00039 class QHBox;
00040 class EmailIdCombo;
00041 class ColourCombo;
00042 class FontColourButton;
00043 class ButtonGroup;
00044 class TimeEdit;
00045 class RadioButton;
00046 class CheckBox;
00047 class LateCancelSelector;
00048 class AlarmTimeWidget;
00049 class RecurrenceEdit;
00050 class Reminder;
00051 class SpecialActionsButton;
00052 class RepetitionButton;
00053 class TimeSpinBox;
00054 class LineEdit;
00055 class TextEdit;
00056 class PickAlarmFileRadio;
00057 
00058 
00059 class EditAlarmDlg : public KDialogBase
00060 {
00061         Q_OBJECT
00062     public:
00063         enum MessageType { MESSAGE, FILE };
00064         enum CmdLogType { DISCARD_OUTPUT, LOG_TO_FILE, EXEC_IN_TERMINAL };
00065 
00066         EditAlarmDlg(bool Template, const QString& caption, QWidget* parent = 0, const char* name = 0,
00067                      const KAEvent* = 0, bool readOnly = false);
00068         virtual ~EditAlarmDlg();
00069         bool            getEvent(KAEvent&);
00070         void            setAction(KAEvent::Action, const AlarmText& = AlarmText());
00071 
00072         static ColourCombo* createBgColourChooser(QHBox** box, QWidget* parent, const char* name = 0);
00073         static CheckBox*    createConfirmAckCheckbox(QWidget* parent, const char* name = 0);
00074 
00075         static QString  i18n_ConfirmAck();         // plain text of 'Confirm acknowledgement' checkbox
00076         static QString  i18n_k_ConfirmAck();       // text of 'Confirm acknowledgement' checkbox, with 'k' shortcut
00077         static QString  i18n_ShowInKOrganizer();   // plain text of 'Show in KOrganizer' checkbox
00078         static QString  i18n_g_ShowInKOrganizer(); // text of 'Show in KOrganizer' checkbox, with 'G' shortcut
00079         static QString  i18n_EnterScript();        // plain text of 'Enter a script' checkbox
00080         static QString  i18n_p_EnterScript();      // text of 'Enter a script' checkbox, with 'P' shortcut
00081         static QString  i18n_ExecInTermWindow();   // plain text of 'Execute in terminal window' checkbox
00082         static QString  i18n_w_ExecInTermWindow(); // text of 'Execute in terminal window' radio button, with 'W' shortcut
00083         static QString  i18n_u_ExecInTermWindow(); // text of 'Execute in terminal window' radio button, with 'U' shortcut
00084         static QString  i18n_g_LogToFile();        // text of 'Log to file' radio button, with 'G' shortcut
00085         static QString  i18n_CopyEmailToSelf();    // plain text of 'Copy email to self' checkbox
00086         static QString  i18n_e_CopyEmailToSelf();  // text of 'Copy email to self' checkbox, with 'E' shortcut
00087         static QString  i18n_s_CopyEmailToSelf();  // text of 'Copy email to self' checkbox, with 'S' shortcut
00088         static QString  i18n_EmailFrom();          // plain text of 'From:' (email address)
00089         static QString  i18n_f_EmailFrom();        // text of 'From:' (email address), with 'F' shortcut
00090         static QString  i18n_EmailTo();            // plain text of 'To:' (email addressee)
00091         static QString  i18n_EmailSubject();       // plain text of 'Subject:' (email)
00092         static QString  i18n_j_EmailSubject();     // text of 'Subject:' (email), with 'J' shortcut
00093 
00094     protected:
00095         virtual void    resizeEvent(QResizeEvent*);
00096         virtual void    showEvent(QShowEvent*);
00097     protected slots:
00098         virtual void    slotOk();
00099         virtual void    slotCancel();
00100         virtual void    slotTry();
00101         virtual void    slotDefault();   // Load Template
00102     private slots:
00103         void            slotRecurTypeChange(int repeatType);
00104         void            slotRecurFrequencyChange();
00105         void            slotAlarmTypeChanged(int id);
00106         void            slotEditDeferral();
00107         void            slotFontColourSelected();
00108         void            slotBgColourSelected(const QColor&);
00109         void            openAddressBook();
00110         void            slotAddAttachment();
00111         void            slotRemoveAttachment();
00112         void            slotShowMainPage();
00113         void            slotShowRecurrenceEdit();
00114         void            slotAnyTimeToggled(bool anyTime);
00115         void            slotTemplateTimeType(int id);
00116         void            slotSetSimpleRepetition();
00117         void            slotCmdScriptToggled(bool);
00118 
00119     private:
00120         void            initialise(const KAEvent*);
00121         void            setReadOnly();
00122         void            setEvent(KAEvent&, const QString& text, bool trial);
00123         KAEvent::Action getAlarmType() const;
00124         int             getAlarmFlags() const;
00125         bool            checkText(QString& result, bool showErrorMessage = true) const;
00126         void            setSoundPicker();
00127         void            setRecurTabTitle(const KAEvent* = 0);
00128         bool            checkCommandData();
00129         bool            checkEmailData();
00130 
00131         void            initDisplayAlarms(QWidget* parent);
00132         void            initCommand(QWidget* parent);
00133         void            initEmail(QWidget* parent);
00134         void            saveState(const KAEvent*);
00135         bool            stateChanged() const;
00136 
00137         QTabWidget*         mTabs;                // the tabs in the dialog
00138         int                 mMainPageIndex;
00139         int                 mRecurPageIndex;
00140         bool                mMainPageShown;            // true once the main tab has been displayed
00141         bool                mRecurPageShown;           // true once the recurrence tab has been displayed
00142         bool                mRecurSetDefaultEndDate;   // adjust default end date/time when recurrence tab is displayed
00143 
00144         ButtonGroup*        mActionGroup;
00145         RadioButton*        mMessageRadio;
00146         RadioButton*        mCommandRadio;
00147         PickAlarmFileRadio* mFileRadio;
00148         RadioButton*        mEmailRadio;
00149         QWidgetStack*       mAlarmTypeStack;
00150 
00151         // Templates
00152         QLineEdit*          mTemplateName;
00153         ButtonGroup*        mTemplateTimeGroup;
00154         RadioButton*        mTemplateDefaultTime; // no alarm time is specified
00155         RadioButton*        mTemplateUseTimeAfter;// alarm time is specified as an offset from current
00156         RadioButton*        mTemplateAnyTime;     // alarms have date only, no time
00157         RadioButton*        mTemplateUseTime;     // an alarm time is specified
00158         TimeSpinBox*        mTemplateTimeAfter;   // the specified offset from the current time
00159         TimeEdit*           mTemplateTime;        // the alarm time which is specified
00160 
00161         // Display alarm options widgets
00162         QFrame*             mDisplayAlarmsFrame;
00163         QHBox*              mFileBox;
00164         QHBox*              mFilePadding;
00165         SoundPicker*        mSoundPicker;
00166         CheckBox*           mConfirmAck;
00167         FontColourButton*   mFontColourButton;
00168         ColourCombo*        mBgColourChoose;
00169         SpecialActionsButton* mSpecialActionsButton;
00170         Reminder*           mReminder;
00171         bool                mReminderDeferral;
00172         bool                mReminderArchived;
00173         // Text message alarm widgets
00174         TextEdit*           mTextMessageEdit;    // text message edit box
00175         // Text file alarm widgets
00176         LineEdit*           mFileMessageEdit;    // text file URL edit box
00177         QPushButton*        mFileBrowseButton;   // text file browse button
00178         QString             mFileDefaultDir;     // default directory for browse button
00179         // Command alarm widgets
00180         QFrame*             mCommandFrame;
00181         CheckBox*           mCmdTypeScript;      // entering a script
00182         LineEdit*           mCmdCommandEdit;     // command line edit box
00183         TextEdit*           mCmdScriptEdit;      // script edit box
00184         ButtonGroup*        mCmdOutputGroup;     // what to do with command output
00185         LineEdit*           mCmdLogFileEdit;     // log file URL edit box
00186         QWidget*            mCmdPadding;
00187         // Email alarm widgets
00188         QFrame*             mEmailFrame;
00189         EmailIdCombo*       mEmailFromList;
00190         LineEdit*           mEmailToEdit;
00191         QPushButton*        mEmailAddressButton; // email open address book button
00192         QLineEdit*          mEmailSubjectEdit;
00193         TextEdit*           mEmailMessageEdit;   // email body edit box
00194         QComboBox*          mEmailAttachList;
00195         QPushButton*        mEmailAddAttachButton;
00196         QPushButton*        mEmailRemoveButton;
00197         CheckBox*           mEmailBcc;
00198         QString             mAttachDefaultDir;
00199 
00200         QGroupBox*          mDeferGroup;
00201         QLabel*             mDeferTimeLabel;
00202         QPushButton*        mDeferChangeButton;
00203 
00204         AlarmTimeWidget*    mTimeWidget;
00205         LateCancelSelector* mLateCancel;
00206         CheckBox*           mShowInKorganizer;
00207 
00208         RepetitionButton*   mSimpleRepetition;
00209         QLabel*             mRecurrenceText;
00210         RecurrenceEdit*     mRecurrenceEdit;
00211 
00212         QString             mAlarmMessage;       // message text/file name/command/email message
00213         DateTime            mAlarmDateTime;
00214         DateTime            mDeferDateTime;
00215         EmailAddressList    mEmailAddresses;     // list of addresses to send email to
00216         QStringList         mEmailAttachments;   // list of email attachment file names
00217         unsigned long       mKMailSerialNumber;  // if email text, message's KMail serial number, else 0
00218         int                 mDeferGroupHeight;   // height added by deferred time widget
00219         int                 mDesktop;            // desktop to display the dialog in
00220         bool                mTemplate;           // editing an alarm template
00221         bool                mExpiredRecurrence;  // initially a recurrence which has expired
00222         mutable bool        mChanged;            // controls other than deferral have changed since dialog was displayed
00223         mutable bool        mOnlyDeferred;       // the only change made in the dialog was to the existing deferral
00224         bool                mDesiredReadOnly;    // the specified read-only status of the dialogue
00225         bool                mReadOnly;           // the actual read-only status of the dialogue
00226 
00227         // Initial state of all controls
00228         KAEvent*            mSavedEvent;
00229         QString             mSavedTemplateName;   // mTemplateName value
00230         QButton*            mSavedTemplateTimeType; // selected button in mTemplateTimeGroup
00231         QTime               mSavedTemplateTime;   // mTemplateTime value
00232         int                 mSavedTemplateAfterTime; // mTemplateAfterTime value
00233         QButton*            mSavedTypeRadio;      // mMessageRadio, etc
00234         SoundPicker::Type   mSavedSoundType;      // mSoundPicker sound type
00235         bool                mSavedSound;          // mSoundPicker sound status
00236         bool                mSavedRepeatSound;    // mSoundPicker repeat status
00237         QString             mSavedSoundFile;      // mSoundPicker sound file
00238         float               mSavedSoundVolume;    // mSoundPicker volume
00239         float               mSavedSoundFadeVolume;// mSoundPicker fade volume
00240         int                 mSavedSoundFadeSeconds;// mSoundPicker fade time
00241         bool                mSavedConfirmAck;     // mConfirmAck status
00242         QFont               mSavedFont;           // mFontColourButton font
00243         QColor              mSavedBgColour;       // mBgColourChoose selection
00244         QColor              mSavedFgColour;       // mFontColourButton foreground colour
00245         QString             mSavedPreAction;      // mSpecialActionsButton pre-alarm action
00246         QString             mSavedPostAction;     // mSpecialActionsButton post-alarm action
00247         int                 mSavedReminder;       // mReminder value
00248         bool                mSavedOnceOnly;       // mReminder once-only status
00249         QString             mSavedTextFileCommandMessage;  // mTextMessageEdit/mFileMessageEdit/mCmdCommandEdit/mEmailMessageEdit value
00250         QString             mSavedEmailFrom;      // mEmailFromList current value
00251         QString             mSavedEmailTo;        // mEmailToEdit value
00252         QString             mSavedEmailSubject;   // mEmailSubjectEdit value
00253         QStringList         mSavedEmailAttach;    // mEmailAttachList values
00254         bool                mSavedEmailBcc;       // mEmailBcc status
00255         bool                mSavedCmdScript;      // mCmdTypeScript status
00256         QButton*            mSavedCmdOutputRadio; // selected button in mCmdOutputGroup
00257         QString             mSavedCmdLogFile;     // mCmdLogFileEdit value
00258         DateTime            mSavedDateTime;       // mTimeWidget value
00259         int                 mSavedRecurrenceType; // RecurrenceEdit::RepeatType value
00260         int                 mSavedRepeatInterval; // alarm repetition interval (via mSimpleRepetition button)
00261         int                 mSavedRepeatCount;    // alarm repetition count (via mSimpleRepetition button)
00262         int                 mSavedLateCancel;     // mLateCancel value
00263         bool                mSavedAutoClose;      // mLateCancel->isAutoClose() value
00264         bool                mSavedShowInKorganizer; // mShowInKorganizer status
00265 };
00266 
00267 #endif // EDITDLG_H
KDE Home | KDE Accessibility Home | Description of Access Keys