9 #include "messageformattingwidget.h"
10 #include "editor/utils/utils.h"
11 #include <KLocalizedString>
16 #include <QVBoxLayout>
17 using namespace ContactEditor;
19 MessageFormattingWidget::MessageFormattingWidget(
QWidget *parent)
21 , mMailPreferFormatting(new
QComboBox(this))
22 , mAllowRemoteContent(new
QCheckBox(
i18n(
"Allow remote content in received HTML messages"), this))
25 topLayout->setContentsMargins({});
26 auto label =
new QLabel(
i18n(
"Show messages received from this contact as:"),
this);
27 label->setObjectName(QStringLiteral(
"label"));
28 topLayout->addWidget(label);
30 mMailPreferFormatting->setObjectName(QStringLiteral(
"mMailPreferFormatting"));
31 topLayout->addWidget(mMailPreferFormatting);
32 label->setBuddy(mMailPreferFormatting);
34 mMailPreferFormatting->addItems(listFormat);
36 mAllowRemoteContent->setObjectName(QStringLiteral(
"mAllowRemoteContent"));
37 topLayout->addWidget(mAllowRemoteContent);
40 MessageFormattingWidget::~MessageFormattingWidget() =
default;
44 const QString mailAllowToRemoteContent = ContactEditor::Utils::loadCustom(contact, QStringLiteral(
"MailAllowToRemoteContent"));
45 mAllowRemoteContent->setChecked(mailAllowToRemoteContent ==
QLatin1String(
"TRUE"));
47 const QString mailPreferedFormatting = ContactEditor::Utils::loadCustom(contact, QStringLiteral(
"MailPreferedFormatting"));
48 if (mailPreferedFormatting.
isEmpty()) {
49 mMailPreferFormatting->setCurrentIndex(0);
51 mMailPreferFormatting->setCurrentIndex(1);
53 mMailPreferFormatting->setCurrentIndex(2);
55 mMailPreferFormatting->setCurrentIndex(0);
62 const int index = mMailPreferFormatting->currentIndex();
65 }
else if (index == 1) {
66 mailPreferedFormatting = QStringLiteral(
"TEXT");
67 }
else if (index == 2) {
68 mailPreferedFormatting = QStringLiteral(
"HTML");
70 ContactEditor::Utils::storeCustom(contact, QStringLiteral(
"MailPreferedFormatting"), mailPreferedFormatting);
72 QString mailAllowToRemoteContent;
73 if (mAllowRemoteContent->isChecked()) {
74 mailAllowToRemoteContent = QStringLiteral(
"TRUE");
76 ContactEditor::Utils::storeCustom(contact, QStringLiteral(
"MailAllowToRemoteContent"), mailAllowToRemoteContent);
79 void MessageFormattingWidget::setReadOnly(
bool readOnly)
81 mMailPreferFormatting->setEnabled(!readOnly);
82 mAllowRemoteContent->setEnabled(!readOnly);