Libksieve

sieveinfodialog.cpp
1/*
2 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
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 <KWindowConfig>
14#include <QDialogButtonBox>
15#include <QVBoxLayout>
16#include <QWindow>
17
18namespace
19{
20static const char myConfigGroupName[] = "SieveInfoDialog";
21}
22
23using namespace KSieveUi;
24SieveInfoDialog::SieveInfoDialog(QWidget *parent)
25 : QDialog(parent)
26 , mSieveInfoWidget(new SieveInfoWidget(this))
27{
28 setWindowTitle(i18nc("@title:window", "Sieve Server Support"));
29 auto mainLayout = new QVBoxLayout(this);
30 mainLayout->setObjectName(QLatin1StringView("mainLayout"));
31
32 mSieveInfoWidget->setObjectName(QLatin1StringView("mSieveInfoWidget"));
33 mainLayout->addWidget(mSieveInfoWidget);
34
35 auto button = new QDialogButtonBox(QDialogButtonBox::Close, this);
36 button->setObjectName(QLatin1StringView("button"));
37 mainLayout->addWidget(button);
38 connect(button, &QDialogButtonBox::rejected, this, &SieveInfoDialog::reject);
39 readConfig();
40}
41
42SieveInfoDialog::~SieveInfoDialog()
43{
44 writeConfig();
45}
46
47void SieveInfoDialog::setServerInfo(const QStringList &serverInfos)
48{
49 mSieveInfoWidget->setServerInfo(serverInfos);
50}
51
52void SieveInfoDialog::readConfig()
53{
54 create(); // ensure a window is created
55 windowHandle()->resize(QSize(400, 300));
58 resize(windowHandle()->size()); // workaround for QTBUG-40584
59}
60
61void SieveInfoDialog::writeConfig()
62{
65 group.sync();
66}
67
68#include "moc_sieveinfodialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options=KConfigGroup::Normal)
KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void create(WId window, bool initializeWindow, bool destroyOldWindow)
void resize(const QSize &)
QWindow * windowHandle() const const
void resize(const QSize &newSize)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.