Messagelib

remotecontentconfiguredialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2020-2021 Laurent Montel <[email protected]>
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 <QDialogButtonBox>
13 #include <QVBoxLayout>
14 
15 namespace
16 {
17 static const char myRemoteContentConfigureConfigGroupName[] = "RemoteContentConfigureDialog";
18 }
19 
20 using namespace MessageViewer;
21 RemoteContentConfigureDialog::RemoteContentConfigureDialog(QWidget *parent)
22  : QDialog(parent)
23  , mRemoteContentConfigureWidget(new RemoteContentConfigureWidget(this))
24 {
25  setWindowTitle(i18nc("@title:window", "Configure Remote Content"));
26  auto mainLayout = new QVBoxLayout(this);
27  mainLayout->setObjectName(QStringLiteral("mainLayout"));
28 
29  mRemoteContentConfigureWidget->setObjectName(QStringLiteral("mRemoteContentConfigureWidget"));
30  mainLayout->addWidget(mRemoteContentConfigureWidget);
31 
33  buttonBox->setObjectName(QStringLiteral("buttonBox"));
34  connect(buttonBox, &QDialogButtonBox::accepted, this, &RemoteContentConfigureDialog::slotAccept);
35  connect(buttonBox, &QDialogButtonBox::rejected, this, &RemoteContentConfigureDialog::reject);
36  mainLayout->addWidget(buttonBox);
37  readConfig();
38 }
39 
40 RemoteContentConfigureDialog::~RemoteContentConfigureDialog()
41 {
42  writeConfig();
43 }
44 
45 void RemoteContentConfigureDialog::slotAccept()
46 {
47  mRemoteContentConfigureWidget->saveSettings();
48  accept();
49 }
50 
51 void RemoteContentConfigureDialog::readConfig()
52 {
53  KConfigGroup group(KSharedConfig::openStateConfig(), myRemoteContentConfigureConfigGroupName);
54  const QSize size = group.readEntry("Size", QSize(600, 400));
55  if (size.isValid()) {
56  resize(size);
57  }
58 }
59 
60 void RemoteContentConfigureDialog::writeConfig()
61 {
62  KConfigGroup group(KSharedConfig::openStateConfig(), myRemoteContentConfigureConfigGroupName);
63  group.writeEntry("Size", size());
64  group.sync();
65 }
void resize(int w, int h)
bool isValid() const const
QSize size() const const
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void readConfig()
void setWindowTitle(const QString &)
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 Tue Nov 30 2021 23:05:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.