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