Messagelib

dkimmanagerkeydialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2018-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "dkimmanagerkeydialog.h"
7 #include "dkimmanagerkeywidget.h"
8 
9 #include <KConfigGroup>
10 #include <KSharedConfig>
11 #include <QDialogButtonBox>
12 #include <QVBoxLayout>
13 
14 namespace
15 {
16 static const char myDKIMManagerKeyDialogConfigGroupName[] = "DKIMManagerKeyDialog";
17 }
18 
19 using namespace MessageViewer;
20 DKIMManagerKeyDialog::DKIMManagerKeyDialog(QWidget *parent)
21  : QDialog(parent)
22  , mManagerWidget(new DKIMManagerKeyWidget(this))
23 {
24  auto mainLayout = new QVBoxLayout(this);
25  mainLayout->setObjectName(QStringLiteral("mainlayout"));
26 
27  mManagerWidget->setObjectName(QStringLiteral("managerWidget"));
28  mainLayout->addWidget(mManagerWidget);
29 
30  auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
31  buttonBox->setObjectName(QStringLiteral("buttonbox"));
32  connect(buttonBox, &QDialogButtonBox::accepted, this, &DKIMManagerKeyDialog::slotAccept);
34  mainLayout->addWidget(buttonBox);
35  loadKeys();
36  readConfig();
37 }
38 
39 DKIMManagerKeyDialog::~DKIMManagerKeyDialog()
40 {
41  writeConfig();
42 }
43 
44 void DKIMManagerKeyDialog::readConfig()
45 {
46  KConfigGroup group(KSharedConfig::openStateConfig(), myDKIMManagerKeyDialogConfigGroupName);
47  mManagerWidget->restoreHeaders(group.readEntry("Header", QByteArray()));
48  const QSize size = group.readEntry("Size", QSize(600, 400));
49  if (size.isValid()) {
50  resize(size);
51  }
52 }
53 
54 void DKIMManagerKeyDialog::writeConfig()
55 {
56  KConfigGroup group(KSharedConfig::openStateConfig(), myDKIMManagerKeyDialogConfigGroupName);
57  group.writeEntry("Header", mManagerWidget->saveHeaders());
58  group.writeEntry("Size", size());
59  group.sync();
60 }
61 
62 void DKIMManagerKeyDialog::loadKeys()
63 {
64  mManagerWidget->loadKeys();
65 }
66 
67 void DKIMManagerKeyDialog::slotAccept()
68 {
69  mManagerWidget->saveKeys();
70 }
bool isValid() const const
virtual void reject()
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
The DKIMManagerKeyWidget class.
void readConfig()
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:16:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.