7#include "collectionviewwidget.h"
8#include "mailcommon_debug.h"
9#include <KLocalizedString>
12#include <Akonadi/MessageFolderAttribute>
13#include <MessageList/AggregationComboBox>
14#include <MessageList/AggregationConfigButton>
15#include <MessageList/ThemeComboBox>
16#include <MessageList/ThemeConfigButton>
18#include <MessageViewer/Viewer>
22#include <QRadioButton>
24CollectionViewWidget::CollectionViewWidget(
QWidget *parent)
26 , mShowSenderReceiverComboBox(new
QComboBox(this))
27 , mUseDefaultAggregationCheckBox(new
QCheckBox(
i18nc(
"@option:check",
"Use default message list aggregation:"), this))
28 , mAggregationComboBox(new
MessageList::Utils::AggregationComboBox(this))
29 , mUseDefaultThemeCheckBox(new
QCheckBox(
i18nc(
"@option:check",
"Use default message list theme"), this))
30 , mThemeComboBox(new
MessageList::Utils::ThemeComboBox(this))
31 , mPreferHtmlToText(new
QRadioButton(
i18nc(
"@option:radio",
"Prefer HTML to text"), this))
32 , mPreferTextToHtml(new
QRadioButton(
i18nc(
"@option:radio",
"Prefer text to HTML"), this))
33 , mUseGlobalSettings(new
QRadioButton(
i18nc(
"@option:radio",
"Use Global Settings"), this))
37 topLayout->setContentsMargins({});
40 const QString senderReceiverColumnTip =
i18n(
"Show Sender/Receiver Column in List of Messages");
42 mShowSenderReceiverComboBox->setToolTip(senderReceiverColumnTip);
43 mShowSenderReceiverComboBox->insertItem(0,
i18nc(
"@item:inlistbox Show default value.",
"Default"));
44 mShowSenderReceiverComboBox->insertItem(1,
i18nc(
"@item:inlistbox Show sender.",
"Sender"));
45 mShowSenderReceiverComboBox->insertItem(2,
i18nc(
"@item:inlistbox Show receiver.",
"Receiver"));
46 topLayout->addRow(
i18n(
"Sho&w column:"), mShowSenderReceiverComboBox);
49 connect(mUseDefaultAggregationCheckBox, &QCheckBox::checkStateChanged,
this, &CollectionViewWidget::slotAggregationCheckboxChanged);
50 topLayout->addRow(
QString(), mUseDefaultAggregationCheckBox);
53 auto aggregationConfigButton =
new AggregationConfigButton(
this, mAggregationComboBox);
55 connect(aggregationConfigButton, &AggregationConfigButton::configureDialogCompleted,
this, &CollectionViewWidget::slotSelectFolderAggregation);
58 aggregationLayout->
addWidget(mAggregationComboBox, 1);
59 aggregationLayout->addWidget(aggregationConfigButton, 0);
60 topLayout->addRow(
QString(), aggregationLayout);
63 connect(mUseDefaultThemeCheckBox, &QCheckBox::checkStateChanged,
this, &CollectionViewWidget::slotThemeCheckboxChanged);
64 topLayout->addRow(
QString(), mUseDefaultThemeCheckBox);
67 auto themeConfigButton =
new ThemeConfigButton(
this, mThemeComboBox);
69 connect(themeConfigButton, &ThemeConfigButton::configureDialogCompleted,
this, &CollectionViewWidget::slotSelectFolderTheme);
72 themeLayout->
addWidget(mThemeComboBox, 1);
73 themeLayout->addWidget(themeConfigButton, 0);
74 topLayout->addRow(
QString(), themeLayout);
77 topLayout->addRow(
i18n(
"Message format:"), mPreferHtmlToText);
78 topLayout->addRow(
QString(), mPreferTextToHtml);
79 topLayout->addRow(
QString(), mUseGlobalSettings);
82CollectionViewWidget::~CollectionViewWidget() =
default;
86 mCurrentCollection = col;
87 mFolderCollection = MailCommon::FolderSettings::forCollection(col);
98 mShowSenderReceiverValue = mShowSenderReceiverComboBox->
currentIndex();
101 slotSelectFolderAggregation();
104 slotSelectFolderTheme();
106 const MessageViewer::Viewer::DisplayFormatMessage formatMessage = mFolderCollection->formatMessage();
107 switch (formatMessage) {
108 case MessageViewer::Viewer::Html:
111 case MessageViewer::Viewer::Text:
114 case MessageViewer::Viewer::UseGlobalSetting:
118 qCDebug(MAILCOMMON_LOG) <<
"No settings defined";
125 if (!mFolderCollection) {
126 mFolderCollection = MailCommon::FolderSettings::forCollection(col);
128 const int currentIndex = mShowSenderReceiverComboBox->
currentIndex();
129 if (mShowSenderReceiverValue != currentIndex) {
130 if (currentIndex == 1) {
133 }
else if (currentIndex == 2) {
141 const bool usePrivateTheme = !mUseDefaultThemeCheckBox->
isChecked();
142 mThemeComboBox->writeStorageModelConfig(
QString::number(mCurrentCollection.
id()), usePrivateTheme);
144 const bool usePrivateAggregation = !mUseDefaultAggregationCheckBox->
isChecked();
145 mAggregationComboBox->writeStorageModelConfig(
QString::number(mCurrentCollection.
id()), usePrivateAggregation);
147 MessageViewer::Viewer::DisplayFormatMessage formatMessage = MessageViewer::Viewer::Unknown;
149 formatMessage = MessageViewer::Viewer::Html;
150 }
else if (mPreferTextToHtml->
isChecked()) {
151 formatMessage = MessageViewer::Viewer::Text;
152 }
else if (mUseGlobalSettings->
isChecked()) {
153 formatMessage = MessageViewer::Viewer::UseGlobalSetting;
155 qCDebug(MAILCOMMON_LOG) <<
"No settings defined";
157 if (formatMessage != MessageViewer::Viewer::Unknown) {
158 mFolderCollection->setFormatMessage(formatMessage);
159 mFolderCollection->writeConfig();
161 mFolderCollection.
reset();
164void CollectionViewWidget::slotSelectFolderAggregation()
166 bool usesPrivateAggregation =
false;
167 mAggregationComboBox->readStorageModelConfig(mCurrentCollection, usesPrivateAggregation);
168 mUseDefaultAggregationCheckBox->
setChecked(!usesPrivateAggregation);
171void CollectionViewWidget::slotSelectFolderTheme()
173 bool usesPrivateTheme =
false;
174 mThemeComboBox->readStorageModelConfig(mCurrentCollection, usesPrivateTheme);
175 mUseDefaultThemeCheckBox->
setChecked(!usesPrivateTheme);
178void CollectionViewWidget::slotAggregationCheckboxChanged()
183void CollectionViewWidget::slotThemeCheckboxChanged()
188#include "moc_collectionviewwidget.cpp"
const T * attribute() const
bool hasAttribute() const
void setOutboundFolder(bool outbound)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void setCurrentIndex(int index)
QString number(double n, char format, int precision)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)