Mailcommon

invalidfilterdialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2015-2022 Laurent Montel <[email protected]>
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 <QDialogButtonBox>
14 #include <QPushButton>
15 #include <QVBoxLayout>
16 
17 using namespace MailCommon;
18 
19 InvalidFilterDialog::InvalidFilterDialog(QWidget *parent)
20  : QDialog(parent)
21  , mInvalidFilterWidget(new InvalidFilterWidget(this))
22  , mInvalidFilterInfoWidget(new InvalidFilterInfoWidget(this))
23 {
24  setWindowTitle(i18nc("@title:window", "Invalid Filters"));
25  setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail")));
26  auto mainLayout = new QVBoxLayout(this);
27 
29  QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
30  okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
33  okButton->setDefault(true);
34  setModal(true);
35  okButton->setText(i18n("Discard"));
36 
37  auto w = new QWidget(this);
38  auto vbox = new QVBoxLayout;
39  vbox->setContentsMargins({});
40  w->setLayout(vbox);
41  mInvalidFilterWidget->setObjectName(QStringLiteral("invalid_filter_widget"));
42  vbox->addWidget(mInvalidFilterWidget);
43 
44  mInvalidFilterInfoWidget->setObjectName(QStringLiteral("invalid_filter_infowidget"));
45  vbox->addWidget(mInvalidFilterInfoWidget);
46  connect(mInvalidFilterWidget, &InvalidFilterWidget::showDetails, mInvalidFilterInfoWidget, &InvalidFilterInfoWidget::slotShowDetails);
47  connect(mInvalidFilterWidget, &InvalidFilterWidget::hideInformationWidget, mInvalidFilterInfoWidget, &KMessageWidget::animatedHide);
48  mainLayout->addWidget(w);
49  mainLayout->addWidget(buttonBox);
50  readConfig();
51 }
52 
53 InvalidFilterDialog::~InvalidFilterDialog()
54 {
55  writeConfig();
56 }
57 
58 void InvalidFilterDialog::setInvalidFilters(const QVector<InvalidFilterInfo> &lst)
59 {
60  mInvalidFilterWidget->setInvalidFilters(lst);
61 }
62 
63 void InvalidFilterDialog::writeConfig()
64 {
65  KConfigGroup group(KSharedConfig::openStateConfig(), "InvalidFilterDialog");
66  group.writeEntry("Size", size());
67 }
68 
69 void InvalidFilterDialog::readConfig()
70 {
71  KConfigGroup group(KSharedConfig::openStateConfig(), "InvalidFilterDialog");
72  const QSize sizeDialog = group.readEntry("Size", QSize(400, 500));
73  if (sizeDialog.isValid()) {
74  resize(sizeDialog);
75  }
76 }
bool isValid() const const
virtual void reject()
void setShortcut(const QKeySequence &key)
QIcon fromTheme(const QString &name)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void animatedHide()
QString i18n(const char *text, const TYPE &arg...)
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
virtual void accept()
Key_Return
void setContentsMargins(int left, int top, int right, int bottom)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setDefault(bool)
void setText(const QString &text)
The filter dialog.
The InvalidFilterWidget class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Oct 1 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.