kalarm

editdlg.h

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