Messagelib

dkimmanagerkeydialog.cpp
1/*
2 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
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
14namespace
15{
16static const char myDKIMManagerKeyDialogConfigGroupName[] = "DKIMManagerKeyDialog";
17}
18
19using namespace MessageViewer;
20DKIMManagerKeyDialog::DKIMManagerKeyDialog(QWidget *parent)
21 : QDialog(parent)
22 , mManagerWidget(new DKIMManagerKeyWidget(this))
23{
24 auto mainLayout = new QVBoxLayout(this);
25 mainLayout->setObjectName(QLatin1StringView("mainlayout"));
26
27 mManagerWidget->setObjectName(QLatin1StringView("managerWidget"));
28 mainLayout->addWidget(mManagerWidget);
29
30 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
31 buttonBox->setObjectName(QLatin1StringView("buttonbox"));
32 connect(buttonBox, &QDialogButtonBox::accepted, this, &DKIMManagerKeyDialog::slotAccept);
33 connect(buttonBox, &QDialogButtonBox::rejected, this, &DKIMManagerKeyDialog::reject);
34 mainLayout->addWidget(buttonBox);
35 loadKeys();
36 readConfig();
37}
38
39DKIMManagerKeyDialog::~DKIMManagerKeyDialog()
40{
41 writeConfig();
42}
43
44void DKIMManagerKeyDialog::readConfig()
45{
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
54void DKIMManagerKeyDialog::writeConfig()
55{
57 group.writeEntry("Header", mManagerWidget->saveHeaders());
58 group.writeEntry("Size", size());
59 group.sync();
60}
61
62void DKIMManagerKeyDialog::loadKeys()
63{
64 mManagerWidget->loadKeys();
65}
66
67void DKIMManagerKeyDialog::slotAccept()
68{
69 mManagerWidget->saveKeys();
70}
71
72#include "moc_dkimmanagerkeydialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
The DKIMManagerKeyWidget class.
T qobject_cast(QObject *object)
void resize(int w, int h)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:37:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.