Remove double margin
[kdepim.git] / kalarm / prefdlg_p.h
blob40d3182d6e8888114a207a34b69bcb1d9ddb2bc3
1 /*
2 * prefdlg_p.h - private classes for program preferences dialog
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 PREFDLG_P_H
22 #define PREFDLG_P_H
24 #include "preferences.h"
25 #include "prefdlg.h"
26 #include "stackedwidgets.h"
28 class QCheckBox;
29 class QGroupBox;
30 class QAbstractButton;
31 class QRadioButton;
32 class QPushButton;
33 class QLabel;
34 class QSpinBox;
35 class KTimeZone;
36 class QLineEdit;
37 class QComboBox;
38 class FontColourChooser;
39 class ColourButton;
40 class ButtonGroup;
41 class RadioButton;
42 class TimeEdit;
43 class TimePeriod;
44 class SpinBox;
45 class TimeSpinBox;
46 class SpecialActionsButton;
47 class TimeZoneCombo;
50 // Base class for each tab in the Preferences dialog
51 class PrefsTabBase : public StackedScrollWidget
53 Q_OBJECT
54 public:
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; }
64 protected:
65 void showEvent(QShowEvent*) Q_DECL_OVERRIDE;
67 private:
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
78 Q_OBJECT
79 public:
80 explicit MiscPrefTab(StackedScrollGroup*);
82 void restore(bool defaults, bool allTabs) Q_DECL_OVERRIDE;
83 void apply(bool syncToDisc) Q_DECL_OVERRIDE;
85 private Q_SLOTS:
86 void slotAutostartClicked();
87 void slotOtherTerminalToggled(bool);
89 private:
90 void setTimeZone(const KTimeZone&);
92 QCheckBox* mAutoStart;
93 QCheckBox* mQuitWarn;
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
106 Q_OBJECT
107 public:
108 explicit TimePrefTab(StackedScrollGroup*);
110 void restore(bool defaults, bool allTabs) Q_DECL_OVERRIDE;
111 void apply(bool syncToDisc) Q_DECL_OVERRIDE;
113 private:
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;
122 TimeEdit* mWorkEnd;
123 TimeSpinBox* mKOrgEventDuration;
127 // Storage tab of the Preferences dialog
128 class StorePrefTab : public PrefsTabBase
130 Q_OBJECT
131 public:
132 explicit StorePrefTab(StackedScrollGroup*);
134 void restore(bool defaults, bool allTabs) Q_DECL_OVERRIDE;
135 void apply(bool syncToDisc) Q_DECL_OVERRIDE;
137 private Q_SLOTS:
138 void slotArchivedToggled(bool);
139 void slotClearArchived();
141 private:
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
159 Q_OBJECT
160 public:
161 explicit EmailPrefTab(StackedScrollGroup*);
163 QString validate();
164 void restore(bool defaults, bool allTabs) Q_DECL_OVERRIDE;
165 void apply(bool syncToDisc) Q_DECL_OVERRIDE;
167 private Q_SLOTS:
168 void slotEmailClientChanged(QAbstractButton*);
169 void slotFromAddrChanged(QAbstractButton*);
170 void slotBccAddrChanged(QAbstractButton*);
171 void slotAddressChanged() { mAddressChanged = true; }
173 private:
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
200 Q_OBJECT
201 public:
202 explicit EditPrefTab(StackedScrollGroup*);
204 QString validate();
205 void restore(bool defaults, bool allTabs) Q_DECL_OVERRIDE;
206 void apply(bool syncToDisc) Q_DECL_OVERRIDE;
208 private Q_SLOTS:
209 void slotBrowseSoundFile();
211 private:
212 QTabWidget* mTabs;
213 QCheckBox* mAutoClose;
214 QCheckBox* mConfirmAck;
215 QComboBox* mReminderUnits;
216 SpecialActionsButton* mSpecialActionsButton;
217 QCheckBox* mCmdScript;
218 QCheckBox* mCmdXterm;
219 QCheckBox* mEmailBcc;
220 QComboBox* mSound;
221 QLabel* mSoundFileLabel;
222 QLineEdit* mSoundFile;
223 QPushButton* mSoundFileBrowse;
224 QCheckBox* mSoundRepeat;
225 QCheckBox* mCopyToKOrganizer;
226 QCheckBox* mLateCancel;
227 ComboBox* mRecurPeriod;
228 ButtonGroup* mFeb29;
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
241 Q_OBJECT
242 public:
243 explicit ViewPrefTab(StackedScrollGroup*);
245 void restore(bool defaults, bool allTabs) Q_DECL_OVERRIDE;
246 void apply(bool syncToDisc) Q_DECL_OVERRIDE;
248 private Q_SLOTS:
249 void slotTooltipAlarmsToggled(bool);
250 void slotTooltipMaxToggled(bool);
251 void slotTooltipTimeToggled(bool);
252 void slotTooltipTimeToToggled(bool);
253 void slotAutoHideSysTrayChanged(QAbstractButton*);
254 void slotWindowPosChanged(QAbstractButton*);
256 private:
257 void setTooltip(int maxAlarms, bool time, bool timeTo, const QString& prefix);
259 QTabWidget* mTabs;
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
282 // vim: et sw=4: