Commit 00c7c920 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Move CertificateDetailsDialog to *.h/*.cpp of its own

GnuPG-bug-id: 5245
parent d47a5a26
......@@ -139,6 +139,7 @@ set(_kleopatra_SRCS
dialogs/addemaildialog.cpp
dialogs/deletecertificatesdialog.cpp
dialogs/setinitialpindialog.cpp
dialogs/certificatedetailsdialog.cpp
dialogs/certificatedetailswidget.cpp
dialogs/trustchainwidget.cpp
dialogs/weboftrustwidget.cpp
......
......@@ -12,7 +12,7 @@
#include "detailscommand.h"
#include "command_p.h"
#include <dialogs/certificatedetailswidget.h>
#include <dialogs/certificatedetailsdialog.h>
#include "kleopatra_debug.h"
......
/* SPDX-FileCopyrightText: 2016 Klarälvdalens Datakonsult AB
SPDX-FileCopyrightText: 2017 Intevation GmbH
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "certificatedetailsdialog.h"
#include "certificatedetailswidget.h"
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <gpgme++/key.h>
CertificateDetailsDialog::CertificateDetailsDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18nc("@title:window", "Certificate Details"));
auto l = new QVBoxLayout(this);
l->addWidget(new CertificateDetailsWidget(this));
auto bbox = new QDialogButtonBox(this);
auto btn = bbox->addButton(QDialogButtonBox::Close);
connect(btn, &QPushButton::pressed, this, &QDialog::accept);
l->addWidget(bbox);
readConfig();
}
CertificateDetailsDialog::~CertificateDetailsDialog()
{
writeConfig();
}
void CertificateDetailsDialog::readConfig()
{
KConfigGroup dialog(KSharedConfig::openStateConfig(), "CertificateDetailsDialog");
const QSize size = dialog.readEntry("Size", QSize(730, 280));
if (size.isValid()) {
resize(size);
}
}
void CertificateDetailsDialog::writeConfig()
{
KConfigGroup dialog(KSharedConfig::openStateConfig(), "CertificateDetailsDialog");
dialog.writeEntry("Size", size());
dialog.sync();
}
void CertificateDetailsDialog::setKey(const GpgME::Key &key)
{
auto w = findChild<CertificateDetailsWidget*>();
Q_ASSERT(w);
w->setKey(key);
}
GpgME::Key CertificateDetailsDialog::key() const
{
auto w = findChild<CertificateDetailsWidget*>();
Q_ASSERT(w);
return w->key();
}
/* SPDX-FileCopyrightText: 2016 Klarälvdalens Datakonsult AB
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QDialog>
namespace GpgME {
class Key;
}
class CertificateDetailsDialog : public QDialog
{
Q_OBJECT
public:
explicit CertificateDetailsDialog(QWidget *parent = nullptr);
~CertificateDetailsDialog() override;
void setKey(const GpgME::Key &key);
GpgME::Key key() const;
private:
void readConfig();
void writeConfig();
};
......@@ -36,10 +36,7 @@
#include <QGpgME/KeyListJob>
#include <QDateTime>
#include <QDialogButtonBox>
#include <QMenu>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QLocale>
#include <gpgme++/gpgmepp_version.h>
......@@ -626,53 +623,4 @@ GpgME::Key CertificateDetailsWidget::key() const
return d->key;
}
CertificateDetailsDialog::CertificateDetailsDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18nc("@title:window", "Certificate Details"));
auto l = new QVBoxLayout(this);
l->addWidget(new CertificateDetailsWidget(this));
auto bbox = new QDialogButtonBox(this);
auto btn = bbox->addButton(QDialogButtonBox::Close);
connect(btn, &QPushButton::pressed, this, &QDialog::accept);
l->addWidget(bbox);
readConfig();
}
CertificateDetailsDialog::~CertificateDetailsDialog()
{
writeConfig();
}
void CertificateDetailsDialog::readConfig()
{
KConfigGroup dialog(KSharedConfig::openStateConfig(), "CertificateDetailsDialog");
const QSize size = dialog.readEntry("Size", QSize(730, 280));
if (size.isValid()) {
resize(size);
}
}
void CertificateDetailsDialog::writeConfig()
{
KConfigGroup dialog(KSharedConfig::openStateConfig(), "CertificateDetailsDialog");
dialog.writeEntry("Size", size());
dialog.sync();
}
void CertificateDetailsDialog::setKey(const GpgME::Key &key)
{
auto w = findChild<CertificateDetailsWidget*>();
Q_ASSERT(w);
w->setKey(key);
}
GpgME::Key CertificateDetailsDialog::key() const
{
auto w = findChild<CertificateDetailsWidget*>();
Q_ASSERT(w);
return w->key();
}
#include "moc_certificatedetailswidget.cpp"
......@@ -6,13 +6,12 @@
#pragma once
#include <QWidget>
#include <QDialog>
#include <vector>
namespace GpgME {
class Key;
class Error;
class Key;
class KeyListResult;
}
......@@ -22,7 +21,7 @@ class CertificateDetailsWidget : public QWidget
public:
explicit CertificateDetailsWidget(QWidget *parent = nullptr);
~CertificateDetailsWidget();
~CertificateDetailsWidget() override;
void setKey(const GpgME::Key &key);
GpgME::Key key() const;
......@@ -36,20 +35,3 @@ private:
const std::vector<GpgME::Key> &, const QString &,
const GpgME::Error &))
};
class CertificateDetailsDialog : public QDialog
{
Q_OBJECT
public:
explicit CertificateDetailsDialog(QWidget *parent = nullptr);
~CertificateDetailsDialog();
void setKey(const GpgME::Key &key);
GpgME::Key key() const;
private:
void readConfig();
void writeConfig();
};
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