summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-02 05:28:13 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-02 05:28:13 (GMT)
commite11ff25b73aff4d401115df1927bfe239b3b4498 (patch)
tree3418b7fc66566cac3feb61ce8fd97e2f88ac97fa
parent83c82e9d96a6898f9a4776b56f70b1ad36bbf8a3 (diff)
Now we can enable/disable plugin => we don't need to have another
checkbox to enable/disable it
-rw-r--r--kmail/editorsendcheckplugins/confirm-address/autotests/confirmaddressconfigurewidgettest.cpp3
-rw-r--r--kmail/editorsendcheckplugins/confirm-address/confirmaddressconfigurewidget.cpp7
-rw-r--r--kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.cpp72
-rw-r--r--kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.h1
4 files changed, 33 insertions, 50 deletions
diff --git a/kmail/editorsendcheckplugins/confirm-address/autotests/confirmaddressconfigurewidgettest.cpp b/kmail/editorsendcheckplugins/confirm-address/autotests/confirmaddressconfigurewidgettest.cpp
index a8b7a52..fed21a0 100644
--- a/kmail/editorsendcheckplugins/confirm-address/autotests/confirmaddressconfigurewidgettest.cpp
+++ b/kmail/editorsendcheckplugins/confirm-address/autotests/confirmaddressconfigurewidgettest.cpp
@@ -42,9 +42,6 @@ void ConfirmAddressConfigureWidgetTest::shouldHaveDefaultValue()
QVBoxLayout *vboxlayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(vboxlayout);
- QCheckBox *enable = w.findChild<QCheckBox *>(QStringLiteral("enable"));
- QVERIFY(enable);
- QVERIFY(!enable->isChecked());
ConfirmAddressConfigureTab *mConfirmAddressConfigureTab = w.findChild<ConfirmAddressConfigureTab *>(QStringLiteral("confirmaddresstab"));
QVERIFY(mConfirmAddressConfigureTab);
diff --git a/kmail/editorsendcheckplugins/confirm-address/confirmaddressconfigurewidget.cpp b/kmail/editorsendcheckplugins/confirm-address/confirmaddressconfigurewidget.cpp
index a6d45c1..355ffb1 100644
--- a/kmail/editorsendcheckplugins/confirm-address/confirmaddressconfigurewidget.cpp
+++ b/kmail/editorsendcheckplugins/confirm-address/confirmaddressconfigurewidget.cpp
@@ -32,11 +32,6 @@ ConfirmAddressConfigureWidget::ConfirmAddressConfigureWidget(QWidget *parent)
QVBoxLayout *vboxlayout = new QVBoxLayout(this);
vboxlayout->setMargin(0);
vboxlayout->setObjectName(QStringLiteral("mainlayout"));
- mEnable = new QCheckBox(i18n("Enable"), this);
- mEnable->setObjectName(QStringLiteral("enable"));
- vboxlayout->addWidget(mEnable);
- connect(mEnable, &QCheckBox::clicked, this, &ConfirmAddressConfigureWidget::slotEnableChanged);
-
mConfirmAddressConfigureTab = new ConfirmAddressConfigureTab(this);
mConfirmAddressConfigureTab->setObjectName(QStringLiteral("confirmaddresstab"));
connect(mConfirmAddressConfigureTab, &ConfirmAddressConfigureTab::configureChanged, this, &ConfirmAddressConfigureWidget::configureChanged);
@@ -51,7 +46,6 @@ ConfirmAddressConfigureWidget::~ConfirmAddressConfigureWidget()
void ConfirmAddressConfigureWidget::loadSettings()
{
KConfigGroup grp(KSharedConfig::openConfig(), "Confirm Address");
- mEnable->setChecked(grp.readEntry("Enabled", false));
mConfirmAddressConfigureTab->loadSettings(grp);
}
@@ -64,7 +58,6 @@ void ConfirmAddressConfigureWidget::saveSettings()
config->deleteGroup(group);
}
KConfigGroup grp(config, "Confirm Address");
- grp.writeEntry("Enabled", mEnable->isChecked());
mConfirmAddressConfigureTab->saveSettings(grp);
}
diff --git a/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.cpp b/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.cpp
index 655ec25..55ac460 100644
--- a/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.cpp
+++ b/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.cpp
@@ -31,8 +31,7 @@
#include <MessageComposer/AliasesExpandJob>
ConfirmAddressInterface::ConfirmAddressInterface(QObject *parent)
- : MessageComposer::PluginEditorCheckBeforeSendInterface(parent),
- mEnabled(false)
+ : MessageComposer::PluginEditorCheckBeforeSendInterface(parent)
{
}
@@ -43,47 +42,43 @@ ConfirmAddressInterface::~ConfirmAddressInterface()
bool ConfirmAddressInterface::exec(const MessageComposer::PluginEditorCheckBeforeSendParams &params)
{
- if (mEnabled) {
- const QStringList lst{ params.bccAddresses(), params.toAddresses(), params.ccAddresses() };
- if (lst.isEmpty()) {
- return true;
- }
- // not configurated => validate it.
- const ConfirmAddressSettings settings = mHashSettings.value(params.identity());
- if (settings.mDomains.isEmpty() && settings.mWhiteLists.isEmpty()) {
- return true;
- }
- const QString str = lst.join(QStringLiteral(", "));
- const QStringList emails = str.split(QStringLiteral(", "));
+ const QStringList lst{ params.bccAddresses(), params.toAddresses(), params.ccAddresses() };
+ if (lst.isEmpty()) {
+ return true;
+ }
+ // not configurated => validate it.
+ const ConfirmAddressSettings settings = mHashSettings.value(params.identity());
+ if (settings.mDomains.isEmpty() && settings.mWhiteLists.isEmpty()) {
+ return true;
+ }
+ const QString str = lst.join(QStringLiteral(", "));
+ const QStringList emails = str.split(QStringLiteral(", "));
#if 0
- MessageComposer::AliasesExpandJob job(params.addresses().join(QStringLiteral(", ")), params.defaultDomain(), this);
- if (job.exec()) {
- emails = job.emailAddressOnly();
- }
+ MessageComposer::AliasesExpandJob job(params.addresses().join(QStringLiteral(", ")), params.defaultDomain(), this);
+ if (job.exec()) {
+ emails = job.emailAddressOnly();
+ }
#endif
- ConfirmAddressCheckJob job;
- job.setCheckSettings(settings.mDomains, settings.mWhiteLists);
- job.setAddressList(emails);
- job.start();
+ ConfirmAddressCheckJob job;
+ job.setCheckSettings(settings.mDomains, settings.mWhiteLists);
+ job.setAddressList(emails);
+ job.start();
- const QStringList invalidEmails = job.invalidEmails();
- const QStringList validEmails = job.validEmails();
+ const QStringList invalidEmails = job.invalidEmails();
+ const QStringList validEmails = job.validEmails();
- if (!invalidEmails.isEmpty()) {
- QPointer<ConfirmAddressDialog> dlg = new ConfirmAddressDialog(parentWidget());
- connect(dlg.data(), &ConfirmAddressDialog::addWhileListEmails, this, &ConfirmAddressInterface::slotAddWhiteListEmails);
- dlg->setCurrentIdentity(params.identity());
- dlg->setValidAddresses(validEmails);
- dlg->setInvalidAddresses(invalidEmails);
- if (dlg->exec()) {
- delete dlg;
- return true;
- } else {
- delete dlg;
- return false;
- }
- } else {
+ if (!invalidEmails.isEmpty()) {
+ QPointer<ConfirmAddressDialog> dlg = new ConfirmAddressDialog(parentWidget());
+ connect(dlg.data(), &ConfirmAddressDialog::addWhileListEmails, this, &ConfirmAddressInterface::slotAddWhiteListEmails);
+ dlg->setCurrentIdentity(params.identity());
+ dlg->setValidAddresses(validEmails);
+ dlg->setInvalidAddresses(invalidEmails);
+ if (dlg->exec()) {
+ delete dlg;
return true;
+ } else {
+ delete dlg;
+ return false;
}
} else {
return true;
@@ -108,7 +103,6 @@ void ConfirmAddressInterface::slotAddWhiteListEmails(const QStringList &lst, uin
void ConfirmAddressInterface::reloadConfig()
{
KConfigGroup grp(KSharedConfig::openConfig(), "Confirm Address");
- mEnabled = grp.readEntry("Enabled", false);
mHashSettings.clear();
KIdentityManagement::IdentityManager *im = KIdentityManagement::IdentityManager::self();
diff --git a/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.h b/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.h
index 67e3e7b..5618fe0 100644
--- a/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.h
+++ b/kmail/editorsendcheckplugins/confirm-address/confirmaddressinterface.h
@@ -38,7 +38,6 @@ public Q_SLOTS:
private:
void slotAddWhiteListEmails(const QStringList &lst, uint currentIdentity);
- bool mEnabled;
struct ConfirmAddressSettings {
QStringList mDomains;