2 * editdlgtypes.h - dialogues to create or edit alarm or alarm template types
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
25 #include "preferences.h"
27 #include <kalarmcal/alarmtext.h>
28 #include <kalarmcal/kaevent.h>
30 class QAbstractButton
;
36 class FontColourButton
;
41 class SpecialActionsButton
;
47 class PickLogFileRadio
;
50 class EditDisplayAlarmDlg
: public EditAlarmDlg
54 explicit EditDisplayAlarmDlg(bool Template
, QWidget
* parent
= Q_NULLPTR
, GetResourceType
= RES_PROMPT
);
55 EditDisplayAlarmDlg(bool Template
, const KAEvent
*, bool newAlarm
, QWidget
* parent
= Q_NULLPTR
,
56 GetResourceType
= RES_PROMPT
, bool readOnly
= false);
58 // Methods to initialise values in the New Alarm dialogue.
59 // N.B. setTime() must be called first to set the date-only characteristic,
60 // followed by setRecurrence().
61 void setAction(KAEvent::SubAction
, const AlarmText
& = AlarmText()) Q_DECL_OVERRIDE
;
62 void setBgColour(const QColor
&);
63 void setFgColour(const QColor
&);
64 void setConfirmAck(bool);
65 void setAutoClose(bool);
66 void setAudio(Preferences::SoundType
, const QString
& file
= QString(), float volume
= -1, int repeatPause
= -1);
67 void setReminder(int minutes
, bool onceOnly
);
69 Reminder
* createReminder(QWidget
* parent
) Q_DECL_OVERRIDE
;
70 static CheckBox
* createConfirmAckCheckbox(QWidget
* parent
);
72 static QString
i18n_chk_ConfirmAck(); // text of 'Confirm acknowledgement' checkbox
75 QString
type_caption() const Q_DECL_OVERRIDE
;
76 void type_init(QWidget
* parent
, QVBoxLayout
* frameLayout
) Q_DECL_OVERRIDE
;
77 void type_initValues(const KAEvent
*) Q_DECL_OVERRIDE
;
78 void type_showOptions(bool more
) Q_DECL_OVERRIDE
;
79 void setReadOnly(bool readOnly
) Q_DECL_OVERRIDE
;
80 void saveState(const KAEvent
*) Q_DECL_OVERRIDE
;
81 bool type_stateChanged() const Q_DECL_OVERRIDE
;
82 void type_setEvent(KAEvent
&, const KDateTime
&, const QString
& text
, int lateCancel
, bool trial
) Q_DECL_OVERRIDE
;
83 KAEvent::Flags
getAlarmFlags() const Q_DECL_OVERRIDE
;
84 bool type_validate(bool trial
) Q_DECL_OVERRIDE
{ Q_UNUSED(trial
); return true; }
85 CheckBox
* type_createConfirmAckCheckbox(QWidget
* parent
) Q_DECL_OVERRIDE
{ mConfirmAck
= createConfirmAckCheckbox(parent
); return mConfirmAck
; }
86 bool checkText(QString
& result
, bool showErrorMessage
= true) const Q_DECL_OVERRIDE
;
89 void slotAlarmTypeChanged(int index
);
91 void slotCmdScriptToggled(bool);
92 void setColours(const QColor
& fg
, const QColor
& bg
);
95 void setSoundPicker();
97 // Display alarm options
100 QWidget
* mFilePadding
;
101 SoundPicker
* mSoundPicker
;
102 CheckBox
* mConfirmAck
;
103 FontColourButton
* mFontColourButton
;
104 SpecialActionsButton
* mSpecialActionsButton
;
105 unsigned long mKMailSerialNumber
; // if email text, message's KMail serial number, else 0
106 bool mReminderDeferral
;
107 bool mReminderArchived
;
108 // Text message alarm widgets
109 TextEdit
* mTextMessageEdit
; // text message edit box
110 // Text file alarm widgets
111 LineEdit
* mFileMessageEdit
; // text file URL edit box
112 QPushButton
* mFileBrowseButton
; // text file browse button
113 QString mFileDefaultDir
; // default directory for browse button
114 // Command output alarm widgets
115 CommandEdit
* mCmdEdit
;
117 // Initial state of all controls
118 int mSavedType
; // mTypeCombo index
119 Preferences::SoundType mSavedSoundType
; // mSoundPicker sound type
120 bool mSavedSound
; // mSoundPicker sound status
121 int mSavedRepeatPause
; // mSoundPicker repeat pause
122 QUrl mSavedSoundFile
; // mSoundPicker sound file
123 float mSavedSoundVolume
; // mSoundPicker volume
124 float mSavedSoundFadeVolume
; // mSoundPicker fade volume
125 int mSavedSoundFadeSeconds
; // mSoundPicker fade time
126 bool mSavedCmdScript
; // mCmdEdit->isScript() status
127 bool mSavedConfirmAck
; // mConfirmAck status
128 QFont mSavedFont
; // mFontColourButton font
129 QColor mSavedBgColour
; // mBgColourChoose selection
130 QColor mSavedFgColour
; // mFontColourButton foreground colour
131 QString mSavedPreAction
; // mSpecialActionsButton pre-alarm action
132 QString mSavedPostAction
; // mSpecialActionsButton post-alarm action
133 int mSavedReminder
; // mReminder value
134 bool mSavedAutoClose
; // mLateCancel->isAutoClose() value
135 bool mSavedOnceOnly
; // mReminder once-only status
136 KAEvent::ExtraActionOptions mSavedPreActionOptions
; // mSpecialActionsButton pre-alarm action options
140 class EditCommandAlarmDlg
: public EditAlarmDlg
144 explicit EditCommandAlarmDlg(bool Template
, QWidget
* parent
= Q_NULLPTR
, GetResourceType
= RES_PROMPT
);
145 EditCommandAlarmDlg(bool Template
, const KAEvent
*, bool newAlarm
, QWidget
* parent
= Q_NULLPTR
,
146 GetResourceType
= RES_PROMPT
, bool readOnly
= false);
148 // Methods to initialise values in the New Alarm dialogue.
149 // N.B. setTime() must be called first to set the date-only characteristic,
150 // followed by setRecurrence().
151 void setAction(KAEvent::SubAction
, const AlarmText
& = AlarmText()) Q_DECL_OVERRIDE
;
153 static QString
i18n_chk_EnterScript(); // text of 'Enter a script' checkbox
154 static QString
i18n_radio_ExecInTermWindow(); // text of 'Execute in terminal window' radio button
155 static QString
i18n_chk_ExecInTermWindow(); // text of 'Execute in terminal window' checkbox
158 QString
type_caption() const Q_DECL_OVERRIDE
;
159 void type_init(QWidget
* parent
, QVBoxLayout
* frameLayout
) Q_DECL_OVERRIDE
;
160 void type_initValues(const KAEvent
*) Q_DECL_OVERRIDE
;
161 void type_showOptions(bool more
) Q_DECL_OVERRIDE
;
162 void setReadOnly(bool readOnly
) Q_DECL_OVERRIDE
;
163 void saveState(const KAEvent
*) Q_DECL_OVERRIDE
;
164 bool type_stateChanged() const Q_DECL_OVERRIDE
;
165 void type_setEvent(KAEvent
&, const KDateTime
&, const QString
& text
, int lateCancel
, bool trial
) Q_DECL_OVERRIDE
;
166 KAEvent::Flags
getAlarmFlags() const Q_DECL_OVERRIDE
;
167 bool type_validate(bool trial
) Q_DECL_OVERRIDE
;
168 void type_executedTry(const QString
& text
, void* obj
) Q_DECL_OVERRIDE
;
169 bool checkText(QString
& result
, bool showErrorMessage
= true) const Q_DECL_OVERRIDE
;
172 void slotCmdScriptToggled(bool);
175 // Command alarm options
176 CommandEdit
* mCmdEdit
;
177 QGroupBox
* mCmdOutputBox
;
178 ButtonGroup
* mCmdOutputGroup
; // what to do with command output
179 RadioButton
* mCmdExecInTerm
;
180 PickLogFileRadio
* mCmdLogToFile
;
181 RadioButton
* mCmdDiscardOutput
;
182 LineEdit
* mCmdLogFileEdit
; // log file URL edit box
183 QWidget
* mCmdPadding
;
185 // Initial state of all controls
186 bool mSavedCmdScript
; // mCmdEdit->isScript() status
187 QAbstractButton
* mSavedCmdOutputRadio
; // selected button in mCmdOutputGroup
188 QString mSavedCmdLogFile
; // mCmdLogFileEdit value
192 class EditEmailAlarmDlg
: public EditAlarmDlg
196 explicit EditEmailAlarmDlg(bool Template
, QWidget
* parent
= Q_NULLPTR
, GetResourceType
= RES_PROMPT
);
197 EditEmailAlarmDlg(bool Template
, const KAEvent
*, bool newAlarm
, QWidget
* parent
= Q_NULLPTR
,
198 GetResourceType
= RES_PROMPT
, bool readOnly
= false);
200 // Methods to initialise values in the New Alarm dialogue.
201 // N.B. setTime() must be called first to set the date-only characteristic,
202 // followed by setRecurrence().
203 void setAction(KAEvent::SubAction
, const AlarmText
& = AlarmText()) Q_DECL_OVERRIDE
;
204 void setEmailFields(uint fromID
, const KCalCore::Person::List
&, const QString
& subject
,
205 const QStringList
& attachments
);
208 static QString
i18n_chk_CopyEmailToSelf(); // text of 'Copy email to self' checkbox
211 QString
type_caption() const Q_DECL_OVERRIDE
;
212 void type_init(QWidget
* parent
, QVBoxLayout
* frameLayout
) Q_DECL_OVERRIDE
;
213 void type_initValues(const KAEvent
*) Q_DECL_OVERRIDE
;
214 void type_showOptions(bool) Q_DECL_OVERRIDE
{}
215 void setReadOnly(bool readOnly
) Q_DECL_OVERRIDE
;
216 void saveState(const KAEvent
*) Q_DECL_OVERRIDE
;
217 bool type_stateChanged() const Q_DECL_OVERRIDE
;
218 void type_setEvent(KAEvent
&, const KDateTime
&, const QString
& text
, int lateCancel
, bool trial
) Q_DECL_OVERRIDE
;
219 KAEvent::Flags
getAlarmFlags() const Q_DECL_OVERRIDE
;
220 bool type_validate(bool trial
) Q_DECL_OVERRIDE
;
221 void type_aboutToTry() Q_DECL_OVERRIDE
;
222 bool checkText(QString
& result
, bool showErrorMessage
= true) const Q_DECL_OVERRIDE
;
225 void slotTrySuccess();
226 void openAddressBook();
227 void slotAddAttachment();
228 void slotRemoveAttachment();
231 void attachmentEnable();
233 // Email alarm options
234 EmailIdCombo
* mEmailFromList
;
235 LineEdit
* mEmailToEdit
;
236 QPushButton
* mEmailAddressButton
; // email open address book button
237 LineEdit
* mEmailSubjectEdit
;
238 TextEdit
* mEmailMessageEdit
; // email body edit box
239 QComboBox
* mEmailAttachList
;
240 QPushButton
* mEmailAddAttachButton
;
241 QPushButton
* mEmailRemoveButton
;
243 QString mAttachDefaultDir
;
245 KCalCore::Person::List 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
262 explicit EditAudioAlarmDlg(bool Template
, QWidget
* parent
= Q_NULLPTR
, GetResourceType
= RES_PROMPT
);
263 EditAudioAlarmDlg(bool Template
, const KAEvent
*, bool newAlarm
, QWidget
* parent
= Q_NULLPTR
,
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 void setAction(KAEvent::SubAction
, const AlarmText
& = AlarmText()) Q_DECL_OVERRIDE
;
270 void setAudio(const QString
& file
, float volume
= -1);
273 QString
type_caption() const Q_DECL_OVERRIDE
;
274 void type_init(QWidget
* parent
, QVBoxLayout
* frameLayout
) Q_DECL_OVERRIDE
;
275 void type_initValues(const KAEvent
*) Q_DECL_OVERRIDE
;
276 void type_showOptions(bool) Q_DECL_OVERRIDE
{}
277 void setReadOnly(bool readOnly
) Q_DECL_OVERRIDE
;
278 void saveState(const KAEvent
*) Q_DECL_OVERRIDE
;
279 bool type_stateChanged() const Q_DECL_OVERRIDE
;
280 void type_setEvent(KAEvent
&, const KDateTime
&, const QString
& text
, int lateCancel
, bool trial
) Q_DECL_OVERRIDE
;
281 KAEvent::Flags
getAlarmFlags() const Q_DECL_OVERRIDE
;
282 bool type_validate(bool trial
) Q_DECL_OVERRIDE
{ Q_UNUSED(trial
); return true; }
283 void type_executedTry(const QString
& text
, void* obj
) Q_DECL_OVERRIDE
;
284 bool checkText(QString
& result
, bool showErrorMessage
= true) const Q_DECL_OVERRIDE
;
287 void slotTry() Q_DECL_OVERRIDE
;
290 void audioWinDestroyed() { slotAudioPlaying(false); }
291 void slotAudioPlaying(bool playing
);
294 MessageWin
* mMessageWin
; // MessageWin controlling test audio playback
296 // Audio alarm options
297 SoundWidget
* mSoundConfig
;
298 QWidget
* mPadding
; // allow top-adjustment of controls
300 // Initial state of all controls
301 QString mSavedFile
; // sound file
302 float mSavedVolume
; // volume
303 float mSavedFadeVolume
; // fade volume
304 int mSavedFadeSeconds
; // fade time
305 int mSavedRepeatPause
; // sound file repeat pause
308 #endif // EDITDLGTYPES_H