Messagelib

remotecontentconfiguredialog.cpp
1/*
2 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "remotecontentconfiguredialog.h"
8#include "remotecontentconfigurewidget.h"
9#include <KConfigGroup>
10#include <KLocalizedString>
11#include <KSharedConfig>
12#include <KWindowConfig>
13#include <QDialogButtonBox>
14#include <QVBoxLayout>
15#include <QWindow>
16
17namespace
18{
19static const char myRemoteContentConfigureConfigGroupName[] = "RemoteContentConfigureDialog";
20}
21
22using namespace MessageViewer;
23RemoteContentConfigureDialog::RemoteContentConfigureDialog(QWidget *parent)
24 : QDialog(parent)
25 , mRemoteContentConfigureWidget(new RemoteContentConfigureWidget(this))
26{
27 setWindowTitle(i18nc("@title:window", "Configure Remote Content"));
28 auto mainLayout = new QVBoxLayout(this);
29 mainLayout->setObjectName(QLatin1StringView("mainLayout"));
30
31 mRemoteContentConfigureWidget->setObjectName(QLatin1StringView("mRemoteContentConfigureWidget"));
32 mainLayout->addWidget(mRemoteContentConfigureWidget);
33
34 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
35 buttonBox->setObjectName(QLatin1StringView("buttonBox"));
36 connect(buttonBox, &QDialogButtonBox::accepted, this, &RemoteContentConfigureDialog::slotAccept);
37 connect(buttonBox, &QDialogButtonBox::rejected, this, &RemoteContentConfigureDialog::reject);
38 mainLayout->addWidget(buttonBox);
39 readConfig();
40}
41
42RemoteContentConfigureDialog::~RemoteContentConfigureDialog()
43{
44 writeConfig();
45}
46
47void RemoteContentConfigureDialog::slotAccept()
48{
49 mRemoteContentConfigureWidget->saveSettings();
50 accept();
51}
52
53void RemoteContentConfigureDialog::readConfig()
54{
55 create(); // ensure a window is created
56 windowHandle()->resize(QSize(600, 200));
57 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myRemoteContentConfigureConfigGroupName));
59 resize(windowHandle()->size()); // workaround for QTBUG-40584
60}
61
62void RemoteContentConfigureDialog::writeConfig()
63{
64 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myRemoteContentConfigureConfigGroupName));
66}
67
68#include "moc_remotecontentconfiguredialog.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)
virtual void accept()
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 Fri Oct 11 2024 12:08:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.