Libksieve

sieveinfodialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2014-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 
6 */
7 
8 #include "sieveinfodialog.h"
9 #include "sieveinfowidget.h"
10 #include <KConfigGroup>
11 #include <KLocalizedString>
12 #include <KSharedConfig>
13 #include <QDialogButtonBox>
14 #include <QVBoxLayout>
15 
16 namespace
17 {
18 static const char myConfigGroupName[] = "SieveInfoDialog";
19 }
20 
21 using namespace KSieveUi;
22 SieveInfoDialog::SieveInfoDialog(QWidget *parent)
23  : QDialog(parent)
24  , mSieveInfoWidget(new SieveInfoWidget(this))
25 {
26  setWindowTitle(i18nc("@title:window", "Sieve Server Support"));
27  auto mainLayout = new QVBoxLayout(this);
28  mainLayout->setObjectName(QStringLiteral("mainLayout"));
29 
30  mSieveInfoWidget->setObjectName(QStringLiteral("mSieveInfoWidget"));
31  mainLayout->addWidget(mSieveInfoWidget);
32 
33  auto button = new QDialogButtonBox(QDialogButtonBox::Close, this);
34  button->setObjectName(QStringLiteral("button"));
35  mainLayout->addWidget(button);
36  connect(button, &QDialogButtonBox::rejected, this, &SieveInfoDialog::reject);
37  readConfig();
38 }
39 
40 SieveInfoDialog::~SieveInfoDialog()
41 {
42  writeConfig();
43 }
44 
45 void SieveInfoDialog::setServerInfo(const QStringList &serverInfos)
46 {
47  mSieveInfoWidget->setServerInfo(serverInfos);
48 }
49 
50 void SieveInfoDialog::readConfig()
51 {
52  KConfigGroup group(KSharedConfig::openStateConfig(), myConfigGroupName);
53  const QSize sizeDialog = group.readEntry("Size", QSize(400, 300));
54  if (sizeDialog.isValid()) {
55  resize(sizeDialog);
56  }
57 }
58 
59 void SieveInfoDialog::writeConfig()
60 {
61  KConfigGroup group(KSharedConfig::openStateConfig(), myConfigGroupName);
62  group.writeEntry("Size", size());
63 }
bool isValid() const const
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
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 Sun Apr 11 2021 23:09:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.