Messagelib

configurefiltersdialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #include "configurefiltersdialog.h"
7 #include "configurefilterswidget.h"
8 #include <KConfigGroup>
9 #include <KLocalizedString>
10 #include <KSharedConfig>
11 #include <QDialogButtonBox>
12 #include <QVBoxLayout>
13 
14 using namespace MessageList::Core;
15 namespace
16 {
17 static const char myConfigureFiltersDialogConfigGroupName[] = "ConfigureFiltersDialog";
18 }
19 
20 ConfigureFiltersDialog::ConfigureFiltersDialog(QWidget *parent)
21  : QDialog(parent)
22  , mConfigureFiltersWidget(new ConfigureFiltersWidget(this))
23 {
24  setWindowTitle(i18nc("@title:window", "Configure Filter"));
25  auto mainLayout = new QVBoxLayout(this);
26  mainLayout->setObjectName(QStringLiteral("mainLayout"));
27 
28  mConfigureFiltersWidget->setObjectName(QStringLiteral("mConfigureFiltersWidget"));
29  mainLayout->addWidget(mConfigureFiltersWidget);
30 
31  auto button = new QDialogButtonBox(QDialogButtonBox::Close, this);
32  mainLayout->addWidget(button);
33  connect(button, &QDialogButtonBox::accepted, this, &ConfigureFiltersDialog::accept);
34  connect(button, &QDialogButtonBox::rejected, this, &ConfigureFiltersDialog::reject);
35  readConfig();
36 }
37 
38 ConfigureFiltersDialog::~ConfigureFiltersDialog()
39 {
40  writeConfig();
41 }
42 
43 void ConfigureFiltersDialog::readConfig()
44 {
45  KConfigGroup group(KSharedConfig::openStateConfig(), myConfigureFiltersDialogConfigGroupName);
46  const QSize size = group.readEntry("Size", QSize(600, 400));
47  if (size.isValid()) {
48  resize(size);
49  }
50 }
51 
52 void ConfigureFiltersDialog::writeConfig()
53 {
54  KConfigGroup group(KSharedConfig::openStateConfig(), myConfigureFiltersDialogConfigGroupName);
55  group.writeEntry("Size", size());
56  group.sync();
57 }
void resize(int w, int h)
bool isValid() const const
The implementation independent part of the MessageList library.
Definition: aggregation.h:21
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 Mon Dec 6 2021 23:04:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.