2 * prefdlg_p.h - private classes for program preferences dialog
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.
24 #include "preferences.h"
26 #include "stackedwidgets.h"
30 class QAbstractButton
;
38 class FontColourChooser
;
46 class SpecialActionsButton
;
50 // Base class for each tab in the Preferences dialog
51 class PrefsTabBase
: public StackedScrollWidget
55 explicit PrefsTabBase(StackedScrollGroup
*);
57 void setPreferences();
58 virtual void restore(bool defaults
, bool allTabs
) = 0;
59 virtual void apply(bool syncToDisc
) = 0;
60 void addAlignedLabel(QLabel
*);
61 QVBoxLayout
* topLayout() const { return mTopLayout
; }
62 static int indentWidth() { return mIndentWidth
; }
65 void showEvent(QShowEvent
*) Q_DECL_OVERRIDE
;
68 static int mIndentWidth
; // indent width for checkboxes etc.
69 QVBoxLayout
* mTopLayout
;
70 QList
<QLabel
*> mLabels
; // labels to right-align
71 bool mLabelsAligned
; // labels have been aligned
75 // Miscellaneous tab of the Preferences dialog
76 class MiscPrefTab
: public PrefsTabBase
80 explicit MiscPrefTab(StackedScrollGroup
*);
82 void restore(bool defaults
, bool allTabs
) Q_DECL_OVERRIDE
;
83 void apply(bool syncToDisc
) Q_DECL_OVERRIDE
;
86 void slotAutostartClicked();
87 void slotOtherTerminalToggled(bool);
90 void setTimeZone(const KTimeZone
&);
92 QCheckBox
* mAutoStart
;
94 QCheckBox
* mConfirmAlarmDeletion
;
95 TimeSpinBox
* mDefaultDeferTime
;
96 ButtonGroup
* mXtermType
;
97 QLineEdit
* mXtermCommand
;
98 int mXtermFirst
; // id of first terminal window radio button
99 int mXtermCount
; // number of terminal window types
103 // Date/time tab of the Preferences dialog
104 class TimePrefTab
: public PrefsTabBase
108 explicit TimePrefTab(StackedScrollGroup
*);
110 void restore(bool defaults
, bool allTabs
) Q_DECL_OVERRIDE
;
111 void apply(bool syncToDisc
) Q_DECL_OVERRIDE
;
114 void setWorkDays(const QBitArray
& days
);
116 TimeZoneCombo
* mTimeZone
;
117 QComboBox
* mHolidays
;
118 QMap
<QString
, QString
> mHolidayNames
;
119 TimeEdit
* mStartOfDay
;
120 QCheckBox
* mWorkDays
[7];
121 TimeEdit
* mWorkStart
;
123 TimeSpinBox
* mKOrgEventDuration
;
127 // Storage tab of the Preferences dialog
128 class StorePrefTab
: public PrefsTabBase
132 explicit StorePrefTab(StackedScrollGroup
*);
134 void restore(bool defaults
, bool allTabs
) Q_DECL_OVERRIDE
;
135 void apply(bool syncToDisc
) Q_DECL_OVERRIDE
;
138 void slotArchivedToggled(bool);
139 void slotClearArchived();
142 void setArchivedControls(int purgeDays
);
144 QRadioButton
* mDefaultResource
;
145 QRadioButton
* mAskResource
;
146 QCheckBox
* mKeepArchived
;
147 QCheckBox
* mPurgeArchived
;
148 SpinBox
* mPurgeAfter
;
149 QLabel
* mPurgeAfterLabel
;
150 QPushButton
* mClearArchived
;
151 bool mOldKeepArchived
; // previous setting of keep-archived
152 bool mCheckKeepChanges
;
156 // Email tab of the Preferences dialog
157 class EmailPrefTab
: public PrefsTabBase
161 explicit EmailPrefTab(StackedScrollGroup
*);
164 void restore(bool defaults
, bool allTabs
) Q_DECL_OVERRIDE
;
165 void apply(bool syncToDisc
) Q_DECL_OVERRIDE
;
168 void slotEmailClientChanged(QAbstractButton
*);
169 void slotFromAddrChanged(QAbstractButton
*);
170 void slotBccAddrChanged(QAbstractButton
*);
171 void slotAddressChanged() { mAddressChanged
= true; }
174 void setEmailAddress(Preferences::MailFrom
, const QString
& address
);
175 void setEmailBccAddress(bool useSystemSettings
, const QString
& address
);
176 QString
validateAddr(ButtonGroup
*, QLineEdit
* addr
, const QString
& msg
);
178 ButtonGroup
* mEmailClient
;
179 RadioButton
* mKMailButton
;
180 RadioButton
* mSendmailButton
;
181 ButtonGroup
* mFromAddressGroup
;
182 RadioButton
* mFromAddrButton
;
183 RadioButton
* mFromCCentreButton
;
184 RadioButton
* mFromKMailButton
;
185 QLineEdit
* mEmailAddress
;
186 ButtonGroup
* mBccAddressGroup
;
187 RadioButton
* mBccAddrButton
;
188 RadioButton
* mBccCCentreButton
;
189 QLineEdit
* mEmailBccAddress
;
190 QCheckBox
* mEmailQueuedNotify
;
191 QCheckBox
* mEmailCopyToKMail
;
192 bool mAddressChanged
;
193 bool mBccAddressChanged
;
197 // Edit defaults tab of the Preferences dialog
198 class EditPrefTab
: public PrefsTabBase
202 explicit EditPrefTab(StackedScrollGroup
*);
205 void restore(bool defaults
, bool allTabs
) Q_DECL_OVERRIDE
;
206 void apply(bool syncToDisc
) Q_DECL_OVERRIDE
;
209 void slotBrowseSoundFile();
213 QCheckBox
* mAutoClose
;
214 QCheckBox
* mConfirmAck
;
215 QComboBox
* mReminderUnits
;
216 SpecialActionsButton
* mSpecialActionsButton
;
217 QCheckBox
* mCmdScript
;
218 QCheckBox
* mCmdXterm
;
219 QCheckBox
* mEmailBcc
;
221 QLabel
* mSoundFileLabel
;
222 QLineEdit
* mSoundFile
;
223 QPushButton
* mSoundFileBrowse
;
224 QCheckBox
* mSoundRepeat
;
225 QCheckBox
* mCopyToKOrganizer
;
226 QCheckBox
* mLateCancel
;
227 ComboBox
* mRecurPeriod
;
229 FontColourChooser
* mFontChooser
;
230 int mTabGeneral
; // index of General tab
231 int mTabTypes
; // index of Alarm Types tab
232 int mTabFontColour
; // index of Font & Color tab
234 static int soundIndex(Preferences::SoundType
);
238 // View tab of the Preferences dialog
239 class ViewPrefTab
: public PrefsTabBase
243 explicit ViewPrefTab(StackedScrollGroup
*);
245 void restore(bool defaults
, bool allTabs
) Q_DECL_OVERRIDE
;
246 void apply(bool syncToDisc
) Q_DECL_OVERRIDE
;
249 void slotTooltipAlarmsToggled(bool);
250 void slotTooltipMaxToggled(bool);
251 void slotTooltipTimeToggled(bool);
252 void slotTooltipTimeToToggled(bool);
253 void slotAutoHideSysTrayChanged(QAbstractButton
*);
254 void slotWindowPosChanged(QAbstractButton
*);
257 void setTooltip(int maxAlarms
, bool time
, bool timeTo
, const QString
& prefix
);
260 ColourButton
* mDisabledColour
;
261 ColourButton
* mArchivedColour
;
262 QGroupBox
* mShowInSystemTray
;
263 ButtonGroup
* mAutoHideSystemTray
;
264 TimePeriod
* mAutoHideSystemTrayPeriod
;
265 QCheckBox
* mTooltipShowAlarms
;
266 QCheckBox
* mTooltipMaxAlarms
;
267 SpinBox
* mTooltipMaxAlarmCount
;
268 QCheckBox
* mTooltipShowTime
;
269 QCheckBox
* mTooltipShowTimeTo
;
270 QLineEdit
* mTooltipTimeToPrefix
;
271 QLabel
* mTooltipTimeToPrefixLabel
;
272 ButtonGroup
* mWindowPosition
;
273 QSpinBox
* mWindowButtonDelay
;
274 QLabel
* mWindowButtonDelayLabel
;
275 QCheckBox
* mModalMessages
;
276 int mTabGeneral
; // index of General tab
277 int mTabWindows
; // index of Alarm Windows tab
280 #endif // PREFDLG_P_H