Commit cd14ee83 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Improve configure dialog

parent 06efeb7b
set(dkimverifyconfigure_SRCS
dkimconfiguredialog.cpp
dkimconfiguretab.cpp
dkimconfiguretabwidget.cpp
dkimconfigurewidget.cpp
dkimgeneralwidget.cpp
)
ecm_qt_declare_logging_category(dkimverifyconfigure_SRCS HEADER libdkimverifyconfigure_debug.h IDENTIFIER LIBDKIMVERIFYCONFIGURE_PLUGIN_LOG CATEGORY_NAME org.kde.pim.libdkimconfigureplugin)
......
......@@ -9,5 +9,5 @@ endmacro ()
add_messageviewer_dkim_verify_unittest(dkimconfiguredialogtest.cpp)
add_messageviewer_dkim_verify_unittest(dkimconfiguretabtest.cpp)
add_messageviewer_dkim_verify_unittest(dkimconfiguretabwidgettest.cpp)
add_messageviewer_dkim_verify_unittest(dkimconfigurewidgettest.cpp)
add_messageviewer_dkim_verify_unittest(dkimgeneralwidgettest.cpp)
......@@ -19,7 +19,6 @@
#include "dkimconfiguretabtest.h"
#include "../dkimconfiguretab.h"
#include <QCheckBox>
#include <QHBoxLayout>
#include <QTabWidget>
#include <QTest>
......@@ -38,12 +37,6 @@ void DKIMConfigureTabTest::shouldHaveDefaultValue()
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
QCheckBox *mEnableDkimSupport = w.findChild<QCheckBox *>(QStringLiteral("enableDkimSupport"));
QVERIFY(mEnableDkimSupport);
QVERIFY(!mEnableDkimSupport->text().isEmpty());
QVERIFY(!mEnableDkimSupport->isChecked());
QTabWidget *mTabWidget = w.findChild<QTabWidget *>(QStringLiteral("tabwidget"));
QVERIFY(mTabWidget);
}
/*
Copyright (C) 2018-2019 Laurent Montel <montel@kde.org>
Copyright (C) 2019 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -17,23 +17,32 @@
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguretabwidgettest.h"
#include "../dkimconfiguretabwidget.h"
#include "dkimgeneralwidgettest.h"
#include "dkimgeneralwidget.h"
#include <QCheckBox>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(DKIMConfigureTabWidgetTest)
DKIMConfigureTabWidgetTest::DKIMConfigureTabWidgetTest(QObject *parent)
QTEST_MAIN(DKIMGeneralWidgetTest)
DKIMGeneralWidgetTest::DKIMGeneralWidgetTest(QObject *parent)
: QObject(parent)
{
}
void DKIMConfigureTabWidgetTest::shouldHaveDefaultValue()
void DKIMGeneralWidgetTest::shouldHaveDefaultValues()
{
DKIMConfigureTabWidget w;
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
DKIMGeneralWidget w;
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
QCheckBox *mEnableDkimSupport = w.findChild<QCheckBox *>(QStringLiteral("enableDkimSupport"));
QVERIFY(mEnableDkimSupport);
QVERIFY(!mEnableDkimSupport->text().isEmpty());
QVERIFY(!mEnableDkimSupport->isChecked());
QCheckBox *mSaveResult = w.findChild<QCheckBox *>(QStringLiteral("mSaveResult"));
QVERIFY(mSaveResult);
QVERIFY(!mSaveResult->text().isEmpty());
QVERIFY(!mSaveResult->isChecked());
}
/*
Copyright (C) 2018-2019 Laurent Montel <montel@kde.org>
Copyright (C) 2019 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -17,19 +17,19 @@
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGURETABWIDGETTEST_H
#define DKIMCONFIGURETABWIDGETTEST_H
#ifndef DKIMGENERALWIDGETTEST_H
#define DKIMGENERALWIDGETTEST_H
#include <QObject>
class DKIMConfigureTabWidgetTest : public QObject
class DKIMGeneralWidgetTest : public QObject
{
Q_OBJECT
public:
explicit DKIMConfigureTabWidgetTest(QObject *parent = nullptr);
~DKIMConfigureTabWidgetTest() = default;
explicit DKIMGeneralWidgetTest(QObject *parent = nullptr);
~DKIMGeneralWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldHaveDefaultValues();
};
#endif // DKIMCONFIGURETABWIDGETTEST_H
#endif // DKIMGENERALWIDGETTEST_H
......@@ -18,11 +18,9 @@
*/
#include "dkimconfiguretab.h"
#include "dkimconfiguretabwidget.h"
#include "dkimgeneralwidget.h"
#include <KSharedConfig>
#include <KLocalizedString>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QRegularExpression>
#include <QTabWidget>
......@@ -34,42 +32,33 @@ DKIMConfigureTab::DKIMConfigureTab(QWidget *parent)
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mainLayout->setContentsMargins(0, 0, 0, 0);
mEnableDkimSupport = new QCheckBox(i18n("Enable DKimSupport"));
mEnableDkimSupport->setObjectName(QStringLiteral("enableDkimSupport"));
mainLayout->addWidget(mEnableDkimSupport);
mTabWidget = new QTabWidget(this);
mTabWidget->setObjectName(QStringLiteral("tabwidget"));
mainLayout->addWidget(mTabWidget);
initTab();
}
DKIMConfigureTab::~DKIMConfigureTab()
{
}
void DKIMConfigureTab::initTab()
{
mGeneralWidget = new DKIMGeneralWidget(this);
mTabWidget->addTab(mGeneralWidget, i18n("General"));
}
void DKIMConfigureTab::loadSettings()
{
for (DKIMConfigureTabWidget *w : qAsConst(mListTabWidget)) {
w->loadSettings();
}
mGeneralWidget->loadSettings();
}
void DKIMConfigureTab::saveSettings()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig();
// first, delete all filter groups:
const QStringList filterGroups = config->groupList().filter(QRegularExpression(QStringLiteral("DKIM \\d+")));
for (const QString &group : filterGroups) {
config->deleteGroup(group);
}
for (DKIMConfigureTabWidget *w : qAsConst(mListTabWidget)) {
w->saveSettings();
}
mGeneralWidget->saveSettings();
}
void DKIMConfigureTab::resetSettings()
{
for (DKIMConfigureTabWidget *w : qAsConst(mListTabWidget)) {
w->resetSettings();
}
mGeneralWidget->resetSettings();
}
......@@ -24,8 +24,7 @@
#include "dkimconfigure_private_export.h"
class QTabWidget;
class QCheckBox;
class DKIMConfigureTabWidget;
class DKIMGeneralWidget;
class LIBDKIMVERIFYCONFIGURE_TESTS_EXPORT DKIMConfigureTab : public QWidget
{
Q_OBJECT
......@@ -38,9 +37,9 @@ public:
void resetSettings();
private:
QList<DKIMConfigureTabWidget *> mListTabWidget;
void initTab();
DKIMGeneralWidget *mGeneralWidget = nullptr;
QTabWidget *mTabWidget = nullptr;
QCheckBox *mEnableDkimSupport = nullptr;
};
#endif // DKIMCONFIGURETAB_H
/*
Copyright (C) 2018-2019 Laurent Montel <montel@kde.org>
Copyright (C) 2019 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -17,35 +17,46 @@
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguretabwidget.h"
#include <KSharedConfig>
#include "dkimgeneralwidget.h"
#include <KLocalizedString>
#include <QCheckBox>
#include <QVBoxLayout>
DKIMConfigureTabWidget::DKIMConfigureTabWidget(QWidget *parent)
DKIMGeneralWidget::DKIMGeneralWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mainLayout->setObjectName(QStringLiteral("mainLayout"));
mainLayout->setContentsMargins(0, 0, 0, 0);
}
DKIMConfigureTabWidget::~DKIMConfigureTabWidget()
{
mEnableDkimSupport = new QCheckBox(i18n("Enable DKimSupport"));
mEnableDkimSupport->setObjectName(QStringLiteral("enableDkimSupport"));
mEnableDkimSupport->setChecked(false);
mainLayout->addWidget(mEnableDkimSupport);
mSaveResult = new QCheckBox(i18n("Save Result"));
mSaveResult->setObjectName(QStringLiteral("mSaveResult"));
mSaveResult->setChecked(false);
mainLayout->addWidget(mSaveResult);
}
void DKIMConfigureTabWidget::loadSettings()
DKIMGeneralWidget::~DKIMGeneralWidget()
{
}
void DKIMConfigureTabWidget::saveSettings()
void DKIMGeneralWidget::loadSettings()
{
//TODO
}
void DKIMConfigureTabWidget::resetSettings()
void DKIMGeneralWidget::saveSettings()
{
//TODO
}
void DKIMConfigureTabWidget::init()
void DKIMGeneralWidget::resetSettings()
{
//TODO
}
/*
Copyright (C) 2018-2019 Laurent Montel <montel@kde.org>
Copyright (C) 2019 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -17,24 +17,24 @@
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGURETABWIDGET_H
#define DKIMCONFIGURETABWIDGET_H
#include "dkimconfigure_private_export.h"
#ifndef DKIMGENERALWIDGET_H
#define DKIMGENERALWIDGET_H
#include <QWidget>
class LIBDKIMVERIFYCONFIGURE_TESTS_EXPORT DKIMConfigureTabWidget : public QWidget
#include "dkimconfigure_private_export.h"
class QCheckBox;
class LIBDKIMVERIFYCONFIGURE_TESTS_EXPORT DKIMGeneralWidget : public QWidget
{
Q_OBJECT
public:
explicit DKIMConfigureTabWidget(QWidget *parent = nullptr);
~DKIMConfigureTabWidget();
explicit DKIMGeneralWidget(QWidget *parent = nullptr);
~DKIMGeneralWidget();
void loadSettings();
void saveSettings();
void resetSettings();
private:
void init();
QCheckBox *mEnableDkimSupport = nullptr;
QCheckBox *mSaveResult = nullptr;
};
#endif // DKIMCONFIGURETABWIDGET_H
#endif // DKIMGENERALWIDGET_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