Updated the Tools menu to reflect current build.
[kdepim.git] / kalarm / editdlgtypes.h
blob1144f96ca95b1ff5a37f8647600bb6b7d34b2fed
1 /*
2 * editdlgtypes.h - dialogues to create or edit alarm or alarm template types
3 * Program: kalarm
4 * Copyright © 2001-2012 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef EDITDLGTYPES_H
22 #define EDITDLGTYPES_H
24 #include "editdlg.h"
25 #include "preferences.h"
27 #include <kalarmcal/alarmtext.h>
28 #include <kalarmcal/kaevent.h>
30 #ifndef USE_AKONADI
31 #include <kcal/person.h>
32 #endif
34 #include <kurl.h>
36 class QAbstractButton;
37 class QGroupBox;
38 class KComboBox;
39 class KHBox;
40 class EmailIdCombo;
41 class CheckBox;
42 class ComboBox;
43 class FontColourButton;
44 class ButtonGroup;
45 class RadioButton;
46 class Reminder;
47 class SoundPicker;
48 class SpecialActionsButton;
49 class CommandEdit;
50 class LineEdit;
51 class TextEdit;
52 class SoundWidget;
53 class MessageWin;
54 class PickLogFileRadio;
57 class EditDisplayAlarmDlg : public EditAlarmDlg
59 Q_OBJECT
60 public:
61 explicit EditDisplayAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
62 EditDisplayAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
63 GetResourceType = RES_PROMPT, bool readOnly = false);
65 // Methods to initialise values in the New Alarm dialogue.
66 // N.B. setTime() must be called first to set the date-only characteristic,
67 // followed by setRecurrence().
68 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
69 void setBgColour(const QColor&);
70 void setFgColour(const QColor&);
71 void setConfirmAck(bool);
72 void setAutoClose(bool);
73 void setAudio(Preferences::SoundType, const QString& file = QString(), float volume = -1, int repeatPause = -1);
74 void setReminder(int minutes, bool onceOnly);
76 virtual Reminder* createReminder(QWidget* parent);
77 static CheckBox* createConfirmAckCheckbox(QWidget* parent);
79 static QString i18n_chk_ConfirmAck(); // text of 'Confirm acknowledgement' checkbox
81 protected:
82 virtual QString type_caption() const;
83 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
84 virtual void type_initValues(const KAEvent*);
85 virtual void type_showOptions(bool more);
86 virtual void setReadOnly(bool readOnly);
87 virtual void saveState(const KAEvent*);
88 virtual bool type_stateChanged() const;
89 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
90 virtual KAEvent::Flags getAlarmFlags() const;
91 virtual bool type_validate(bool trial) { Q_UNUSED(trial); return true; }
92 virtual CheckBox* type_createConfirmAckCheckbox(QWidget* parent) { mConfirmAck = createConfirmAckCheckbox(parent); return mConfirmAck; }
93 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
95 private slots:
96 void slotAlarmTypeChanged(int index);
97 void slotPickFile();
98 void slotCmdScriptToggled(bool);
99 void setColours(const QColor& fg, const QColor& bg);
101 private:
102 void setSoundPicker();
104 // Display alarm options
105 ComboBox* mTypeCombo;
106 KHBox* mFileBox;
107 KHBox* mFilePadding;
108 SoundPicker* mSoundPicker;
109 CheckBox* mConfirmAck;
110 FontColourButton* mFontColourButton;
111 SpecialActionsButton* mSpecialActionsButton;
112 unsigned long mKMailSerialNumber; // if email text, message's KMail serial number, else 0
113 bool mReminderDeferral;
114 bool mReminderArchived;
115 // Text message alarm widgets
116 TextEdit* mTextMessageEdit; // text message edit box
117 // Text file alarm widgets
118 LineEdit* mFileMessageEdit; // text file URL edit box
119 QPushButton* mFileBrowseButton; // text file browse button
120 QString mFileDefaultDir; // default directory for browse button
121 // Command output alarm widgets
122 CommandEdit* mCmdEdit;
124 // Initial state of all controls
125 int mSavedType; // mTypeCombo index
126 Preferences::SoundType mSavedSoundType; // mSoundPicker sound type
127 bool mSavedSound; // mSoundPicker sound status
128 int mSavedRepeatPause; // mSoundPicker repeat pause
129 KUrl mSavedSoundFile; // mSoundPicker sound file
130 float mSavedSoundVolume; // mSoundPicker volume
131 float mSavedSoundFadeVolume; // mSoundPicker fade volume
132 int mSavedSoundFadeSeconds; // mSoundPicker fade time
133 bool mSavedCmdScript; // mCmdEdit->isScript() status
134 bool mSavedConfirmAck; // mConfirmAck status
135 QFont mSavedFont; // mFontColourButton font
136 QColor mSavedBgColour; // mBgColourChoose selection
137 QColor mSavedFgColour; // mFontColourButton foreground colour
138 QString mSavedPreAction; // mSpecialActionsButton pre-alarm action
139 QString mSavedPostAction; // mSpecialActionsButton post-alarm action
140 int mSavedReminder; // mReminder value
141 bool mSavedAutoClose; // mLateCancel->isAutoClose() value
142 bool mSavedOnceOnly; // mReminder once-only status
143 KAEvent::ExtraActionOptions mSavedPreActionOptions; // mSpecialActionsButton pre-alarm action options
147 class EditCommandAlarmDlg : public EditAlarmDlg
149 Q_OBJECT
150 public:
151 explicit EditCommandAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
152 EditCommandAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
153 GetResourceType = RES_PROMPT, bool readOnly = false);
155 // Methods to initialise values in the New Alarm dialogue.
156 // N.B. setTime() must be called first to set the date-only characteristic,
157 // followed by setRecurrence().
158 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
160 static QString i18n_chk_EnterScript(); // text of 'Enter a script' checkbox
161 static QString i18n_radio_ExecInTermWindow(); // text of 'Execute in terminal window' radio button
162 static QString i18n_chk_ExecInTermWindow(); // text of 'Execute in terminal window' checkbox
164 protected:
165 virtual QString type_caption() const;
166 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
167 virtual void type_initValues(const KAEvent*);
168 virtual void type_showOptions(bool more);
169 virtual void setReadOnly(bool readOnly);
170 virtual void saveState(const KAEvent*);
171 virtual bool type_stateChanged() const;
172 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
173 virtual KAEvent::Flags getAlarmFlags() const;
174 virtual bool type_validate(bool trial);
175 virtual void type_executedTry(const QString& text, void* obj);
176 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
178 private slots:
179 void slotCmdScriptToggled(bool);
181 private:
182 // Command alarm options
183 CommandEdit* mCmdEdit;
184 QGroupBox* mCmdOutputBox;
185 ButtonGroup* mCmdOutputGroup; // what to do with command output
186 RadioButton* mCmdExecInTerm;
187 PickLogFileRadio* mCmdLogToFile;
188 RadioButton* mCmdDiscardOutput;
189 LineEdit* mCmdLogFileEdit; // log file URL edit box
190 KHBox* mCmdPadding;
192 // Initial state of all controls
193 bool mSavedCmdScript; // mCmdEdit->isScript() status
194 QAbstractButton* mSavedCmdOutputRadio; // selected button in mCmdOutputGroup
195 QString mSavedCmdLogFile; // mCmdLogFileEdit value
199 class EditEmailAlarmDlg : public EditAlarmDlg
201 Q_OBJECT
202 public:
203 explicit EditEmailAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
204 EditEmailAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
205 GetResourceType = RES_PROMPT, bool readOnly = false);
207 // Methods to initialise values in the New Alarm dialogue.
208 // N.B. setTime() must be called first to set the date-only characteristic,
209 // followed by setRecurrence().
210 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
211 #ifdef USE_AKONADI
212 void setEmailFields(uint fromID, const KCalCore::Person::List&, const QString& subject,
213 const QStringList& attachments);
214 #else
215 void setEmailFields(uint fromID, const QList<KCal::Person>&, const QString& subject,
216 const QStringList& attachments);
217 #endif
218 void setBcc(bool);
220 static QString i18n_chk_CopyEmailToSelf(); // text of 'Copy email to self' checkbox
222 protected:
223 virtual QString type_caption() const;
224 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
225 virtual void type_initValues(const KAEvent*);
226 virtual void type_showOptions(bool) {}
227 virtual void setReadOnly(bool readOnly);
228 virtual void saveState(const KAEvent*);
229 virtual bool type_stateChanged() const;
230 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
231 virtual KAEvent::Flags getAlarmFlags() const;
232 virtual bool type_validate(bool trial);
233 virtual void type_aboutToTry();
234 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
236 private slots:
237 void slotTrySuccess();
238 void openAddressBook();
239 void slotAddAttachment();
240 void slotRemoveAttachment();
242 private:
243 void attachmentEnable();
245 // Email alarm options
246 EmailIdCombo* mEmailFromList;
247 LineEdit* mEmailToEdit;
248 QPushButton* mEmailAddressButton; // email open address book button
249 LineEdit* mEmailSubjectEdit;
250 TextEdit* mEmailMessageEdit; // email body edit box
251 KComboBox* mEmailAttachList;
252 QPushButton* mEmailAddAttachButton;
253 QPushButton* mEmailRemoveButton;
254 CheckBox* mEmailBcc;
255 QString mAttachDefaultDir;
257 #ifdef USE_AKONADI
258 KCalCore::Person::List mEmailAddresses; // list of addresses to send email to
259 #else
260 QList<KCal::Person> mEmailAddresses; // list of addresses to send email to
261 #endif
263 QStringList mEmailAttachments; // list of email attachment file names
265 // Initial state of all controls
266 QString mSavedEmailFrom; // mEmailFromList current value
267 QString mSavedEmailTo; // mEmailToEdit value
268 QString mSavedEmailSubject; // mEmailSubjectEdit value
269 QStringList mSavedEmailAttach; // mEmailAttachList values
270 bool mSavedEmailBcc; // mEmailBcc status
274 class EditAudioAlarmDlg : public EditAlarmDlg
276 Q_OBJECT
277 public:
278 explicit EditAudioAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
279 EditAudioAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
280 GetResourceType = RES_PROMPT, bool readOnly = false);
282 // Methods to initialise values in the New Alarm dialogue.
283 // N.B. setTime() must be called first to set the date-only characteristic,
284 // followed by setRecurrence().
285 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
286 void setAudio(const QString& file, float volume = -1);
288 protected:
289 virtual QString type_caption() const;
290 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
291 virtual void type_initValues(const KAEvent*);
292 virtual void type_showOptions(bool) {}
293 virtual void setReadOnly(bool readOnly);
294 virtual void saveState(const KAEvent*);
295 virtual bool type_stateChanged() const;
296 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
297 virtual KAEvent::Flags getAlarmFlags() const;
298 virtual bool type_validate(bool trial) { Q_UNUSED(trial); return true; }
299 virtual void type_executedTry(const QString& text, void* obj);
300 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
302 protected slots:
303 virtual void slotTry();
305 private slots:
306 void audioWinDestroyed() { slotAudioPlaying(false); }
307 void slotAudioPlaying(bool playing);
309 private:
310 MessageWin* mMessageWin; // MessageWin controlling test audio playback
312 // Audio alarm options
313 SoundWidget* mSoundConfig;
314 KHBox* mPadding; // allow top-adjustment of controls
316 // Initial state of all controls
317 QString mSavedFile; // sound file
318 float mSavedVolume; // volume
319 float mSavedFadeVolume; // fade volume
320 int mSavedFadeSeconds; // fade time
321 int mSavedRepeatPause; // sound file repeat pause
324 #endif // EDITDLGTYPES_H
326 // vim: et sw=4: