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::rejected, this, &DKIMManagerKeyDialog::reject);
33 mainLayout->addWidget(buttonBox);
34 loadKeys();
35 readConfig();
36}
37
38DKIMManagerKeyDialog::~DKIMManagerKeyDialog()
39{
40 writeConfig();
41}
42
43void DKIMManagerKeyDialog::readConfig()
44{
45 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myDKIMManagerKeyDialogConfigGroupName));
46 mManagerWidget->restoreHeaders(group.readEntry("Header", QByteArray()));
47 const QSize size = group.readEntry("Size", QSize(600, 400));
48 if (size.isValid()) {
49 resize(size);
50 }
51}
52
53void DKIMManagerKeyDialog::writeConfig()
54{
55 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myDKIMManagerKeyDialogConfigGroupName));
56 group.writeEntry("Header", mManagerWidget->saveHeaders());
57 group.writeEntry("Size", size());
58 group.sync();
59}
60
61void DKIMManagerKeyDialog::loadKeys()
62{
63 mManagerWidget->loadKeys();
64}
65
66void DKIMManagerKeyDialog::slotAccept()
67{
68 mManagerWidget->saveKeys();
69}
70
71#include "moc_dkimmanagerkeydialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
The DKIMManagerKeyWidget class.
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 11:53:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.