File indexing completed on 2024-12-22 05:01:01
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only 0005 */ 0006 #pragma once 0007 0008 #include "MailCommon/Tag" 0009 #include "configuredialog_p.h" 0010 #include "kmail_export.h" 0011 #include <QListWidgetItem> 0012 0013 class QPushButton; 0014 class QCheckBox; 0015 class QComboBox; 0016 class KFontChooser; 0017 class ColorListBox; 0018 class QButtonGroup; 0019 class QGroupBox; 0020 class QSpinBox; 0021 class QLineEdit; 0022 class QModelIndex; 0023 class KJob; 0024 namespace MessageViewer 0025 { 0026 class ConfigureWidget; 0027 } 0028 0029 namespace MessageList 0030 { 0031 namespace Utils 0032 { 0033 class AggregationComboBox; 0034 class ThemeComboBox; 0035 } 0036 } 0037 0038 namespace MailCommon 0039 { 0040 class Tag; 0041 using TagPtr = QSharedPointer<Tag>; 0042 } 0043 0044 namespace MailCommon 0045 { 0046 class TagWidget; 0047 } 0048 0049 class AppearancePageFontsTab : public ConfigModuleTab 0050 { 0051 Q_OBJECT 0052 public: 0053 explicit AppearancePageFontsTab(QWidget *parent = nullptr); 0054 [[nodiscard]] QString helpAnchor() const; 0055 void save() override; 0056 0057 private: 0058 void slotFontSelectorChanged(int); 0059 void doLoadOther() override; 0060 void doResetToDefaultsOther() override; 0061 0062 private: 0063 QCheckBox *mCustomFontCheck = nullptr; 0064 QComboBox *mFontLocationCombo = nullptr; 0065 KFontChooser *mFontChooser = nullptr; 0066 0067 int mActiveFontIndex{-1}; 0068 QFont mFont[8]; 0069 }; 0070 0071 class AppearancePageColorsTab : public ConfigModuleTab 0072 { 0073 Q_OBJECT 0074 public: 0075 explicit AppearancePageColorsTab(QWidget *parent = nullptr); 0076 [[nodiscard]] QString helpAnchor() const; 0077 void save() override; 0078 0079 private: 0080 void doLoadOther() override; 0081 void doResetToDefaultsOther() override; 0082 void loadColor(bool loadFromConfig); 0083 0084 private: 0085 QCheckBox *mCustomColorCheck = nullptr; 0086 ColorListBox *mColorList = nullptr; 0087 QCheckBox *mRecycleColorCheck = nullptr; 0088 QSpinBox *mCloseToQuotaThreshold = nullptr; 0089 QCheckBox *mUseInlineStyle = nullptr; 0090 }; 0091 0092 class AppearancePageLayoutTab : public ConfigModuleTab 0093 { 0094 Q_OBJECT 0095 public: 0096 explicit AppearancePageLayoutTab(QWidget *parent = nullptr); 0097 [[nodiscard]] QString helpAnchor() const; 0098 0099 void save() override; 0100 0101 private: 0102 void doLoadOther() override; 0103 0104 private: // data 0105 QButtonGroup *mFolderListGroup = nullptr; 0106 QButtonGroup *mReaderWindowModeGroup = nullptr; 0107 QButtonGroup *mFolderToolTipsGroup = nullptr; 0108 QButtonGroup *mFavoriteFoldersViewGroup = nullptr; 0109 QCheckBox *mFolderQuickSearchCB = nullptr; 0110 }; 0111 0112 class AppearancePageHeadersTab : public ConfigModuleTab 0113 { 0114 Q_OBJECT 0115 public: 0116 explicit AppearancePageHeadersTab(QWidget *parent = nullptr); 0117 0118 [[nodiscard]] QString helpAnchor() const; 0119 0120 void save() override; 0121 0122 private: // methods 0123 void doLoadFromGlobalSettings() override; 0124 void doLoadOther() override; 0125 // virtual void doResetToDefaultsOther(); 0126 void setDateDisplay(int id, const QString &format); 0127 void slotLinkClicked(const QString &link); 0128 void slotSelectDefaultAggregation(); 0129 void slotSelectDefaultTheme(); 0130 0131 private: // data 0132 QCheckBox *mDisplayMessageToolTips = nullptr; 0133 MessageList::Utils::AggregationComboBox *mAggregationComboBox = nullptr; 0134 MessageList::Utils::ThemeComboBox *mThemeComboBox = nullptr; 0135 QButtonGroup *mDateDisplay = nullptr; 0136 QGroupBox *mDateDisplayBox = nullptr; 0137 QLineEdit *mCustomDateFormatEdit = nullptr; 0138 QString mCustomDateWhatsThis; 0139 }; 0140 0141 class AppearancePageGeneralTab : public ConfigModuleTab 0142 { 0143 Q_OBJECT 0144 public: 0145 explicit AppearancePageGeneralTab(QWidget *parent = nullptr); 0146 0147 QString helpAnchor() const; 0148 0149 void save() override; 0150 0151 private: 0152 void doLoadOther() override; 0153 void doResetToDefaultsOther() override; 0154 0155 private: // data 0156 QCheckBox *mCloseAfterReplyOrForwardCheck = nullptr; 0157 MessageViewer::ConfigureWidget *mViewerSettings = nullptr; 0158 QCheckBox *mSystemTrayCheck = nullptr; 0159 QCheckBox *mStartInTrayCheck = nullptr; 0160 QCheckBox *mShowNumberInTaskBar = nullptr; 0161 }; 0162 0163 class TagListWidgetItem : public QListWidgetItem 0164 { 0165 public: 0166 explicit TagListWidgetItem(QListWidget *parent = nullptr); 0167 explicit TagListWidgetItem(const QIcon &icon, const QString &text, QListWidget *parent = nullptr); 0168 0169 ~TagListWidgetItem() override; 0170 void setKMailTag(const MailCommon::Tag::Ptr &tag); 0171 MailCommon::Tag::Ptr kmailTag() const; 0172 0173 private: 0174 MailCommon::Tag::Ptr mTag; 0175 }; 0176 0177 /**Configuration tab in the appearance page for modifying the available set of 0178 +message tags*/ 0179 class AppearancePageMessageTagTab : public ConfigModuleTab 0180 { 0181 Q_OBJECT 0182 public: 0183 explicit AppearancePageMessageTagTab(QWidget *parent = nullptr); 0184 ~AppearancePageMessageTagTab() override; 0185 0186 QString helpAnchor() const; 0187 0188 void save() override; 0189 0190 public Q_SLOTS: 0191 /**Enables/disables Add button according to whether @p aText is empty. 0192 Connected to signal of the line edit widget for adding tags 0193 @param aText String to change add button according to 0194 */ 0195 void slotAddLineTextChanged(const QString &aText); 0196 /**Creates a generic tag with the visible name from the line edit widget for 0197 adding tags. Adds it to the end of the list and selects. Empties the line 0198 edit widget*/ 0199 void slotAddNewTag(); 0200 /**Removes the currently selected text in the list box.*/ 0201 void slotRemoveTag(); 0202 /**Increases the currently selected tag's priority and handles related visual 0203 changes*/ 0204 void slotMoveTagUp(); 0205 /**Decreases the currently selected tag's priority and handles related visual 0206 changes*/ 0207 void slotMoveTagDown(); 0208 0209 private: 0210 /*Handles necessary processing when the selection in the edit box changes. 0211 Records the unselected tag's information, and applies visual changes 0212 necessary depending on the description of the new tag. Private since doesn't 0213 change the selection of the edit box itself*/ 0214 void slotSelectionChanged(); 0215 /*This slot is necessary so that apply button is not activated when we are 0216 only applying visual changes after selecting a new tag in the list box*/ 0217 void slotEmitChangeCheck(); 0218 /*Transfers the tag settings from the widgets to the internal data structures. 0219 Private since passing a wrong parameter modifies another tag's data*/ 0220 void slotRecordTagSettings(int aIndex); 0221 /*Transfers the tag settings from the internal data structures to the widgets. 0222 Private since passing a wrong parameter visualizes another tag's data*/ 0223 void slotUpdateTagSettingWidgets(int aIndex); 0224 /*Transfers changes in the tag name edit box to the list box for tags. Private 0225 since calling externally decouples the name in the list box from name edit box*/ 0226 void slotNameLineTextChanged(const QString &); 0227 void slotIconNameChanged(const QString &iconName); 0228 void slotRowsMoved(const QModelIndex &, int sourcestart, int sourceEnd, const QModelIndex &, int destinationRow); 0229 void slotTagsFetched(KJob *job); 0230 0231 void slotDeleteTagJob(KJob *job); 0232 0233 void doLoadFromGlobalSettings() override; 0234 void swapTagsInListBox(const int first, const int second); 0235 void updateButtons(); 0236 void slotCustomMenuRequested(const QPoint &pos); 0237 0238 private: // data 0239 QLineEdit *mTagAddLineEdit = nullptr; 0240 QPushButton *mTagAddButton = nullptr; 0241 QPushButton *mTagRemoveButton = nullptr; 0242 QPushButton *mTagUpButton = nullptr; 0243 QPushButton *mTagDownButton = nullptr; 0244 0245 QListWidget *mTagListBox = nullptr; 0246 0247 QGroupBox *mTagsGroupBox = nullptr; 0248 QGroupBox *mTagSettingGroupBox = nullptr; 0249 0250 MailCommon::TagWidget *mTagWidget = nullptr; 0251 0252 // So we can compare to mMsgTagList and see if the user changed tags 0253 QList<MailCommon::TagPtr> mOriginalMsgTagList; 0254 0255 /*Used to safely call slotRecordTagSettings when the selection in 0256 list box changes*/ 0257 int mPreviousTag; 0258 }; 0259 0260 class KMAIL_EXPORT AppearancePage : public ConfigModuleWithTabs 0261 { 0262 Q_OBJECT 0263 public: 0264 explicit AppearancePage(QObject *parent, const KPluginMetaData &data); 0265 0266 QString helpAnchor() const override; 0267 };