configureappearancepage.h 8.23 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
2
  SPDX-FileCopyrightText: 2013-2020 Laurent Montel <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3

4
  SPDX-License-Identifier: GPL-2.0-only
Laurent Montel's avatar
Laurent Montel committed
5 6 7 8 9 10
*/
#ifndef CONFIGUREAPPEARANCEPAGE_H
#define CONFIGUREAPPEARANCEPAGE_H

#include "kmail_export.h"
#include "configuredialog_p.h"
Laurent Montel's avatar
Laurent Montel committed
11
#include "MailCommon/Tag"
12
#include <QListWidgetItem>
Laurent Montel's avatar
Laurent Montel committed
13

14
class QPushButton;
Laurent Montel's avatar
Laurent Montel committed
15
class QCheckBox;
Laurent Montel's avatar
Laurent Montel committed
16
class QComboBox;
Laurent Montel's avatar
Laurent Montel committed
17 18 19 20 21
class KFontChooser;
class ColorListBox;
class QButtonGroup;
class QGroupBox;
class QSpinBox;
Laurent Montel's avatar
Laurent Montel committed
22
class QLineEdit;
23
class QModelIndex;
Laurent Montel's avatar
Laurent Montel committed
24
class KJob;
Laurent Montel's avatar
Laurent Montel committed
25
namespace MessageViewer {
Laurent Montel's avatar
Laurent Montel committed
26
class ConfigureWidget;
Laurent Montel's avatar
Laurent Montel committed
27
}
Laurent Montel's avatar
Laurent Montel committed
28

Laurent Montel's avatar
Laurent Montel committed
29 30
namespace MessageList {
namespace Utils {
Laurent Montel's avatar
Laurent Montel committed
31 32 33 34 35
class AggregationComboBox;
class ThemeComboBox;
}
}

Laurent Montel's avatar
Laurent Montel committed
36
namespace MailCommon {
Laurent Montel's avatar
Laurent Montel committed
37 38 39 40
class Tag;
typedef QSharedPointer<Tag> TagPtr;
}

Laurent Montel's avatar
Laurent Montel committed
41
namespace MailCommon {
Laurent Montel's avatar
Laurent Montel committed
42 43 44
class TagWidget;
}

Laurent Montel's avatar
Laurent Montel committed
45 46
class AppearancePageFontsTab : public ConfigModuleTab
{
Laurent Montel's avatar
Laurent Montel committed
47 48
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
49
    explicit AppearancePageFontsTab(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
50
    Q_REQUIRED_RESULT QString helpAnchor() const;
51
    void save() override;
Laurent Montel's avatar
Laurent Montel committed
52 53

private:
Laurent Montel's avatar
Laurent Montel committed
54
    void slotFontSelectorChanged(int);
55 56
    void doLoadOther() override;
    void doResetToDefaultsOther() override;
Laurent Montel's avatar
Laurent Montel committed
57 58

private:
Laurent Montel's avatar
Laurent Montel committed
59
    QCheckBox *mCustomFontCheck = nullptr;
Laurent Montel's avatar
Laurent Montel committed
60
    QComboBox *mFontLocationCombo = nullptr;
Laurent Montel's avatar
Laurent Montel committed
61
    KFontChooser *mFontChooser = nullptr;
Laurent Montel's avatar
Laurent Montel committed
62

Laurent Montel's avatar
Laurent Montel committed
63 64
    int mActiveFontIndex;
    QFont mFont[8];
Laurent Montel's avatar
Laurent Montel committed
65 66
};

Laurent Montel's avatar
Laurent Montel committed
67 68
class AppearancePageColorsTab : public ConfigModuleTab
{
Laurent Montel's avatar
Laurent Montel committed
69 70
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
71
    explicit AppearancePageColorsTab(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
72
    Q_REQUIRED_RESULT QString helpAnchor() const;
73
    void save() override;
Laurent Montel's avatar
Laurent Montel committed
74 75

private:
76 77
    void doLoadOther() override;
    void doResetToDefaultsOther() override;
Laurent Montel's avatar
Laurent Montel committed
78
    void loadColor(bool loadFromConfig);
Laurent Montel's avatar
Laurent Montel committed
79 80

private:
Laurent Montel's avatar
Laurent Montel committed
81 82 83 84
    QCheckBox *mCustomColorCheck = nullptr;
    ColorListBox *mColorList = nullptr;
    QCheckBox *mRecycleColorCheck = nullptr;
    QSpinBox *mCloseToQuotaThreshold = nullptr;
85
    QCheckBox *mUseInlineStyle = nullptr;
Laurent Montel's avatar
Laurent Montel committed
86 87
};

Laurent Montel's avatar
Laurent Montel committed
88 89
class AppearancePageLayoutTab : public ConfigModuleTab
{
Laurent Montel's avatar
Laurent Montel committed
90 91
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
92
    explicit AppearancePageLayoutTab(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
93
    Q_REQUIRED_RESULT QString helpAnchor() const;
Laurent Montel's avatar
Laurent Montel committed
94

95
    void save() override;
Laurent Montel's avatar
Laurent Montel committed
96 97

private:
98
    void doLoadOther() override;
Laurent Montel's avatar
Laurent Montel committed
99 100

private: // data
Laurent Montel's avatar
Laurent Montel committed
101 102 103 104 105 106 107 108 109
    QButtonGroup *mFolderListGroup = nullptr;
    QGroupBox *mFolderListGroupBox = nullptr;
    QButtonGroup *mReaderWindowModeGroup = nullptr;
    QGroupBox *mReaderWindowModeGroupBox = nullptr;
    QButtonGroup *mFolderToolTipsGroup = nullptr;
    QGroupBox *mFolderToolTipsGroupBox = nullptr;
    QButtonGroup *mFavoriteFoldersViewGroup = nullptr;
    QGroupBox *mFavoriteFoldersViewGroupBox = nullptr;
    QCheckBox *mFolderQuickSearchCB = nullptr;
Laurent Montel's avatar
Laurent Montel committed
110 111
};

Laurent Montel's avatar
Laurent Montel committed
112 113
class AppearancePageHeadersTab : public ConfigModuleTab
{
Laurent Montel's avatar
Laurent Montel committed
114 115
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
116
    explicit AppearancePageHeadersTab(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
117

Laurent Montel's avatar
Laurent Montel committed
118
    Q_REQUIRED_RESULT QString helpAnchor() const;
Laurent Montel's avatar
Laurent Montel committed
119

120
    void save() override;
Laurent Montel's avatar
Laurent Montel committed
121 122

private: // methods
123 124
    void doLoadFromGlobalSettings() override;
    void doLoadOther() override;
Laurent Montel's avatar
Laurent Montel committed
125
    // virtual void doResetToDefaultsOther();
Laurent Montel's avatar
Laurent Montel committed
126
    void setDateDisplay(int id, const QString &format);
127 128 129
    void slotLinkClicked(const QString &link);
    void slotSelectDefaultAggregation();
    void slotSelectDefaultTheme();
Laurent Montel's avatar
Laurent Montel committed
130 131

private: // data
Laurent Montel's avatar
Laurent Montel committed
132 133 134 135 136
    QCheckBox *mDisplayMessageToolTips = nullptr;
    MessageList::Utils::AggregationComboBox *mAggregationComboBox = nullptr;
    MessageList::Utils::ThemeComboBox *mThemeComboBox = nullptr;
    QButtonGroup *mDateDisplay = nullptr;
    QGroupBox *mDateDisplayBox = nullptr;
Laurent Montel's avatar
Laurent Montel committed
137
    QLineEdit *mCustomDateFormatEdit = nullptr;
Laurent Montel's avatar
Laurent Montel committed
138
    QString mCustomDateWhatsThis;
Laurent Montel's avatar
Laurent Montel committed
139 140
};

Laurent Montel's avatar
Laurent Montel committed
141
class AppearancePageGeneralTab : public ConfigModuleTab
Laurent Montel's avatar
Laurent Montel committed
142
{
Laurent Montel's avatar
Laurent Montel committed
143 144
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
145
    explicit AppearancePageGeneralTab(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
146 147 148

    QString helpAnchor() const;

149
    void save() override;
Laurent Montel's avatar
Laurent Montel committed
150 151

private:
152 153
    void doLoadOther() override;
    void doResetToDefaultsOther() override;
Laurent Montel's avatar
Laurent Montel committed
154 155

private: // data
Laurent Montel's avatar
Laurent Montel committed
156 157 158
    QCheckBox *mCloseAfterReplyOrForwardCheck = nullptr;
    MessageViewer::ConfigureWidget *mViewerSettings = nullptr;
    QCheckBox *mSystemTrayCheck = nullptr;
159
    QCheckBox *mStartInTrayCheck = nullptr;
160
    QCheckBox *mShowNumberInTaskBar = nullptr;
Laurent Montel's avatar
Laurent Montel committed
161 162 163 164 165
};

class TagListWidgetItem : public QListWidgetItem
{
public:
Laurent Montel's avatar
Laurent Montel committed
166 167
    explicit TagListWidgetItem(QListWidget *parent = nullptr);
    explicit TagListWidgetItem(const QIcon &icon, const QString &text, QListWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
168 169

    ~TagListWidgetItem();
Laurent Montel's avatar
Laurent Montel committed
170
    void setKMailTag(const MailCommon::Tag::Ptr &tag);
Laurent Montel's avatar
Laurent Montel committed
171 172 173 174 175 176 177
    MailCommon::Tag::Ptr kmailTag() const;
private:
    MailCommon::Tag::Ptr mTag;
};

/**Configuration tab in the appearance page for modifying the available set of
+message tags*/
Laurent Montel's avatar
Laurent Montel committed
178 179
class AppearancePageMessageTagTab : public ConfigModuleTab
{
Laurent Montel's avatar
Laurent Montel committed
180 181
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
182
    explicit AppearancePageMessageTagTab(QWidget *parent = nullptr);
183
    ~AppearancePageMessageTagTab() override;
Laurent Montel's avatar
Laurent Montel committed
184 185 186

    QString helpAnchor() const;

187
    void save() override;
Laurent Montel's avatar
Laurent Montel committed
188

Laurent Montel's avatar
Laurent Montel committed
189
public Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
190
    /**Enables/disables Add button according to whether @p aText is empty.
Laurent Montel's avatar
Laurent Montel committed
191 192 193 194
    Connected to signal of the line edit widget for adding tags
    @param aText String to change add button according to
    */
    void slotAddLineTextChanged(const QString &aText);
Laurent Montel's avatar
Laurent Montel committed
195 196 197 198 199 200 201
    /**Creates a generic tag with the visible name from the line edit widget for
    adding tags. Adds it to the end of the list and selects. Empties the line
    edit widget*/
    void slotAddNewTag();
    /**Removes the currently selected text in the list box.*/
    void slotRemoveTag();
    /**Increases the currently selected tag's priority and handles related visual
Laurent Montel's avatar
Laurent Montel committed
202
    changes*/
Laurent Montel's avatar
Laurent Montel committed
203 204
    void slotMoveTagUp();
    /**Decreases the currently selected tag's priority and handles related visual
Laurent Montel's avatar
Laurent Montel committed
205
    changes*/
Laurent Montel's avatar
Laurent Montel committed
206 207
    void slotMoveTagDown();

208
private:
Laurent Montel's avatar
Laurent Montel committed
209
    /*Handles necessary processing when the selection in the edit box changes.
Laurent Montel's avatar
Laurent Montel committed
210 211 212
    Records the unselected tag's information, and applies visual changes
    necessary depending on the description of the new tag. Private since doesn't
    change the selection of the edit box itself*/
Laurent Montel's avatar
Laurent Montel committed
213 214
    void slotSelectionChanged();
    /*This slot is necessary so that apply button is not activated when we are
Laurent Montel's avatar
Laurent Montel committed
215
    only applying visual changes after selecting a new tag in the list box*/
Laurent Montel's avatar
Laurent Montel committed
216 217
    void slotEmitChangeCheck();
    /*Transfers the tag settings from the widgets to the internal data structures.
Laurent Montel's avatar
Laurent Montel committed
218 219
    Private since passing a wrong parameter modifies another tag's data*/
    void slotRecordTagSettings(int aIndex);
Laurent Montel's avatar
Laurent Montel committed
220
    /*Transfers the tag settings from the internal data structures to the widgets.
Laurent Montel's avatar
Laurent Montel committed
221 222
    Private since passing a wrong parameter visualizes another tag's data*/
    void slotUpdateTagSettingWidgets(int aIndex);
Laurent Montel's avatar
Laurent Montel committed
223
    /*Transfers changes in the tag name edit box to the list box for tags. Private
Laurent Montel's avatar
Laurent Montel committed
224 225 226
    since calling externally decouples the name in the list box from name edit box*/
    void slotNameLineTextChanged(const QString &);
    void slotIconNameChanged(const QString &iconName);
Laurent Montel's avatar
Laurent Montel committed
227
    void slotRowsMoved(const QModelIndex &, int sourcestart, int sourceEnd, const QModelIndex &, int destinationRow);
228
    void slotTagsFetched(KJob *job);
Laurent Montel's avatar
Laurent Montel committed
229

230
    void slotDeleteTagJob(KJob *job);
231

232
    void doLoadFromGlobalSettings() override;
Laurent Montel's avatar
Laurent Montel committed
233
    void swapTagsInListBox(const int first, const int second);
Laurent Montel's avatar
Laurent Montel committed
234 235 236
    void updateButtons();

private: // data
Laurent Montel's avatar
Laurent Montel committed
237
    QLineEdit *mTagAddLineEdit = nullptr;
Laurent Montel's avatar
Laurent Montel committed
238 239 240 241
    QPushButton *mTagAddButton = nullptr;
    QPushButton *mTagRemoveButton = nullptr;
    QPushButton *mTagUpButton = nullptr;
    QPushButton *mTagDownButton = nullptr;
Laurent Montel's avatar
Laurent Montel committed
242

Laurent Montel's avatar
Laurent Montel committed
243
    QListWidget *mTagListBox = nullptr;
Laurent Montel's avatar
Laurent Montel committed
244

Laurent Montel's avatar
Laurent Montel committed
245 246
    QGroupBox *mTagsGroupBox = nullptr;
    QGroupBox *mTagSettingGroupBox = nullptr;
Laurent Montel's avatar
Laurent Montel committed
247

Laurent Montel's avatar
Laurent Montel committed
248
    MailCommon::TagWidget *mTagWidget = nullptr;
Laurent Montel's avatar
Laurent Montel committed
249 250 251 252 253 254 255 256 257

    // So we can compare to mMsgTagList and see if the user changed tags
    QList<MailCommon::TagPtr> mOriginalMsgTagList;

    /*Used to safely call slotRecordTagSettings when the selection in
    list box changes*/
    int mPreviousTag;
};

Laurent Montel's avatar
Laurent Montel committed
258 259
class KMAIL_EXPORT AppearancePage : public ConfigModuleWithTabs
{
Laurent Montel's avatar
Laurent Montel committed
260 261
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
262
    explicit AppearancePage(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
263

264
    QString helpAnchor() const override;
Laurent Montel's avatar
Laurent Montel committed
265 266 267 268 269 270

    // hrmpf. moc doesn't like nested classes with slots/signals...:
    typedef AppearancePageFontsTab FontsTab;
    typedef AppearancePageColorsTab ColorsTab;
    typedef AppearancePageLayoutTab LayoutTab;
    typedef AppearancePageHeadersTab HeadersTab;
Laurent Montel's avatar
Laurent Montel committed
271
    typedef AppearancePageGeneralTab ReaderTab;
Laurent Montel's avatar
Laurent Montel committed
272 273 274 275
    typedef AppearancePageMessageTagTab MessageTagTab;
};

#endif // CONFIGUREAPPEARANCEPAGE_H