Build with clang.
[kdepim.git] / kalarm / editdlgtypes.h
blob245d5b0227f90b6ce19638a2f1457b037a1fc5d5
1 /*
2 * editdlgtypes.h - dialogues to create or edit alarm or alarm template types
3 * Program: kalarm
4 * Copyright © 2001-2011 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 "alarmtext.h"
25 #include "editdlg.h"
26 #include "kaevent.h"
27 #include "preferences.h"
29 #include <kurl.h>
31 class QAbstractButton;
32 class QGroupBox;
33 class KComboBox;
34 class KHBox;
35 class EmailIdCombo;
36 class CheckBox;
37 class ComboBox;
38 class FontColourButton;
39 class ButtonGroup;
40 class RadioButton;
41 class Reminder;
42 class SoundPicker;
43 class SpecialActionsButton;
44 class CommandEdit;
45 class LineEdit;
46 class TextEdit;
47 class SoundWidget;
48 class PickLogFileRadio;
51 class EditDisplayAlarmDlg : public EditAlarmDlg
53 Q_OBJECT
54 public:
55 explicit EditDisplayAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
56 EditDisplayAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
57 GetResourceType = RES_PROMPT, bool readOnly = false);
59 // Methods to initialise values in the New Alarm dialogue.
60 // N.B. setTime() must be called first to set the date-only characteristic,
61 // followed by setRecurrence().
62 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
63 void setBgColour(const QColor&);
64 void setFgColour(const QColor&);
65 void setConfirmAck(bool);
66 void setAutoClose(bool);
67 void setAudio(Preferences::SoundType, const QString& file = QString(), float volume = -1, bool repeat = false);
68 void setReminder(int minutes, bool onceOnly);
70 virtual Reminder* createReminder(QWidget* parent);
71 static CheckBox* createConfirmAckCheckbox(QWidget* parent);
73 static QString i18n_chk_ConfirmAck(); // text of 'Confirm acknowledgement' checkbox
75 protected:
76 virtual QString type_caption() const;
77 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
78 virtual void type_initValues(const KAEvent*);
79 virtual void type_showOptions(bool more);
80 virtual void setReadOnly(bool readOnly);
81 virtual void saveState(const KAEvent*);
82 virtual bool type_stateChanged() const;
83 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
84 virtual int getAlarmFlags() const;
85 virtual bool type_validate(bool trial) { Q_UNUSED(trial); return true; }
86 virtual void type_trySuccessMessage(ShellProcess*, const QString&) {}
87 virtual CheckBox* type_createConfirmAckCheckbox(QWidget* parent) { mConfirmAck = createConfirmAckCheckbox(parent); return mConfirmAck; }
88 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
90 private slots:
91 void slotAlarmTypeChanged(int index);
92 void slotPickFile();
93 void slotCmdScriptToggled(bool);
94 void setColours(const QColor& fg, const QColor& bg);
96 private:
97 void setSoundPicker();
99 // Display alarm options
100 ComboBox* mTypeCombo;
101 KHBox* mFileBox;
102 KHBox* mFilePadding;
103 SoundPicker* mSoundPicker;
104 CheckBox* mConfirmAck;
105 FontColourButton* mFontColourButton;
106 SpecialActionsButton* mSpecialActionsButton;
107 unsigned long mKMailSerialNumber; // if email text, message's KMail serial number, else 0
108 bool mReminderDeferral;
109 bool mReminderArchived;
110 // Text message alarm widgets
111 TextEdit* mTextMessageEdit; // text message edit box
112 // Text file alarm widgets
113 LineEdit* mFileMessageEdit; // text file URL edit box
114 QPushButton* mFileBrowseButton; // text file browse button
115 QString mFileDefaultDir; // default directory for browse button
116 // Command output alarm widgets
117 CommandEdit* mCmdEdit;
119 // Initial state of all controls
120 int mSavedType; // mTypeCombo index
121 Preferences::SoundType mSavedSoundType; // mSoundPicker sound type
122 bool mSavedSound; // mSoundPicker sound status
123 bool mSavedRepeatSound; // mSoundPicker repeat status
124 KUrl mSavedSoundFile; // mSoundPicker sound file
125 float mSavedSoundVolume; // mSoundPicker volume
126 float mSavedSoundFadeVolume; // mSoundPicker fade volume
127 int mSavedSoundFadeSeconds; // mSoundPicker fade time
128 bool mSavedCmdScript; // mCmdEdit->isScript() status
129 bool mSavedConfirmAck; // mConfirmAck status
130 QFont mSavedFont; // mFontColourButton font
131 QColor mSavedBgColour; // mBgColourChoose selection
132 QColor mSavedFgColour; // mFontColourButton foreground colour
133 QString mSavedPreAction; // mSpecialActionsButton pre-alarm action
134 QString mSavedPostAction; // mSpecialActionsButton post-alarm action
135 int mSavedReminder; // mReminder value
136 bool mSavedAutoClose; // mLateCancel->isAutoClose() value
137 bool mSavedOnceOnly; // mReminder once-only status
138 bool mSavedPreActionCancel; // mSpecialActionsButton cancel on pre-alarm action error
142 class EditCommandAlarmDlg : public EditAlarmDlg
144 Q_OBJECT
145 public:
146 explicit EditCommandAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
147 EditCommandAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
148 GetResourceType = RES_PROMPT, bool readOnly = false);
150 // Methods to initialise values in the New Alarm dialogue.
151 // N.B. setTime() must be called first to set the date-only characteristic,
152 // followed by setRecurrence().
153 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
155 static QString i18n_chk_EnterScript(); // text of 'Enter a script' checkbox
156 static QString i18n_radio_ExecInTermWindow(); // text of 'Execute in terminal window' radio button
157 static QString i18n_chk_ExecInTermWindow(); // text of 'Execute in terminal window' checkbox
159 protected:
160 virtual QString type_caption() const;
161 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
162 virtual void type_initValues(const KAEvent*);
163 virtual void type_showOptions(bool more);
164 virtual void setReadOnly(bool readOnly);
165 virtual void saveState(const KAEvent*);
166 virtual bool type_stateChanged() const;
167 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
168 virtual int getAlarmFlags() const;
169 virtual bool type_validate(bool trial);
170 virtual void type_trySuccessMessage(ShellProcess*, const QString& text);
171 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
173 private slots:
174 void slotCmdScriptToggled(bool);
176 private:
177 // Command alarm options
178 CommandEdit* mCmdEdit;
179 QGroupBox* mCmdOutputBox;
180 ButtonGroup* mCmdOutputGroup; // what to do with command output
181 RadioButton* mCmdExecInTerm;
182 PickLogFileRadio* mCmdLogToFile;
183 RadioButton* mCmdDiscardOutput;
184 LineEdit* mCmdLogFileEdit; // log file URL edit box
185 KHBox* mCmdPadding;
187 // Initial state of all controls
188 bool mSavedCmdScript; // mCmdEdit->isScript() status
189 QAbstractButton* mSavedCmdOutputRadio; // selected button in mCmdOutputGroup
190 QString mSavedCmdLogFile; // mCmdLogFileEdit value
194 class EditEmailAlarmDlg : public EditAlarmDlg
196 Q_OBJECT
197 public:
198 explicit EditEmailAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
199 EditEmailAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
200 GetResourceType = RES_PROMPT, bool readOnly = false);
202 // Methods to initialise values in the New Alarm dialogue.
203 // N.B. setTime() must be called first to set the date-only characteristic,
204 // followed by setRecurrence().
205 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
206 void setEmailFields(uint fromID, const EmailAddressList&, const QString& subject,
207 const QStringList& attachments);
208 void setBcc(bool);
210 static QString i18n_chk_CopyEmailToSelf(); // text of 'Copy email to self' checkbox
212 protected:
213 virtual QString type_caption() const;
214 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
215 virtual void type_initValues(const KAEvent*);
216 virtual void type_showOptions(bool) {}
217 virtual void setReadOnly(bool readOnly);
218 virtual void saveState(const KAEvent*);
219 virtual bool type_stateChanged() const;
220 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
221 virtual int getAlarmFlags() const;
222 virtual bool type_validate(bool trial);
223 virtual void type_trySuccessMessage(ShellProcess*, const QString& text);
224 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
226 private slots:
227 void openAddressBook();
228 void slotAddAttachment();
229 void slotRemoveAttachment();
231 private:
232 void attachmentEnable();
234 // Email alarm options
235 EmailIdCombo* mEmailFromList;
236 LineEdit* mEmailToEdit;
237 QPushButton* mEmailAddressButton; // email open address book button
238 LineEdit* mEmailSubjectEdit;
239 TextEdit* mEmailMessageEdit; // email body edit box
240 KComboBox* mEmailAttachList;
241 QPushButton* mEmailAddAttachButton;
242 QPushButton* mEmailRemoveButton;
243 CheckBox* mEmailBcc;
244 QString mAttachDefaultDir;
246 EmailAddressList mEmailAddresses; // list of addresses to send email to
247 QStringList mEmailAttachments; // list of email attachment file names
249 // Initial state of all controls
250 QString mSavedEmailFrom; // mEmailFromList current value
251 QString mSavedEmailTo; // mEmailToEdit value
252 QString mSavedEmailSubject; // mEmailSubjectEdit value
253 QStringList mSavedEmailAttach; // mEmailAttachList values
254 bool mSavedEmailBcc; // mEmailBcc status
258 class EditAudioAlarmDlg : public EditAlarmDlg
260 Q_OBJECT
261 public:
262 explicit EditAudioAlarmDlg(bool Template, QWidget* parent = 0, GetResourceType = RES_PROMPT);
263 EditAudioAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
264 GetResourceType = RES_PROMPT, bool readOnly = false);
266 // Methods to initialise values in the New Alarm dialogue.
267 // N.B. setTime() must be called first to set the date-only characteristic,
268 // followed by setRecurrence().
269 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText());
270 void setAudio(const QString& file, float volume = -1);
272 protected:
273 virtual QString type_caption() const;
274 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout);
275 virtual void type_initValues(const KAEvent*);
276 virtual void type_showOptions(bool) {}
277 virtual void setReadOnly(bool readOnly);
278 virtual void saveState(const KAEvent*);
279 virtual bool type_stateChanged() const;
280 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial);
281 virtual int getAlarmFlags() const;
282 virtual bool type_validate(bool trial) { Q_UNUSED(trial); return true; }
283 virtual void type_trySuccessMessage(ShellProcess*, const QString&) {}
284 virtual bool checkText(QString& result, bool showErrorMessage = true) const;
286 // Audio alarm options
287 SoundWidget* mSoundConfig;
288 KHBox* mPadding; // allow top-adjustment of controls
290 // Initial state of all controls
291 QString mSavedFile; // sound file
292 float mSavedVolume; // volume
293 float mSavedFadeVolume; // fade volume
294 int mSavedFadeSeconds; // fade time
295 bool mSavedRepeat; // repeat sound file
298 #endif // EDITDLGTYPES_H
300 // vim: et sw=4: