Mailcommon

invalidfilterdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "invalidfilterdialog.h"
8#include "invalidfilterinfowidget.h"
9#include "invalidfilterwidget.h"
10#include <KConfigGroup>
11#include <KLocalizedString>
12#include <KSharedConfig>
13#include <KWindowConfig>
14#include <QDialogButtonBox>
15#include <QPushButton>
16#include <QVBoxLayout>
17#include <QWindow>
18
19using namespace MailCommon;
20namespace
21{
22static const char myInvalidFilterDialogName[] = "InvalidFilterDialog";
23}
24InvalidFilterDialog::InvalidFilterDialog(QWidget *parent)
25 : QDialog(parent)
26 , mInvalidFilterWidget(new InvalidFilterWidget(this))
27 , mInvalidFilterInfoWidget(new InvalidFilterInfoWidget(this))
28{
29 setWindowTitle(i18nc("@title:window", "Invalid Filters"));
30 setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail")));
31 auto mainLayout = new QVBoxLayout(this);
32
34 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
38 okButton->setDefault(true);
39 setModal(true);
40 okButton->setText(i18n("Discard"));
41
42 auto w = new QWidget(this);
43 auto vbox = new QVBoxLayout;
44 vbox->setContentsMargins({});
45 w->setLayout(vbox);
46 mInvalidFilterWidget->setObjectName(QLatin1StringView("invalid_filter_widget"));
47 vbox->addWidget(mInvalidFilterWidget);
48
49 mInvalidFilterInfoWidget->setObjectName(QLatin1StringView("invalid_filter_infowidget"));
50 vbox->addWidget(mInvalidFilterInfoWidget);
51 connect(mInvalidFilterWidget, &InvalidFilterWidget::showDetails, mInvalidFilterInfoWidget, &InvalidFilterInfoWidget::slotShowDetails);
52 connect(mInvalidFilterWidget, &InvalidFilterWidget::hideInformationWidget, mInvalidFilterInfoWidget, &KMessageWidget::animatedHide);
53 mainLayout->addWidget(w);
54 mainLayout->addWidget(buttonBox);
55 readConfig();
56}
57
58InvalidFilterDialog::~InvalidFilterDialog()
59{
60 writeConfig();
61}
62
63void InvalidFilterDialog::setInvalidFilters(const QList<InvalidFilterInfo> &lst)
64{
65 mInvalidFilterWidget->setInvalidFilters(lst);
66}
67
68void InvalidFilterDialog::readConfig()
69{
70 create(); // ensure a window is created
71 windowHandle()->resize(QSize(400, 500));
72 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myInvalidFilterDialogName));
74 resize(windowHandle()->size()); // workaround for QTBUG-40584
75}
76
77void InvalidFilterDialog::writeConfig()
78{
79 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myInvalidFilterDialogName));
81 group.sync();
82}
83
84#include "moc_invalidfilterdialog.cpp"
void animatedHide()
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
The InvalidFilterWidget class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(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)
The filter dialog.
void setShortcut(const QKeySequence &key)
void setText(const QString &text)
virtual void accept()
virtual void reject()
QIcon fromTheme(const QString &name)
void setContentsMargins(const QMargins &margins)
void setDefault(bool)
Key_Return
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 Dec 6 2024 12:02:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.