Commit 25b4c921 authored by Laurent Montel's avatar Laurent Montel 😁

Add new check

parent f6c01bf3
......@@ -2,8 +2,9 @@ set(kmail_checkbeforesendeditorplugin_SRCS
checkbeforesendplugin.cpp
checkbeforesendinterface.cpp
checkbeforesendconfigurewidget.cpp
checkduplicateemailsdialog.cpp
checkduplicateemailsjob.cpp
duplicateemails/checkduplicateemailsdialog.cpp
duplicateemails/checkduplicateemailsjob.cpp
sendattachments/checkattachmentdialog.cpp
)
ecm_qt_declare_logging_category(kmail_checkbeforesendeditorplugin_SRCS HEADER checkbeforesendplugin_debug.h IDENTIFIER KMAIL_EDITOR_checkbeforesend_PLUGIN_LOG CATEGORY_NAME log_kmail_checkbeforesendplugin)
......
......@@ -12,7 +12,9 @@ macro(add_kmail_checkbeforesend_unittest _source _additional)
endmacro ()
add_kmail_checkbeforesend_unittest(checkbeforesendplugintest.cpp "../checkduplicateemailsjob.cpp;../checkduplicateemailsdialog.cpp;../checkbeforesendplugin.cpp;../checkbeforesendinterface.cpp;../checkbeforesendconfigurewidget.cpp")
add_kmail_checkbeforesend_unittest(checkbeforesendplugintest.cpp "../sendattachments/checkattachmentdialog.cpp;../duplicateemails/checkduplicateemailsjob.cpp;../duplicateemails/checkduplicateemailsdialog.cpp;../checkbeforesendplugin.cpp;../checkbeforesendinterface.cpp;../checkbeforesendconfigurewidget.cpp")
add_kmail_checkbeforesend_unittest(checkbeforesendconfigurewidgettest.cpp "../checkbeforesendconfigurewidget.cpp")
add_kmail_checkbeforesend_unittest(checkduplicateemailsdialogtest.cpp "../checkduplicateemailsdialog.cpp")
add_kmail_checkbeforesend_unittest(checkduplicateemailsjobtest.cpp "../checkduplicateemailsjob.cpp")
add_kmail_checkbeforesend_unittest(checkduplicateemailsdialogtest.cpp "../duplicateemails/checkduplicateemailsdialog.cpp")
add_kmail_checkbeforesend_unittest(checkduplicateemailsjobtest.cpp "../duplicateemails/checkduplicateemailsjob.cpp")
add_kmail_checkbeforesend_unittest(checkattachmentdialogtest.cpp "../sendattachments/checkattachmentdialog.cpp")
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "checkattachmentdialogtest.h"
#include "../sendattachments/checkattachmentdialog.h"
#include <QDialogButtonBox>
#include <QLabel>
#include <QListWidget>
#include <QTest>
CheckAttachmentDialogTest::CheckAttachmentDialogTest(QObject *parent)
: QObject(parent)
{
}
CheckAttachmentDialogTest::~CheckAttachmentDialogTest()
{
}
void CheckAttachmentDialogTest::shouldHaveDefaultValue()
{
CheckAttachmentDialog w;
QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
QLabel *lab = w.findChild<QLabel *>(QStringLiteral("lab"));
QVERIFY(lab);
QVERIFY(!lab->text().isEmpty());
QListWidget *mListWidget = w.findChild<QListWidget *>(QStringLiteral("listwidget"));
QVERIFY(mListWidget);
QCOMPARE(mListWidget->count(), 0);
}
QTEST_MAIN(CheckAttachmentDialogTest)
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CHECKATTACHMENTDIALOGTEST_H
#define CHECKATTACHMENTDIALOGTEST_H
#include <QObject>
class CheckAttachmentDialogTest : public QObject
{
Q_OBJECT
public:
explicit CheckAttachmentDialogTest(QObject *parent = Q_NULLPTR);
~CheckAttachmentDialogTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // CHECKATTACHMENTDIALOGTEST_H
......@@ -54,6 +54,54 @@ void CheckBeforeSendConfigureWidgetTest::shouldHaveDefaultValue()
QVERIFY(mCheckDuplicateEmails);
QVERIFY(!mCheckDuplicateEmails->text().isEmpty());
QVERIFY(!mCheckDuplicateEmails->isChecked());
QCheckBox *mCheckSendAttachments = w.findChild<QCheckBox *>(QStringLiteral("checksendattachment"));
QVERIFY(mCheckSendAttachments);
QVERIFY(!mCheckSendAttachments->text().isEmpty());
QVERIFY(!mCheckSendAttachments->isChecked());
}
void CheckBeforeSendConfigureWidgetTest::shouldResetValue()
{
CheckBeforeSendConfigureWidget w;
QCheckBox *mCheckPlainTextMail = w.findChild<QCheckBox *>(QStringLiteral("checkplaintext"));
QCheckBox *mCheckMailTransport = w.findChild<QCheckBox *>(QStringLiteral("smtpdefinedinidentity"));
QCheckBox *mCheckDuplicateEmails = w.findChild<QCheckBox *>(QStringLiteral("checkduplicatedemails"));
QCheckBox *mCheckSendAttachments = w.findChild<QCheckBox *>(QStringLiteral("checksendattachment"));
mCheckMailTransport->setChecked(true);
mCheckDuplicateEmails->setChecked(true);
mCheckSendAttachments->setChecked(true);
mCheckPlainTextMail->setChecked(true);
QVERIFY(mCheckPlainTextMail->isChecked());
QVERIFY(mCheckMailTransport->isChecked());
QVERIFY(mCheckDuplicateEmails->isChecked());
QVERIFY(mCheckSendAttachments->isChecked());
mCheckMailTransport->setChecked(false);
mCheckDuplicateEmails->setChecked(false);
mCheckSendAttachments->setChecked(false);
mCheckPlainTextMail->setChecked(false);
QVERIFY(!mCheckPlainTextMail->isChecked());
QVERIFY(!mCheckMailTransport->isChecked());
QVERIFY(!mCheckDuplicateEmails->isChecked());
QVERIFY(!mCheckSendAttachments->isChecked());
mCheckMailTransport->setChecked(true);
mCheckDuplicateEmails->setChecked(true);
mCheckSendAttachments->setChecked(true);
mCheckPlainTextMail->setChecked(true);
w.resetSettings();
QVERIFY(!mCheckPlainTextMail->isChecked());
QVERIFY(!mCheckMailTransport->isChecked());
QVERIFY(!mCheckDuplicateEmails->isChecked());
QVERIFY(!mCheckSendAttachments->isChecked());
}
QTEST_MAIN(CheckBeforeSendConfigureWidgetTest)
......@@ -31,6 +31,7 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldResetValue();
};
#endif // CHECKBEFORESENDCONFIGUREWIDGETTEST_H
......@@ -18,7 +18,7 @@
*/
#include "checkduplicateemailsdialogtest.h"
#include "../checkduplicateemailsdialog.h"
#include "../duplicateemails/checkduplicateemailsdialog.h"
#include <QDialogButtonBox>
#include <QLabel>
#include <QListWidget>
......
......@@ -18,7 +18,7 @@
*/
#include "checkduplicateemailsjobtest.h"
#include "../checkduplicateemailsjob.h"
#include "../duplicateemails/checkduplicateemailsjob.h"
#include <QTest>
#include <QStringList>
......
......@@ -45,6 +45,11 @@ CheckBeforeSendConfigureWidget::CheckBeforeSendConfigureWidget(QWidget *parent)
connect(mCheckDuplicateEmails, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged);
mainLayout->addWidget(mCheckDuplicateEmails);
mCheckSendAttachments = new QCheckBox(i18n("Check send attachment"), this);
mCheckSendAttachments->setObjectName(QStringLiteral("checksendattachment"));
connect(mCheckSendAttachments, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged);
mainLayout->addWidget(mCheckSendAttachments);
mainLayout->addStretch(1);
}
......@@ -59,6 +64,7 @@ void CheckBeforeSendConfigureWidget::loadSettings()
mCheckPlainTextMail->setChecked(grp.readEntry("SendPlainText", false));
mCheckMailTransport->setChecked(grp.readEntry("SmtpDefinedInIdentity", false));
mCheckDuplicateEmails->setChecked(grp.readEntry("CheckDuplicatedEmails", false));
mCheckSendAttachments->setChecked(grp.readEntry("CheckSendAttachment", false));
}
void CheckBeforeSendConfigureWidget::saveSettings()
......@@ -67,10 +73,13 @@ void CheckBeforeSendConfigureWidget::saveSettings()
grp.writeEntry("SendPlainText", mCheckPlainTextMail->isChecked());
grp.writeEntry("SmtpDefinedInIdentity", mCheckMailTransport->isChecked());
grp.writeEntry("CheckDuplicatedEmails", mCheckDuplicateEmails->isChecked());
grp.writeEntry("CheckSendAttachment", mCheckSendAttachments->isChecked());
}
void CheckBeforeSendConfigureWidget::resetSettings()
{
mCheckPlainTextMail->setChecked(false);
mCheckMailTransport->setChecked(false);
mCheckSendAttachments->setChecked(false);
mCheckDuplicateEmails->setChecked(false);
}
......@@ -39,6 +39,7 @@ private:
QCheckBox *mCheckPlainTextMail;
QCheckBox *mCheckMailTransport;
QCheckBox *mCheckDuplicateEmails;
QCheckBox *mCheckSendAttachments;
};
#endif // CHECKBEFORESENDCONFIGUREWIDGET_H
......@@ -18,8 +18,9 @@
*/
#include "checkbeforesendinterface.h"
#include "checkduplicateemailsjob.h"
#include "checkduplicateemailsdialog.h"
#include "duplicateemails/checkduplicateemailsjob.h"
#include "duplicateemails/checkduplicateemailsdialog.h"
#include "sendattachments/checkattachmentdialog.h"
#include <KMessageBox>
#include <KConfigGroup>
......@@ -35,7 +36,8 @@ CheckBeforeSendInterface::CheckBeforeSendInterface(QObject *parent)
mIdentityManager(Q_NULLPTR),
mSendPlainText(false),
mCheckMailTransport(false),
mCheckDuplicateEmails(false)
mCheckDuplicateEmails(false),
mCheckSendAttachments(false)
{
reloadConfig();
}
......@@ -90,6 +92,9 @@ bool CheckBeforeSendInterface::exec(const MessageComposer::PluginEditorCheckBefo
}
}
}
if (mCheckSendAttachments) {
//TODO
}
return true;
}
......@@ -99,4 +104,5 @@ void CheckBeforeSendInterface::reloadConfig()
mSendPlainText = grp.readEntry("SendPlainText", false);
mCheckMailTransport = grp.readEntry("SmtpDefinedInIdentity", false);
mCheckDuplicateEmails = grp.readEntry("CheckDuplicatedEmails", false);
mCheckSendAttachments = grp.readEntry("CheckSendAttachment", false);
}
......@@ -41,6 +41,7 @@ private:
bool mSendPlainText;
bool mCheckMailTransport;
bool mCheckDuplicateEmails;
bool mCheckSendAttachments;
};
#endif // CHECKBEFORESENDINTERFACE_H
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "checkattachmentdialog.h"
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QLabel>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QListWidget>
CheckAttachmentDialog::CheckAttachmentDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QLabel *lab = new QLabel(i18n("Do you want to send some attachment?"), this);
lab->setObjectName(QStringLiteral("lab"));
mainLayout->addWidget(lab);
mListWidget = new QListWidget(this);
mListWidget->setObjectName(QStringLiteral("listwidget"));
mainLayout->addWidget(mListWidget);
QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
mainLayout->addWidget(buttonBox);
readConfig();
}
CheckAttachmentDialog::~CheckAttachmentDialog()
{
writeConfig();
}
void CheckAttachmentDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "CheckAttachmentDialog");
group.writeEntry("Size", size());
}
void CheckAttachmentDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "CheckAttachmentDialog");
const QSize sizeDialog = group.readEntry("Size", QSize(500, 300));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CHECKATTACHMENTDIALOG_H
#define CHECKATTACHMENTDIALOG_H
#include <QDialog>
class QListWidget;
class CheckAttachmentDialog : public QDialog
{
Q_OBJECT
public:
explicit CheckAttachmentDialog(QWidget *parent = Q_NULLPTR);
~CheckAttachmentDialog();
private:
void writeConfig();
void readConfig();
QListWidget *mListWidget;
};
#endif // CHECKATTACHMENTDIALOG_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment