2 * editdlgtypes.h - dialogues to create or edit alarm or alarm template types
4 * Copyright © 2001-2008 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
26 #include "alarmevent.h"
27 #include "alarmtext.h"
30 class QAbstractButton
;
37 class FontColourButton
;
43 class SpecialActionsButton
;
49 class EditDisplayAlarmDlg
: public EditAlarmDlg
53 // enum MessageType { TEXT, FILE, COMMAND };
55 EditDisplayAlarmDlg(bool Template
, bool newAlarm
, QWidget
* parent
= 0,
56 GetResourceType
= RES_PROMPT
);
57 EditDisplayAlarmDlg(bool Template
, const KAEvent
*, bool newAlarm
, QWidget
* parent
= 0,
58 GetResourceType
= RES_PROMPT
, bool readOnly
= false);
59 virtual void setAction(KAEvent::Action
, const AlarmText
& = AlarmText());
61 virtual Reminder
* createReminder(QWidget
* parent
);
62 static CheckBox
* createConfirmAckCheckbox(QWidget
* parent
);
64 static QString
i18n_chk_ConfirmAck(); // text of 'Confirm acknowledgement' checkbox
67 virtual QString
type_caption(bool newAlarm
) const;
68 virtual void type_init(QWidget
* parent
, QVBoxLayout
* frameLayout
);
69 virtual void type_initValues(const KAEvent
*);
70 virtual void setReadOnly(bool readOnly
);
71 virtual void saveState(const KAEvent
*);
72 virtual bool type_stateChanged() const;
73 virtual void type_setEvent(KAEvent
&, const KDateTime
&, const QString
& text
, int lateCancel
, bool trial
);
74 virtual int getAlarmFlags() const;
75 virtual bool type_validate(bool trial
) { Q_UNUSED(trial
); return true; }
76 virtual void type_trySuccessMessage(ShellProcess
*, const QString
&) {}
77 virtual CheckBox
* type_createConfirmAckCheckbox(QWidget
* parent
) { mConfirmAck
= createConfirmAckCheckbox(parent
); return mConfirmAck
; }
78 virtual bool checkText(QString
& result
, bool showErrorMessage
= true) const;
81 void slotAlarmTypeChanged(int index
);
83 void slotCmdScriptToggled(bool);
84 void setColours(const QColor
& fg
, const QColor
& bg
);
87 void setSoundPicker();
89 // Display alarm options
93 SoundPicker
* mSoundPicker
;
94 CheckBox
* mConfirmAck
;
95 FontColourButton
* mFontColourButton
;
96 SpecialActionsButton
* mSpecialActionsButton
;
97 unsigned long mKMailSerialNumber
; // if email text, message's KMail serial number, else 0
98 bool mReminderDeferral
;
99 bool mReminderArchived
;
100 // Text message alarm widgets
101 TextEdit
* mTextMessageEdit
; // text message edit box
102 // Text file alarm widgets
103 LineEdit
* mFileMessageEdit
; // text file URL edit box
104 QPushButton
* mFileBrowseButton
; // text file browse button
105 QString mFileDefaultDir
; // default directory for browse button
106 // Command output alarm widgets
107 CommandEdit
* mCmdEdit
;
109 // Initial state of all controls
110 int mSavedType
; // mTypeCombo index
111 Preferences::SoundType mSavedSoundType
; // mSoundPicker sound type
112 bool mSavedSound
; // mSoundPicker sound status
113 bool mSavedRepeatSound
; // mSoundPicker repeat status
114 KUrl mSavedSoundFile
; // mSoundPicker sound file
115 float mSavedSoundVolume
; // mSoundPicker volume
116 float mSavedSoundFadeVolume
; // mSoundPicker fade volume
117 int mSavedSoundFadeSeconds
; // mSoundPicker fade time
118 bool mSavedCmdScript
; // mCmdEdit->isScript() status
119 bool mSavedConfirmAck
; // mConfirmAck status
120 QFont mSavedFont
; // mFontColourButton font
121 QColor mSavedBgColour
; // mBgColourChoose selection
122 QColor mSavedFgColour
; // mFontColourButton foreground colour
123 QString mSavedPreAction
; // mSpecialActionsButton pre-alarm action
124 QString mSavedPostAction
; // mSpecialActionsButton post-alarm action
125 int mSavedReminder
; // mReminder value
126 bool mSavedAutoClose
; // mLateCancel->isAutoClose() value
127 bool mSavedOnceOnly
; // mReminder once-only status
128 bool mSavedPreActionCancel
; // mSpecialActionsButton cancel on pre-alarm action error
132 class EditCommandAlarmDlg
: public EditAlarmDlg
136 EditCommandAlarmDlg(bool Template
, bool newAlarm
, QWidget
* parent
= 0,
137 GetResourceType
= RES_PROMPT
);
138 EditCommandAlarmDlg(bool Template
, const KAEvent
*, bool newAlarm
, QWidget
* parent
= 0,
139 GetResourceType
= RES_PROMPT
, bool readOnly
= false);
140 virtual void setAction(KAEvent::Action
, const AlarmText
& = AlarmText());
142 static QString
i18n_chk_EnterScript(); // text of 'Enter a script' checkbox
143 static QString
i18n_radio_ExecInTermWindow(); // text of 'Execute in terminal window' radio button
144 static QString
i18n_chk_ExecInTermWindow(); // text of 'Execute in terminal window' checkbox
147 virtual QString
type_caption(bool newAlarm
) const;
148 virtual void type_init(QWidget
* parent
, QVBoxLayout
* frameLayout
);
149 virtual void type_initValues(const KAEvent
*);
150 virtual void setReadOnly(bool readOnly
);
151 virtual void saveState(const KAEvent
*);
152 virtual bool type_stateChanged() const;
153 virtual void type_setEvent(KAEvent
&, const KDateTime
&, const QString
& text
, int lateCancel
, bool trial
);
154 virtual int getAlarmFlags() const;
155 virtual bool type_validate(bool trial
);
156 virtual void type_trySuccessMessage(ShellProcess
*, const QString
& text
);
157 virtual bool checkText(QString
& result
, bool showErrorMessage
= true) const;
160 void slotCmdScriptToggled(bool);
163 // Command alarm options
164 CommandEdit
* mCmdEdit
;
165 ButtonGroup
* mCmdOutputGroup
; // what to do with command output
166 RadioButton
* mCmdExecInTerm
;
167 RadioButton
* mCmdLogToFile
;
168 RadioButton
* mCmdDiscardOutput
;
169 LineEdit
* mCmdLogFileEdit
; // log file URL edit box
172 // Initial state of all controls
173 bool mSavedCmdScript
; // mCmdEdit->isScript() status
174 QAbstractButton
* mSavedCmdOutputRadio
; // selected button in mCmdOutputGroup
175 QString mSavedCmdLogFile
; // mCmdLogFileEdit value
179 class EditEmailAlarmDlg
: public EditAlarmDlg
183 EditEmailAlarmDlg(bool Template
, bool newAlarm
, QWidget
* parent
= 0,
184 GetResourceType
= RES_PROMPT
);
185 EditEmailAlarmDlg(bool Template
, const KAEvent
*, bool newAlarm
, QWidget
* parent
= 0,
186 GetResourceType
= RES_PROMPT
, bool readOnly
= false);
187 virtual void setAction(KAEvent::Action
, const AlarmText
& = AlarmText());
189 static QString
i18n_chk_CopyEmailToSelf(); // text of 'Copy email to self' checkbox
192 virtual QString
type_caption(bool newAlarm
) const;
193 virtual void type_init(QWidget
* parent
, QVBoxLayout
* frameLayout
);
194 virtual void type_initValues(const KAEvent
*);
195 virtual void setReadOnly(bool readOnly
);
196 virtual void saveState(const KAEvent
*);
197 virtual bool type_stateChanged() const;
198 virtual void type_setEvent(KAEvent
&, const KDateTime
&, const QString
& text
, int lateCancel
, bool trial
);
199 virtual int getAlarmFlags() const;
200 virtual bool type_validate(bool trial
);
201 virtual void type_trySuccessMessage(ShellProcess
*, const QString
& text
);
202 virtual bool checkText(QString
& result
, bool showErrorMessage
= true) const;
205 void openAddressBook();
206 void slotAddAttachment();
207 void slotRemoveAttachment();
210 // Email alarm options
211 EmailIdCombo
* mEmailFromList
;
212 LineEdit
* mEmailToEdit
;
213 QPushButton
* mEmailAddressButton
; // email open address book button
214 LineEdit
* mEmailSubjectEdit
;
215 TextEdit
* mEmailMessageEdit
; // email body edit box
216 KComboBox
* mEmailAttachList
;
217 QPushButton
* mEmailAddAttachButton
;
218 QPushButton
* mEmailRemoveButton
;
220 QString mAttachDefaultDir
;
222 EmailAddressList mEmailAddresses
; // list of addresses to send email to
223 QStringList mEmailAttachments
; // list of email attachment file names
225 // Initial state of all controls
226 QString mSavedEmailFrom
; // mEmailFromList current value
227 QString mSavedEmailTo
; // mEmailToEdit value
228 QString mSavedEmailSubject
; // mEmailSubjectEdit value
229 QStringList mSavedEmailAttach
; // mEmailAttachList values
230 bool mSavedEmailBcc
; // mEmailBcc status
233 #endif // EDITDLGTYPES_H