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