Messagelib

configurefiltersdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
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
14using namespace MessageList::Core;
15namespace
16{
17static const char myConfigureFiltersDialogConfigGroupName[] = "ConfigureFiltersDialog";
18}
19
20ConfigureFiltersDialog::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(QLatin1StringView("mainLayout"));
27
28 mConfigureFiltersWidget->setObjectName(QLatin1StringView("mConfigureFiltersWidget"));
29 mainLayout->addWidget(mConfigureFiltersWidget);
30
31 auto button = new QDialogButtonBox(QDialogButtonBox::Close, this);
32 mainLayout->addWidget(button);
33 connect(button, &QDialogButtonBox::rejected, this, &ConfigureFiltersDialog::reject);
34 readConfig();
35}
36
37ConfigureFiltersDialog::~ConfigureFiltersDialog()
38{
39 writeConfig();
40}
41
42void ConfigureFiltersDialog::readConfig()
43{
44 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigureFiltersDialogConfigGroupName));
45 const QSize size = group.readEntry("Size", QSize(600, 400));
46 if (size.isValid()) {
47 resize(size);
48 }
49}
50
51void ConfigureFiltersDialog::writeConfig()
52{
53 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigureFiltersDialogConfigGroupName));
54 group.writeEntry("Size", size());
55 group.sync();
56}
57
58#include "moc_configurefiltersdialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
The implementation independent part of the MessageList library.
Definition aggregation.h:22
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.