Commit 60c15751 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move export/import in manager dialog

parent 24cda77d
......@@ -19,12 +19,15 @@
#include "dkimmanagerulesdialog.h"
#include "dkimmanageruleswidget.h"
#include "dkimmanagerrules.h"
#include <KConfigGroup>
#include <KSharedConfig>
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QPushButton>
namespace {
static const char myConfigGroupName[] = "DKIMManageRulesDialog";
......@@ -46,6 +49,14 @@ DKIMManageRulesDialog::DKIMManageRulesDialog(QWidget *parent)
buttonBox->setObjectName(QStringLiteral("buttonBox"));
mainLayout->addWidget(buttonBox);
QPushButton *importButton = new QPushButton(i18n("Import..."), this);
buttonBox->addButton(importButton, QDialogButtonBox::ActionRole);
connect(importButton, &QPushButton::clicked, this, &DKIMManageRulesDialog::slotImport);
QPushButton *exportButton = new QPushButton(i18n("Export..."), this);
buttonBox->addButton(exportButton, QDialogButtonBox::ActionRole);
connect(exportButton, &QPushButton::clicked, this, &DKIMManageRulesDialog::slotExport);
connect(buttonBox, &QDialogButtonBox::accepted, this, &DKIMManageRulesDialog::slotAccepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &DKIMManageRulesDialog::reject);
mRulesWidget->loadSettings();
......@@ -63,6 +74,22 @@ void DKIMManageRulesDialog::slotAccepted()
accept();
}
void DKIMManageRulesDialog::slotExport()
{
const QString fileName = QFileDialog::getSaveFileName(this, i18n("Export Rules"));
if (!fileName.isEmpty()) {
MessageViewer::DKIMManagerRules::self()->exportRules(fileName);
}
}
void DKIMManageRulesDialog::slotImport()
{
const QString fileName = QFileDialog::getOpenFileName(this, i18n("Import Rules"));
if (!fileName.isEmpty()) {
MessageViewer::DKIMManagerRules::self()->importRules(fileName);
}
}
void DKIMManageRulesDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), myConfigGroupName);
......
......@@ -38,6 +38,8 @@ private:
void slotAccepted();
void readConfig();
void writeConfig();
void slotImport();
void slotExport();
DKIMManageRulesWidget *mRulesWidget = nullptr;
};
}
......
......@@ -19,13 +19,11 @@
#include "dkimruledialog.h"
#include "dkimrulewidget.h"
#include <MessageViewer/DKIMManagerRules>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QPushButton>
#include <QVBoxLayout>
......@@ -49,13 +47,6 @@ DKIMRuleDialog::DKIMRuleDialog(QWidget *parent)
buttonBox->setObjectName(QStringLiteral("buttonBox"));
mainLayout->addWidget(buttonBox);
QPushButton *importButton = new QPushButton(i18n("Import..."), this);
buttonBox->addButton(importButton, QDialogButtonBox::ActionRole);
connect(importButton, &QPushButton::clicked, this, &DKIMRuleDialog::slotImport);
QPushButton *exportButton = new QPushButton(i18n("Export..."), this);
buttonBox->addButton(exportButton, QDialogButtonBox::ActionRole);
connect(exportButton, &QPushButton::clicked, this, &DKIMRuleDialog::slotExport);
connect(buttonBox, &QDialogButtonBox::accepted, this, &DKIMRuleDialog::slotAccepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &DKIMRuleDialog::reject);
readConfig();
......@@ -71,22 +62,6 @@ void DKIMRuleDialog::slotAccepted()
accept();
}
void DKIMRuleDialog::slotExport()
{
const QString fileName = QFileDialog::getSaveFileName(this, i18n("Export Rules"));
if (!fileName.isEmpty()) {
MessageViewer::DKIMManagerRules::self()->exportRules(fileName);
}
}
void DKIMRuleDialog::slotImport()
{
const QString fileName = QFileDialog::getOpenFileName(this, i18n("Import Rules"));
if (!fileName.isEmpty()) {
MessageViewer::DKIMManagerRules::self()->importRules(fileName);
}
}
void DKIMRuleDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), myConfigGroupName);
......
......@@ -37,8 +37,6 @@ public:
private:
void slotAccepted();
void writeConfig();
void slotImport();
void slotExport();
void readConfig();
DKIMRuleWidget *mRuleWidget = nullptr;
};
......
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