File indexing completed on 2025-01-19 04:46:52
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "dkimpolicywidget.h" 0008 #include <KLocalizedString> 0009 #include <MessageViewer/DKIMManageRulesDialog> 0010 #include <MessageViewer/MessageViewerSettings> 0011 #include <QCheckBox> 0012 #include <QPushButton> 0013 #include <QSpacerItem> 0014 #include <QVBoxLayout> 0015 0016 DKIMPolicyWidget::DKIMPolicyWidget(QWidget *parent) 0017 : QWidget(parent) 0018 , mVerifyIfEmailMustBeSigned(new QCheckBox(i18n("Check if e-mail should be signed"), this)) 0019 , mUseDMARC(new QCheckBox(i18n("Use DMARC to heuristically determine if an e-mail should be signed"), this)) 0020 , mUseDefaultRules(new QCheckBox(i18n("Use default rule"), this)) 0021 , mAutoGenerateRule(new QCheckBox(i18n("Autogenerate rule"), this)) 0022 , mReadAuthResultHeader(new QCheckBox(i18n("Read Authentication-Results header"), this)) 0023 , mAutoGenerateOnlyIfSenderInSDID(new QCheckBox(i18n("Autogenerate when Sender in SDID"), this)) 0024 , mRulesButton(new QPushButton(i18n("Show Rules"), this)) 0025 { 0026 auto mainLayout = new QVBoxLayout(this); 0027 mainLayout->setObjectName(QLatin1StringView("mainLayout")); 0028 0029 mVerifyIfEmailMustBeSigned->setObjectName(QLatin1StringView("kcfg_CheckIfEmailShouldBeSigned")); 0030 mainLayout->addWidget(mVerifyIfEmailMustBeSigned); 0031 connect(mVerifyIfEmailMustBeSigned, &QCheckBox::toggled, this, [this](bool state) { 0032 mUseDMARC->setEnabled(state); 0033 mUseDefaultRules->setEnabled(state); 0034 mRulesButton->setEnabled(state); 0035 mAutoGenerateOnlyIfSenderInSDID->setEnabled(state); 0036 mAutoGenerateRule->setEnabled(state); 0037 mReadAuthResultHeader->setEnabled(state); 0038 }); 0039 0040 mUseDMARC->setObjectName(QLatin1StringView("kcfg_UseDMarc")); 0041 mUseDMARC->setEnabled(false); 0042 mainLayout->addWidget(mUseDMARC); 0043 0044 mReadAuthResultHeader->setObjectName(QLatin1StringView("kcfg_UseAuthenticationResults")); 0045 mReadAuthResultHeader->setEnabled(false); 0046 mainLayout->addWidget(mReadAuthResultHeader); 0047 0048 mUseDefaultRules->setObjectName(QLatin1StringView("kcfg_UseDefaultRules")); 0049 mUseDefaultRules->setEnabled(false); 0050 mainLayout->addWidget(mUseDefaultRules); 0051 0052 mAutoGenerateRule->setObjectName(QLatin1StringView("kcfg_AutogenerateRule")); 0053 mAutoGenerateRule->setEnabled(false); 0054 mainLayout->addWidget(mAutoGenerateRule); 0055 0056 auto autogenerateOnlyLayout = new QHBoxLayout; 0057 autogenerateOnlyLayout->setContentsMargins({}); 0058 mainLayout->addLayout(autogenerateOnlyLayout); 0059 0060 auto item = new QSpacerItem(30, 0); 0061 autogenerateOnlyLayout->addItem(item); 0062 0063 mAutoGenerateOnlyIfSenderInSDID->setObjectName(QLatin1StringView("kcfg_AutogenerateRuleOnlyIfSenderOnSDID")); 0064 mAutoGenerateOnlyIfSenderInSDID->setEnabled(false); 0065 autogenerateOnlyLayout->addWidget(mAutoGenerateOnlyIfSenderInSDID); 0066 0067 auto ruleLayout = new QHBoxLayout; 0068 mainLayout->addLayout(ruleLayout); 0069 mRulesButton->setObjectName(QLatin1StringView("rules")); 0070 mRulesButton->setEnabled(false); 0071 ruleLayout->addWidget(mRulesButton); 0072 connect(mRulesButton, &QPushButton::clicked, this, [this]() { 0073 MessageViewer::DKIMManageRulesDialog dlg(this); 0074 dlg.exec(); 0075 }); 0076 ruleLayout->addStretch(1); 0077 0078 mainLayout->addStretch(1); 0079 } 0080 0081 DKIMPolicyWidget::~DKIMPolicyWidget() = default; 0082 0083 #include "moc_dkimpolicywidget.cpp"