kalarm

editdlg.h

00001 /*
00002  *  editdlg.h  -  dialogue to create or modify an alarm or alarm template
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 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_SpecialActions();     // plain text of 'Special Actions...' button
00078         static QString  i18n_ShowInKOrganizer();   // plain text of 'Show in KOrganizer' checkbox
00079         static QString  i18n_g_ShowInKOrganizer(); // text of 'Show in KOrganizer' checkbox, with 'G' shortcut
00080         static QString  i18n_EnterScript();        // plain text of 'Enter a script' checkbox
00081         static QString  i18n_p_EnterScript();      // text of 'Enter a script' checkbox, with 'P' shortcut
00082         static QString  i18n_ExecInTermWindow();   // plain text of 'Execute in terminal window' checkbox
00083         static QString  i18n_w_ExecInTermWindow(); // text of 'Execute in terminal window' radio button, with 'W' shortcut
00084         static QString  i18n_u_ExecInTermWindow(); // text of 'Execute in terminal window' radio button, with 'U' shortcut
00085         static QString  i18n_g_LogToFile();        // text of 'Log to file' radio button, with 'G' shortcut
00086         static QString  i18n_CopyEmailToSelf();    // plain text of 'Copy email to self' checkbox
00087         static QString  i18n_e_CopyEmailToSelf();  // text of 'Copy email to self' checkbox, with 'E' shortcut
00088         static QString  i18n_s_CopyEmailToSelf();  // text of 'Copy email to self' checkbox, with 'S' shortcut
00089         static QString  i18n_EmailFrom();          // plain text of 'From:' (email address)
00090         static QString  i18n_f_EmailFrom();        // text of 'From:' (email address), with 'F' shortcut
00091         static QString  i18n_EmailTo();            // plain text of 'To:' (email addressee)
00092         static QString  i18n_EmailSubject();       // plain text of 'Subject:' (email)
00093         static QString  i18n_j_EmailSubject();     // text of 'Subject:' (email), with 'J' shortcut
00094 
00095     protected:
00096         virtual void    resizeEvent(QResizeEvent*);
00097         virtual void    showEvent(QShowEvent*);
00098     protected slots:
00099         virtual void    slotOk();
00100         virtual void    slotCancel();
00101         virtual void    slotTry();
00102         virtual void    slotDefault();   // Load Template
00103     private slots:
00104         void            slotRecurTypeChange(int repeatType);
00105         void            slotRecurFrequencyChange();
00106         void            slotAlarmTypeChanged(int id);
00107         void            slotEditDeferral();
00108         void            slotFontColourSelected();
00109         void            slotBgColourSelected(const QColor&);
00110         void            openAddressBook();
00111         void            slotAddAttachment();
00112         void            slotRemoveAttachment();
00113         void            slotShowMainPage();
00114         void            slotShowRecurrenceEdit();
00115         void            slotAnyTimeToggled(bool anyTime);
00116         void            slotTemplateTimeType(int id);
00117         void            slotSetSimpleRepetition();
00118         void            slotCmdScriptToggled(bool);
00119 
00120     private:
00121         void            initialise(const KAEvent*);
00122         void            setReadOnly();
00123         void            setEvent(KAEvent&, const QString& text, bool trial);
00124         KAEvent::Action getAlarmType() const;
00125         int             getAlarmFlags() const;
00126         bool            checkText(QString& result, bool showErrorMessage = true) const;
00127         void            setSoundPicker();
00128         void            setRecurTabTitle(const KAEvent* = 0);
00129         bool            checkCommandData();
00130         bool            checkEmailData();
00131 
00132         void            initDisplayAlarms(QWidget* parent);
00133         void            initCommand(QWidget* parent);
00134         void            initEmail(QWidget* parent);
00135         void            saveState(const KAEvent*);
00136         bool            stateChanged() const;
00137 
00138         QTabWidget*         mTabs;                // the tabs in the dialog
00139         int                 mMainPageIndex;
00140         int                 mRecurPageIndex;
00141         bool                mMainPageShown;            // true once the main tab has been displayed
00142         bool                mRecurPageShown;           // true once the recurrence tab has been displayed
00143         bool                mRecurSetDefaultEndDate;   // adjust default end date/time when recurrence tab is displayed
00144 
00145         ButtonGroup*        mActionGroup;
00146         RadioButton*        mMessageRadio;
00147         RadioButton*        mCommandRadio;
00148         PickAlarmFileRadio* mFileRadio;
00149         RadioButton*        mEmailRadio;
00150         QWidgetStack*       mAlarmTypeStack;
00151 
00152         // Templates
00153         QLineEdit*          mTemplateName;
00154         ButtonGroup*        mTemplateTimeGroup;
00155         RadioButton*        mTemplateDefaultTime; // no alarm time is specified
00156         RadioButton*        mTemplateUseTimeAfter;// alarm time is specified as an offset from current
00157         RadioButton*        mTemplateAnyTime;     // alarms have date only, no time
00158         RadioButton*        mTemplateUseTime;     // an alarm time is specified
00159         TimeSpinBox*        mTemplateTimeAfter;   // the specified offset from the current time
00160         TimeEdit*           mTemplateTime;        // the alarm time which is specified
00161 
00162         // Display alarm options widgets
00163         QFrame*             mDisplayAlarmsFrame;
00164         QHBox*              mFileBox;
00165         QHBox*              mFilePadding;
00166         SoundPicker*        mSoundPicker;
00167         CheckBox*           mConfirmAck;
00168         FontColourButton*   mFontColourButton;
00169         ColourCombo*        mBgColourChoose;
00170         SpecialActionsButton* mSpecialActionsButton;
00171         Reminder*           mReminder;
00172         bool                mReminderDeferral;
00173         bool                mReminderArchived;
00174         // Text message alarm widgets
00175         TextEdit*           mTextMessageEdit;    // text message edit box
00176         // Text file alarm widgets
00177         LineEdit*           mFileMessageEdit;    // text file URL edit box
00178         QPushButton*        mFileBrowseButton;   // text file browse button
00179         QString             mFileDefaultDir;     // default directory for browse button
00180         // Command alarm widgets
00181         QFrame*             mCommandFrame;
00182         CheckBox*           mCmdTypeScript;      // entering a script
00183         LineEdit*           mCmdCommandEdit;     // command line edit box
00184         TextEdit*           mCmdScriptEdit;      // script edit box
00185         ButtonGroup*        mCmdOutputGroup;     // what to do with command output
00186         LineEdit*           mCmdLogFileEdit;     // log file URL edit box
00187         QWidget*            mCmdPadding;
00188         // Email alarm widgets
00189         QFrame*             mEmailFrame;
00190         EmailIdCombo*       mEmailFromList;
00191         LineEdit*           mEmailToEdit;
00192         QPushButton*        mEmailAddressButton; // email open address book button
00193         QLineEdit*          mEmailSubjectEdit;
00194         TextEdit*           mEmailMessageEdit;   // email body edit box
00195         QComboBox*          mEmailAttachList;
00196         QPushButton*        mEmailAddAttachButton;
00197         QPushButton*        mEmailRemoveButton;
00198         CheckBox*           mEmailBcc;
00199         QString             mAttachDefaultDir;
00200 
00201         QGroupBox*          mDeferGroup;
00202         QLabel*             mDeferTimeLabel;
00203         QPushButton*        mDeferChangeButton;
00204 
00205         AlarmTimeWidget*    mTimeWidget;
00206         LateCancelSelector* mLateCancel;
00207         CheckBox*           mShowInKorganizer;
00208 
00209         RepetitionButton*   mSimpleRepetition;
00210         QLabel*             mRecurrenceText;
00211         RecurrenceEdit*     mRecurrenceEdit;
00212 
00213         QString             mAlarmMessage;       // message text/file name/command/email message
00214         DateTime            mAlarmDateTime;
00215         DateTime            mDeferDateTime;
00216         EmailAddressList    mEmailAddresses;     // list of addresses to send email to
00217         QStringList         mEmailAttachments;   // list of email attachment file names
00218         unsigned long       mKMailSerialNumber;  // if email text, message's KMail serial number, else 0
00219         int                 mDeferGroupHeight;   // height added by deferred time widget
00220         int                 mDesktop;            // desktop to display the dialog in
00221         bool                mTemplate;           // editing an alarm template
00222         bool                mExpiredRecurrence;  // initially a recurrence which has expired
00223         mutable bool        mChanged;            // controls other than deferral have changed since dialog was displayed
00224         mutable bool        mOnlyDeferred;       // the only change made in the dialog was to the existing deferral
00225         bool                mDesiredReadOnly;    // the specified read-only status of the dialogue
00226         bool                mReadOnly;           // the actual read-only status of the dialogue
00227 
00228         // Initial state of all controls
00229         KAEvent*            mSavedEvent;
00230         QString             mSavedTemplateName;   // mTemplateName value
00231         QButton*            mSavedTemplateTimeType; // selected button in mTemplateTimeGroup
00232         QTime               mSavedTemplateTime;   // mTemplateTime value
00233         int                 mSavedTemplateAfterTime; // mTemplateAfterTime value
00234         QButton*            mSavedTypeRadio;      // mMessageRadio, etc
00235         SoundPicker::Type   mSavedSoundType;      // mSoundPicker sound type
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