File indexing completed on 2024-05-12 05:14:55
0001 /* 0002 * prefdlg_p.h - private classes for program preferences dialog 0003 * Program: kalarm 0004 * SPDX-FileCopyrightText: 2001-2024 David Jarvie <djarvie@kde.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "preferences.h" 0012 #include "prefdlg.h" 0013 #include "lib/stackedwidgets.h" 0014 0015 class QCheckBox; 0016 class QGroupBox; 0017 class QAbstractButton; 0018 class QRadioButton; 0019 class QPushButton; 0020 class QLabel; 0021 class QSpinBox; 0022 class QTimeZone; 0023 class QLineEdit; 0024 class QComboBox; 0025 class QVBoxLayout; 0026 class QTabWidget; 0027 class FontColourChooser; 0028 class CheckBox; 0029 class ColourButton; 0030 class ButtonGroup; 0031 class RadioButton; 0032 class TimeEdit; 0033 class TimePeriod; 0034 class Slider; 0035 class SpinBox; 0036 class TimeSpinBox; 0037 class SpecialActionsButton; 0038 class TimeZoneCombo; 0039 0040 0041 // Base class for each tab in the Preferences dialog 0042 class PrefsTabBase : public StackedScrollWidget 0043 { 0044 Q_OBJECT 0045 public: 0046 explicit PrefsTabBase(StackedScrollGroup*); 0047 0048 void setPreferences(); 0049 virtual void restore(bool defaults, bool allTabs) = 0; 0050 virtual bool apply(bool syncToDisc) = 0; 0051 void addAlignedLabel(QLabel*); 0052 QVBoxLayout* topLayout() const { return mTopLayout; } 0053 static int indentWidth() { return mIndentWidth; } 0054 static int gridIndentWidth() { return mGridIndentWidth; } 0055 0056 protected: 0057 void showEvent(QShowEvent*) override; 0058 0059 private: 0060 static int mIndentWidth; // indent width for checkboxes etc. 0061 static int mGridIndentWidth; // minimum grid column indent width for checkboxes etc. 0062 QVBoxLayout* mTopLayout; 0063 QList<QLabel*> mLabels; // labels to right-align 0064 bool mLabelsAligned {false}; // labels have been aligned 0065 }; 0066 0067 0068 // Miscellaneous tab of the Preferences dialog 0069 class MiscPrefTab : public PrefsTabBase 0070 { 0071 Q_OBJECT 0072 public: 0073 explicit MiscPrefTab(StackedScrollGroup*); 0074 0075 void restore(bool defaults, bool allTabs) override; 0076 bool apply(bool syncToDisc) override; 0077 0078 private Q_SLOTS: 0079 void slotAutostartClicked(); 0080 void slotOtherTerminalToggled(bool); 0081 0082 private: 0083 void setTimeZone(const QTimeZone&); 0084 0085 QCheckBox* mAutoStart; 0086 QCheckBox* mQuitWarn; 0087 QCheckBox* mUseAlarmNames; 0088 QCheckBox* mConfirmAlarmDeletion; 0089 QCheckBox* mUseAkonadi {nullptr}; 0090 TimeSpinBox* mDefaultDeferTime; 0091 ButtonGroup* mXtermType; 0092 QLineEdit* mXtermCommand; 0093 }; 0094 0095 0096 // Date/time tab of the Preferences dialog 0097 class TimePrefTab : public PrefsTabBase 0098 { 0099 Q_OBJECT 0100 public: 0101 explicit TimePrefTab(StackedScrollGroup*); 0102 0103 void restore(bool defaults, bool allTabs) override; 0104 bool apply(bool syncToDisc) override; 0105 0106 private: 0107 void setWorkDays(const QBitArray& days); 0108 0109 TimeZoneCombo* mTimeZone; 0110 QComboBox* mHolidays; 0111 QMap<QString, QString> mHolidayNames; 0112 TimeEdit* mStartOfDay; 0113 SpinBox* mPreWakeSuspend {nullptr}; 0114 QCheckBox* mWorkDays[7]; 0115 TimeEdit* mWorkStart; 0116 TimeEdit* mWorkEnd; 0117 TimeSpinBox* mKOrgEventDuration; 0118 }; 0119 0120 0121 // Storage tab of the Preferences dialog 0122 class StorePrefTab : public PrefsTabBase 0123 { 0124 Q_OBJECT 0125 public: 0126 explicit StorePrefTab(StackedScrollGroup*); 0127 0128 void restore(bool defaults, bool allTabs) override; 0129 bool apply(bool syncToDisc) override; 0130 0131 private Q_SLOTS: 0132 void slotArchivedToggled(bool); 0133 void slotClearArchived(); 0134 0135 private: 0136 void setArchivedControls(int purgeDays); 0137 0138 QRadioButton* mDefaultResource; 0139 QRadioButton* mAskResource; 0140 QCheckBox* mKeepArchived; 0141 QCheckBox* mPurgeArchived; 0142 SpinBox* mPurgeAfter; 0143 QLabel* mPurgeAfterLabel; 0144 QPushButton* mClearArchived; 0145 bool mOldKeepArchived; // previous setting of keep-archived 0146 bool mCheckKeepChanges {false}; 0147 }; 0148 0149 0150 // Email tab of the Preferences dialog 0151 class EmailPrefTab : public PrefsTabBase 0152 { 0153 Q_OBJECT 0154 public: 0155 explicit EmailPrefTab(StackedScrollGroup*); 0156 0157 QString validate(); 0158 void restore(bool defaults, bool allTabs) override; 0159 bool apply(bool syncToDisc) override; 0160 0161 protected: 0162 void showEvent(QShowEvent*) override; 0163 0164 private Q_SLOTS: 0165 void slotEmailClientChanged(QAbstractButton*); 0166 void slotFromAddrChanged(QAbstractButton*); 0167 void slotBccAddrChanged(QAbstractButton*); 0168 void slotAddressChanged() { mAddressChanged = true; } 0169 0170 private: 0171 void setEmailAddress(Preferences::MailFrom, const QString& address); 0172 void setEmailBccAddress(bool useSystemSettings, const QString& address); 0173 QString validateAddr(ButtonGroup*, QLineEdit* addr, const QString& msg); 0174 0175 ButtonGroup* mEmailClient; 0176 RadioButton* mKMailButton {nullptr}; 0177 RadioButton* mSendmailButton; 0178 ButtonGroup* mFromAddressGroup; 0179 RadioButton* mFromAddrButton; 0180 RadioButton* mFromCCentreButton; 0181 RadioButton* mFromKMailButton; 0182 QLineEdit* mEmailAddress; 0183 ButtonGroup* mBccAddressGroup; 0184 RadioButton* mBccAddrButton; 0185 RadioButton* mBccCCentreButton; 0186 QLineEdit* mEmailBccAddress; 0187 QCheckBox* mEmailQueuedNotify; 0188 QCheckBox* mEmailCopyToKMail {nullptr}; 0189 bool mAddressChanged {false}; 0190 bool mBccAddressChanged {false}; 0191 }; 0192 0193 0194 // Edit defaults tab of the Preferences dialog 0195 class EditPrefTab : public PrefsTabBase 0196 { 0197 Q_OBJECT 0198 public: 0199 explicit EditPrefTab(StackedScrollGroup*); 0200 0201 QString validate(); 0202 void restore(bool defaults, bool allTabs) override; 0203 bool apply(bool syncToDisc) override; 0204 0205 private Q_SLOTS: 0206 void slotBrowseSoundFile(); 0207 0208 private: 0209 QTabWidget* mTabs; 0210 QComboBox* mDisplayMethod; 0211 QCheckBox* mAutoClose; 0212 QCheckBox* mConfirmAck; 0213 QComboBox* mReminderUnits; 0214 SpecialActionsButton* mSpecialActionsButton; 0215 QCheckBox* mCmdScript; 0216 QCheckBox* mCmdXterm; 0217 QCheckBox* mEmailBcc; 0218 QComboBox* mSound; 0219 QLabel* mSoundFileLabel; 0220 QLineEdit* mSoundFile; 0221 QPushButton* mSoundFileBrowse; 0222 CheckBox* mSoundVolumeCheckbox; 0223 Slider* mSoundVolumeSlider; 0224 QCheckBox* mSoundRepeat; 0225 QCheckBox* mCopyToKOrganizer; 0226 QCheckBox* mLateCancel; 0227 ComboBox* mRecurPeriod; 0228 ButtonGroup* mFeb29; 0229 FontColourChooser* mFontChooser; 0230 int mTabGeneral; // index of General tab 0231 int mTabTypes; // index of Alarm Types tab 0232 int mTabFontColour; // index of Font & Color tab 0233 0234 static int soundIndex(Preferences::SoundType); 0235 }; 0236 0237 0238 // View tab of the Preferences dialog 0239 class ViewPrefTab : public PrefsTabBase 0240 { 0241 Q_OBJECT 0242 public: 0243 explicit ViewPrefTab(StackedScrollGroup*); 0244 0245 void restore(bool defaults, bool allTabs) override; 0246 bool apply(bool syncToDisc) override; 0247 0248 private Q_SLOTS: 0249 void slotTooltipAlarmsToggled(bool); 0250 void slotTooltipMaxToggled(bool); 0251 void slotTooltipTimeToggled(bool); 0252 void slotTooltipTimeToToggled(bool); 0253 void slotAutoHideSysTrayChanged(QAbstractButton*); 0254 void slotWindowPosChanged(QAbstractButton*); 0255 0256 private: 0257 void setTooltip(int maxAlarms, bool time, bool timeTo, const QString& prefix); 0258 0259 QTabWidget* mTabs; 0260 ColourButton* mDisabledColour; 0261 ColourButton* mArchivedColour; 0262 QCheckBox* mShowInSystemTrayCheck {nullptr}; 0263 QGroupBox* mShowInSystemTrayGroup {nullptr}; 0264 ButtonGroup* mAutoHideSystemTray {nullptr}; 0265 TimePeriod* mAutoHideSystemTrayPeriod {nullptr}; 0266 QCheckBox* mTooltipShowAlarms; 0267 QCheckBox* mTooltipMaxAlarms; 0268 SpinBox* mTooltipMaxAlarmCount; 0269 QCheckBox* mTooltipShowTime; 0270 QCheckBox* mTooltipShowTimeTo; 0271 QLineEdit* mTooltipTimeToPrefix; 0272 QLabel* mTooltipTimeToPrefixLabel; 0273 ButtonGroup* mWindowPosition {nullptr}; 0274 QSpinBox* mWindowButtonDelay; 0275 QLabel* mWindowButtonDelayLabel; 0276 QCheckBox* mModalMessages {nullptr}; 0277 int mTabGeneral; // index of General tab 0278 int mTabWindows; // index of Alarm Windows tab 0279 }; 0280 0281 // vim: et sw=4: