kalarm

prefdlg.h
1 /*
2  * prefdlg.h - program preferences dialog
3  * Program: kalarm
4  * Copyright © 2001-2007 by David Jarvie <djarvie@kde.org>
5  *
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.
10  *
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.
15  *
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.
19  */
20 
21 #ifndef PREFDLG_H
22 #define PREFDLG_H
23 
24 #include <tqsize.h>
25 #include <tqdatetime.h>
26 #include <ktabctl.h>
27 #include <kdialogbase.h>
28 
29 #include "preferences.h"
30 #include "recurrenceedit.h"
31 #include "soundpicker.h"
32 
33 class TQButtonGroup;
34 class TQCheckBox;
35 class TQRadioButton;
36 class TQPushButton;
37 class TQComboBox;
38 class TQLineEdit;
39 class KColorCombo;
40 class FontColourChooser;
41 class ButtonGroup;
42 class TimeEdit;
43 class SpinBox;
44 class SpecialActionsButton;
45 
46 class FontColourPrefTab;
47 class EditPrefTab;
48 class EmailPrefTab;
49 class ViewPrefTab;
50 class MiscPrefTab;
51 
52 
53 // The Preferences dialog
54 class KAlarmPrefDlg : public KDialogBase
55 {
56  TQ_OBJECT
57 
58  public:
59  static void display();
60  ~KAlarmPrefDlg();
61 
62  FontColourPrefTab* mFontColourPage;
63  EditPrefTab* mEditPage;
64  EmailPrefTab* mEmailPage;
65  ViewPrefTab* mViewPage;
66  MiscPrefTab* mMiscPage;
67 
68  protected slots:
69  virtual void slotOk();
70  virtual void slotApply();
71  virtual void slotHelp();
72  virtual void slotDefault();
73  virtual void slotCancel();
74 
75  private:
76  KAlarmPrefDlg();
77  void restore();
78 
79  static KAlarmPrefDlg* mInstance;
80  bool mValid;
81 };
82 
83 // Base class for each tab in the Preferences dialog
84 class PrefsTabBase : public TQWidget
85 {
86  TQ_OBJECT
87 
88  public:
89  PrefsTabBase(TQVBox*);
90 
91  void setPreferences();
92  virtual void restore() = 0;
93  virtual void apply(bool syncToDisc) = 0;
94  virtual void setDefaults() = 0;
95  static int indentWidth() { return mIndentWidth; }
96 
97  protected:
98  TQVBox* mPage;
99 
100  private:
101  static int mIndentWidth; // indent width for checkboxes etc.
102 };
103 
104 
105 // Miscellaneous tab of the Preferences dialog
106 class MiscPrefTab : public PrefsTabBase
107 {
108  TQ_OBJECT
109 
110  public:
111  MiscPrefTab(TQVBox*);
112 
113  virtual void restore();
114  virtual void apply(bool syncToDisc);
115  virtual void setDefaults();
116 
117  private slots:
118  void slotAutostartDaemonClicked();
119  void slotRunModeToggled(bool);
120  void slotDisableIfStoppedToggled(bool);
121  void slotExpiredToggled(bool);
122  void slotClearExpired();
123  void slotOtherTerminalToggled(bool);
124 //#ifdef AUTOSTART_BY_KALARMD
125  void slotAutostartToggled(bool);
126 //#endif
127 
128  private:
129  void setExpiredControls(int purgeDays);
130 
131  TQCheckBox* mAutostartDaemon;
132  TQRadioButton* mRunInSystemTray;
133  TQRadioButton* mRunOnDemand;
134  TQCheckBox* mDisableAlarmsIfStopped;
135  TQCheckBox* mQuitWarn;
136  TQCheckBox* mAutostartTrayIcon;
137  TQCheckBox* mConfirmAlarmDeletion;
138  TQCheckBox* mKeepExpired;
139  TQCheckBox* mPurgeExpired;
140  SpinBox* mPurgeAfter;
141  TQLabel* mPurgeAfterLabel;
142  TQPushButton* mClearExpired;
143  TimeEdit* mStartOfDay;
144  TQButtonGroup* mXtermType;
145  TQLineEdit* mXtermCommand;
146  int mXtermFirst; // id of first terminal window radio button
147  int mXtermCount; // number of terminal window types
148 };
149 
150 
151 // Email tab of the Preferences dialog
152 class EmailPrefTab : public PrefsTabBase
153 {
154  TQ_OBJECT
155 
156  public:
157  EmailPrefTab(TQVBox*);
158 
159  TQString validate();
160  virtual void restore();
161  virtual void apply(bool syncToDisc);
162  virtual void setDefaults();
163 
164  private slots:
165  void slotEmailClientChanged(int);
166  void slotFromAddrChanged(int);
167  void slotBccAddrChanged(int);
168  void slotAddressChanged() { mAddressChanged = true; }
169 
170  private:
171  void setEmailAddress(Preferences::MailFrom, const TQString& address);
172  void setEmailBccAddress(bool useControlCentre, const TQString& address);
173  TQString validateAddr(ButtonGroup*, TQLineEdit* addr, const TQString& msg);
174 
175  ButtonGroup* mEmailClient;
176  ButtonGroup* mFromAddressGroup;
177  TQLineEdit* mEmailAddress;
178  ButtonGroup* mBccAddressGroup;
179  TQLineEdit* mEmailBccAddress;
180  TQCheckBox* mEmailQueuedNotify;
181  TQCheckBox* mEmailCopyToKMail;
182  bool mAddressChanged;
183  bool mBccAddressChanged;
184 };
185 
186 
187 // Edit defaults tab of the Preferences dialog
188 class EditPrefTab : public PrefsTabBase
189 {
190  TQ_OBJECT
191 
192  public:
193  EditPrefTab(TQVBox*);
194 
195  TQString validate();
196  virtual void restore();
197  virtual void apply(bool syncToDisc);
198  virtual void setDefaults();
199 
200  private slots:
201  void slotBrowseSoundFile();
202 
203  private:
204  TQCheckBox* mAutoClose;
205  TQCheckBox* mConfirmAck;
206  TQComboBox* mReminderUnits;
207  SpecialActionsButton* mSpecialActionsButton;
208  TQCheckBox* mCmdScript;
209  TQCheckBox* mCmdXterm;
210  TQCheckBox* mEmailBcc;
211  TQComboBox* mSound;
212  TQLabel* mSoundFileLabel;
213  TQLineEdit* mSoundFile;
214  TQPushButton* mSoundFileBrowse;
215  TQCheckBox* mSoundRepeat;
216  TQCheckBox* mCopyToKOrganizer;
217  TQCheckBox* mLateCancel;
218  TQComboBox* mRecurPeriod;
219  TQButtonGroup* mFeb29;
220 
221  static int soundIndex(SoundPicker::Type);
222  static int recurIndex(RecurrenceEdit::RepeatType);
223 };
224 
225 
226 // View tab of the Preferences dialog
227 class ViewPrefTab : public PrefsTabBase
228 {
229  TQ_OBJECT
230 
231  public:
232  ViewPrefTab(TQVBox*);
233 
234  virtual void restore();
235  virtual void apply(bool syncToDisc);
236  virtual void setDefaults();
237 
238  private slots:
239  void slotTooltipAlarmsToggled(bool);
240  void slotTooltipMaxToggled(bool);
241  void slotTooltipTimeToggled(bool);
242  void slotTooltipTimeToToggled(bool);
243 
244  private:
245  void setTooltip(int maxAlarms, bool time, bool timeTo, const TQString& prefix);
246 
247  TQCheckBox* mTooltipShowAlarms;
248  TQCheckBox* mTooltipMaxAlarms;
249  SpinBox* mTooltipMaxAlarmCount;
250  TQCheckBox* mTooltipShowTime;
251  TQCheckBox* mTooltipShowTimeTo;
252  TQLineEdit* mTooltipTimeToPrefix;
253  TQLabel* mTooltipTimeToPrefixLabel;
254  TQCheckBox* mModalMessages;
255  SpinBox* mDaemonTrayCheckInterval;
256 };
257 
258 
259 // Font & Colour tab of the Preferences dialog
260 class FontColourPrefTab : public PrefsTabBase
261 {
262  TQ_OBJECT
263 
264  public:
265  FontColourPrefTab(TQVBox*);
266 
267  virtual void restore();
268  virtual void apply(bool syncToDisc);
269  virtual void setDefaults();
270 
271  private:
272  FontColourChooser* mFontChooser;
273  KColorCombo* mDisabledColour;
274  KColorCombo* mExpiredColour;
275 };
276 
277 #endif // PREFDLG_H