prefdlg.h
00001 /* 00002 * prefdlg.h - program preferences dialog 00003 * Program: kalarm 00004 * Copyright © 2001-2007 by David Jarvie <djarvie@kde.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef PREFDLG_H 00022 #define PREFDLG_H 00023 00024 #include <tqsize.h> 00025 #include <tqdatetime.h> 00026 #include <ktabctl.h> 00027 #include <kdialogbase.h> 00028 00029 #include "preferences.h" 00030 #include "recurrenceedit.h" 00031 #include "soundpicker.h" 00032 00033 class TQButtonGroup; 00034 class TQCheckBox; 00035 class TQRadioButton; 00036 class TQPushButton; 00037 class TQComboBox; 00038 class TQLineEdit; 00039 class KColorCombo; 00040 class FontColourChooser; 00041 class ButtonGroup; 00042 class TimeEdit; 00043 class SpinBox; 00044 class SpecialActionsButton; 00045 00046 class FontColourPrefTab; 00047 class EditPrefTab; 00048 class EmailPrefTab; 00049 class ViewPrefTab; 00050 class MiscPrefTab; 00051 00052 00053 // The Preferences dialog 00054 class KAlarmPrefDlg : public KDialogBase 00055 { 00056 Q_OBJECT 00057 TQ_OBJECT 00058 public: 00059 static void display(); 00060 ~KAlarmPrefDlg(); 00061 00062 FontColourPrefTab* mFontColourPage; 00063 EditPrefTab* mEditPage; 00064 EmailPrefTab* mEmailPage; 00065 ViewPrefTab* mViewPage; 00066 MiscPrefTab* mMiscPage; 00067 00068 protected slots: 00069 virtual void slotOk(); 00070 virtual void slotApply(); 00071 virtual void slotHelp(); 00072 virtual void slotDefault(); 00073 virtual void slotCancel(); 00074 00075 private: 00076 KAlarmPrefDlg(); 00077 void restore(); 00078 00079 static KAlarmPrefDlg* mInstance; 00080 bool mValid; 00081 }; 00082 00083 // Base class for each tab in the Preferences dialog 00084 class PrefsTabBase : public TQWidget 00085 { 00086 Q_OBJECT 00087 TQ_OBJECT 00088 public: 00089 PrefsTabBase(TQVBox*); 00090 00091 void setPreferences(); 00092 virtual void restore() = 0; 00093 virtual void apply(bool syncToDisc) = 0; 00094 virtual void setDefaults() = 0; 00095 static int indentWidth() { return mIndentWidth; } 00096 00097 protected: 00098 TQVBox* mPage; 00099 00100 private: 00101 static int mIndentWidth; // indent width for checkboxes etc. 00102 }; 00103 00104 00105 // Miscellaneous tab of the Preferences dialog 00106 class MiscPrefTab : public PrefsTabBase 00107 { 00108 Q_OBJECT 00109 TQ_OBJECT 00110 public: 00111 MiscPrefTab(TQVBox*); 00112 00113 virtual void restore(); 00114 virtual void apply(bool syncToDisc); 00115 virtual void setDefaults(); 00116 00117 private slots: 00118 void slotAutostartDaemonClicked(); 00119 void slotRunModeToggled(bool); 00120 void slotDisableIfStoppedToggled(bool); 00121 void slotExpiredToggled(bool); 00122 void slotClearExpired(); 00123 void slotOtherTerminalToggled(bool); 00124 //#ifdef AUTOSTART_BY_KALARMD 00125 void slotAutostartToggled(bool); 00126 //#endif 00127 00128 private: 00129 void setExpiredControls(int purgeDays); 00130 00131 TQCheckBox* mAutostartDaemon; 00132 TQRadioButton* mRunInSystemTray; 00133 TQRadioButton* mRunOnDemand; 00134 TQCheckBox* mDisableAlarmsIfStopped; 00135 TQCheckBox* mQuitWarn; 00136 TQCheckBox* mAutostartTrayIcon; 00137 TQCheckBox* mConfirmAlarmDeletion; 00138 TQCheckBox* mKeepExpired; 00139 TQCheckBox* mPurgeExpired; 00140 SpinBox* mPurgeAfter; 00141 TQLabel* mPurgeAfterLabel; 00142 TQPushButton* mClearExpired; 00143 TimeEdit* mStartOfDay; 00144 TQButtonGroup* mXtermType; 00145 TQLineEdit* mXtermCommand; 00146 int mXtermFirst; // id of first terminal window radio button 00147 int mXtermCount; // number of terminal window types 00148 }; 00149 00150 00151 // Email tab of the Preferences dialog 00152 class EmailPrefTab : public PrefsTabBase 00153 { 00154 Q_OBJECT 00155 TQ_OBJECT 00156 public: 00157 EmailPrefTab(TQVBox*); 00158 00159 TQString validate(); 00160 virtual void restore(); 00161 virtual void apply(bool syncToDisc); 00162 virtual void setDefaults(); 00163 00164 private slots: 00165 void slotEmailClientChanged(int); 00166 void slotFromAddrChanged(int); 00167 void slotBccAddrChanged(int); 00168 void slotAddressChanged() { mAddressChanged = true; } 00169 00170 private: 00171 void setEmailAddress(Preferences::MailFrom, const TQString& address); 00172 void setEmailBccAddress(bool useControlCentre, const TQString& address); 00173 TQString validateAddr(ButtonGroup*, TQLineEdit* addr, const TQString& msg); 00174 00175 ButtonGroup* mEmailClient; 00176 ButtonGroup* mFromAddressGroup; 00177 TQLineEdit* mEmailAddress; 00178 ButtonGroup* mBccAddressGroup; 00179 TQLineEdit* mEmailBccAddress; 00180 TQCheckBox* mEmailQueuedNotify; 00181 TQCheckBox* mEmailCopyToKMail; 00182 bool mAddressChanged; 00183 bool mBccAddressChanged; 00184 }; 00185 00186 00187 // Edit defaults tab of the Preferences dialog 00188 class EditPrefTab : public PrefsTabBase 00189 { 00190 Q_OBJECT 00191 TQ_OBJECT 00192 public: 00193 EditPrefTab(TQVBox*); 00194 00195 TQString validate(); 00196 virtual void restore(); 00197 virtual void apply(bool syncToDisc); 00198 virtual void setDefaults(); 00199 00200 private slots: 00201 void slotBrowseSoundFile(); 00202 00203 private: 00204 TQCheckBox* mAutoClose; 00205 TQCheckBox* mConfirmAck; 00206 TQComboBox* mReminderUnits; 00207 SpecialActionsButton* mSpecialActionsButton; 00208 TQCheckBox* mCmdScript; 00209 TQCheckBox* mCmdXterm; 00210 TQCheckBox* mEmailBcc; 00211 TQComboBox* mSound; 00212 TQLabel* mSoundFileLabel; 00213 TQLineEdit* mSoundFile; 00214 TQPushButton* mSoundFileBrowse; 00215 TQCheckBox* mSoundRepeat; 00216 TQCheckBox* mCopyToKOrganizer; 00217 TQCheckBox* mLateCancel; 00218 TQComboBox* mRecurPeriod; 00219 TQButtonGroup* mFeb29; 00220 00221 static int soundIndex(SoundPicker::Type); 00222 static int recurIndex(RecurrenceEdit::RepeatType); 00223 }; 00224 00225 00226 // View tab of the Preferences dialog 00227 class ViewPrefTab : public PrefsTabBase 00228 { 00229 Q_OBJECT 00230 TQ_OBJECT 00231 public: 00232 ViewPrefTab(TQVBox*); 00233 00234 virtual void restore(); 00235 virtual void apply(bool syncToDisc); 00236 virtual void setDefaults(); 00237 00238 private slots: 00239 void slotTooltipAlarmsToggled(bool); 00240 void slotTooltipMaxToggled(bool); 00241 void slotTooltipTimeToggled(bool); 00242 void slotTooltipTimeToToggled(bool); 00243 00244 private: 00245 void setTooltip(int maxAlarms, bool time, bool timeTo, const TQString& prefix); 00246 00247 TQCheckBox* mTooltipShowAlarms; 00248 TQCheckBox* mTooltipMaxAlarms; 00249 SpinBox* mTooltipMaxAlarmCount; 00250 TQCheckBox* mTooltipShowTime; 00251 TQCheckBox* mTooltipShowTimeTo; 00252 TQLineEdit* mTooltipTimeToPrefix; 00253 TQLabel* mTooltipTimeToPrefixLabel; 00254 TQCheckBox* mModalMessages; 00255 SpinBox* mDaemonTrayCheckInterval; 00256 }; 00257 00258 00259 // Font & Colour tab of the Preferences dialog 00260 class FontColourPrefTab : public PrefsTabBase 00261 { 00262 Q_OBJECT 00263 TQ_OBJECT 00264 public: 00265 FontColourPrefTab(TQVBox*); 00266 00267 virtual void restore(); 00268 virtual void apply(bool syncToDisc); 00269 virtual void setDefaults(); 00270 00271 private: 00272 FontColourChooser* mFontChooser; 00273 KColorCombo* mDisabledColour; 00274 KColorCombo* mExpiredColour; 00275 }; 00276 00277 #endif // PREFDLG_H