Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 37262c9a authored by Laurent Montel's avatar Laurent Montel 😁

Fix config here

parent 6132b80a
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguredialogtest.h"
#include "dkim-verify/dkimconfiguredialog.h"
#include "dkim-verify/dkimconfigurewidget.h"
#include <QTest>
#include <QStandardPaths>
#include <QVBoxLayout>
#include <QDialogButtonBox>
QTEST_MAIN(DKIMConfigureDialogTest)
DKIMConfigureDialogTest::DKIMConfigureDialogTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
void DKIMConfigureDialogTest::shouldHaveDefaultValue()
{
MessageViewer::DKIMConfigureDialog dlg;
QVBoxLayout *mainLayout = dlg.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
MessageViewer::DKIMConfigureWidget *mConfigureWidget = dlg.findChild<MessageViewer::DKIMConfigureWidget *>(QStringLiteral("mConfigureWidget"));
QVERIFY(mConfigureWidget);
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonBox"));
QVERIFY(buttonBox);
QCOMPARE(buttonBox->standardButtons(), {QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults});
}
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGUREDIALOGTEST_H
#define DKIMCONFIGUREDIALOGTEST_H
#include <QObject>
class DKIMConfigureDialogTest : public QObject
{
Q_OBJECT
public:
explicit DKIMConfigureDialogTest(QObject *parent = nullptr);
~DKIMConfigureDialogTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // DKIMCONFIGUREDIALOGTEST_H
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguretabtest.h"
#include "dkim-verify/dkimconfiguretab.h"
#include <QHBoxLayout>
#include <QTabWidget>
#include <QTest>
QTEST_MAIN(DKIMConfigureTabTest)
DKIMConfigureTabTest::DKIMConfigureTabTest(QObject *parent)
: QObject(parent)
{
}
void DKIMConfigureTabTest::shouldHaveDefaultValue()
{
MessageViewer::DKIMConfigureTab w;
QHBoxLayout *mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->margin(), 0);
QTabWidget *mTabWidget = w.findChild<QTabWidget *>(QStringLiteral("tabwidget"));
QVERIFY(mTabWidget);
}
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGURETABTEST_H
#define DKIMCONFIGURETABTEST_H
#include <QObject>
class DKIMConfigureTabTest : public QObject
{
Q_OBJECT
public:
explicit DKIMConfigureTabTest(QObject *parent = nullptr);
~DKIMConfigureTabTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // DKIMCONFIGURETABTEST_H
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguretabwidgettest.h"
#include "dkim-verify/dkimconfiguretabwidget.h"
#include <QTabWidget>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(DKIMConfigureTabWidgetTest)
DKIMConfigureTabWidgetTest::DKIMConfigureTabWidgetTest(QObject *parent)
: QObject(parent)
{
}
void DKIMConfigureTabWidgetTest::shouldHaveDefaultValue()
{
MessageViewer::DKIMConfigureTabWidget w;
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->margin(), 0);
}
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGURETABWIDGETTEST_H
#define DKIMCONFIGURETABWIDGETTEST_H
#include <QObject>
class DKIMConfigureTabWidgetTest : public QObject
{
Q_OBJECT
public:
explicit DKIMConfigureTabWidgetTest(QObject *parent = nullptr);
~DKIMConfigureTabWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // DKIMCONFIGURETABWIDGETTEST_H
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dkimconfigurewidgettest.h"
#include "dkim-verify/dkimconfigurewidget.h"
#include "dkim-verify/dkimconfiguretab.h"
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(DKIMConfigureWidgetTest)
DKIMConfigureWidgetTest::DKIMConfigureWidgetTest(QObject *parent)
: QObject(parent)
{
}
void DKIMConfigureWidgetTest::shouldHaveDefaultValue()
{
MessageViewer::DKIMConfigureWidget w;
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->margin(), 0);
MessageViewer::DKIMConfigureTab *mTabWidget = w.findChild<MessageViewer::DKIMConfigureTab *>(QStringLiteral("tabwidget"));
QVERIFY(mTabWidget);
}
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGUREWIDGETTEST_H
#define DKIMCONFIGUREWIDGETTEST_H
#include <QObject>
class DKIMConfigureWidgetTest : public QObject
{
Q_OBJECT
public:
explicit DKIMConfigureWidgetTest(QObject *parent = nullptr);
~DKIMConfigureWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // DKIMCONFIGUREWIDGETTEST_H
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguredialog.h"
#include "dkimconfigurewidget.h"
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#include <KLocalizedString>
#include <KConfigGroup>
#include <KSharedConfig>
using namespace MessageViewer;
DKIMConfigureDialog::DKIMConfigureDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mConfigureWidget = new DKIMConfigureWidget(this);
mConfigureWidget->setObjectName(QStringLiteral("mConfigureWidget"));
mainLayout->addWidget(mConfigureWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults, this);
buttonBox->setObjectName(QStringLiteral("buttonBox"));
mainLayout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, this, &DKIMConfigureDialog::slotAccepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &DKIMConfigureDialog::reject);
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &DKIMConfigureDialog::slotReset);
mConfigureWidget->loadSettings();
}
DKIMConfigureDialog::~DKIMConfigureDialog()
{
}
void DKIMConfigureDialog::slotAccepted()
{
mConfigureWidget->saveSettings();
accept();
}
void DKIMConfigureDialog::slotReset()
{
mConfigureWidget->resetSettings();
}
void DKIMConfigureDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "DKIMConfigureDialog");
const QSize size = group.readEntry("Size", QSize(600, 400));
if (size.isValid()) {
resize(size);
}
}
void DKIMConfigureDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "DKIMConfigureDialog");
group.writeEntry("Size", size());
group.sync();
}
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGUREDIALOG_H
#define DKIMCONFIGUREDIALOG_H
#include <QDialog>
#include "messageviewer_private_export.h"
namespace MessageViewer {
class DKIMConfigureWidget;
class MESSAGEVIEWER_TESTS_EXPORT DKIMConfigureDialog : public QDialog
{
Q_OBJECT
public:
explicit DKIMConfigureDialog(QWidget *parent = nullptr);
~DKIMConfigureDialog();
private:
void slotReset();
void readConfig();
void slotAccepted();
void writeConfig();
DKIMConfigureWidget *mConfigureWidget = nullptr;
};
}
#endif // DKIMCONFIGUREDIALOG_H
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguretab.h"
#include "dkimconfiguretabwidget.h"
#include <KSharedConfig>
#include <QHBoxLayout>
#include <QRegularExpression>
#include <QTabWidget>
using namespace MessageViewer;
DKIMConfigureTab::DKIMConfigureTab(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mainLayout->setContentsMargins(0, 0, 0, 0);
mTabWidget = new QTabWidget(this);
mTabWidget->setObjectName(QStringLiteral("tabwidget"));
mainLayout->addWidget(mTabWidget);
}
DKIMConfigureTab::~DKIMConfigureTab()
{
}
void DKIMConfigureTab::loadSettings()
{
for (DKIMConfigureTabWidget *w : qAsConst(mListTabWidget)) {
w->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();
}
}
void DKIMConfigureTab::resetSettings()
{
for (DKIMConfigureTabWidget *w : qAsConst(mListTabWidget)) {
w->resetSettings();
}
}
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGURETAB_H
#define DKIMCONFIGURETAB_H
#include <QWidget>
#include "messageviewer_private_export.h"
class QTabWidget;
namespace MessageViewer {
class DKIMConfigureTabWidget;
class MESSAGEVIEWER_TESTS_EXPORT DKIMConfigureTab : public QWidget
{
Q_OBJECT
public:
explicit DKIMConfigureTab(QWidget *parent = nullptr);
~DKIMConfigureTab();
void loadSettings();
void saveSettings();
void resetSettings();
private:
QList<DKIMConfigureTabWidget *> mListTabWidget;
QTabWidget *mTabWidget = nullptr;
};
}
#endif // DKIMCONFIGURETAB_H
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dkimconfiguretabwidget.h"
#include <KConfigGroup>
#include <KSharedConfig>
#include <KLocalizedString>
#include <QVBoxLayout>
using namespace MessageViewer;
DKIMConfigureTabWidget::DKIMConfigureTabWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout"));
mainLayout->setContentsMargins(0, 0, 0, 0);
}
DKIMConfigureTabWidget::~DKIMConfigureTabWidget()
{
}
void DKIMConfigureTabWidget::loadSettings()
{
}
void DKIMConfigureTabWidget::saveSettings()
{
}
void DKIMConfigureTabWidget::resetSettings()
{
}
void DKIMConfigureTabWidget::init()
{
//TODO
}
/*
Copyright (C) 2018-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
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef DKIMCONFIGURETABWIDGET_H
#define DKIMCONFIGURETABWIDGET_H
#include "messageviewer_private_export.h"
#include <QWidget>
namespace MessageViewer {
class MESSAGEVIEWER_TESTS_EXPORT DKIMConfigureTabWidget : public QWidget
{
Q_OBJECT