Warning, file /pim/mailcommon/src/filter/invalidfilters/invalidfilterdialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "invalidfilterdialog.h" 0008 #include "invalidfilterinfowidget.h" 0009 #include "invalidfilterwidget.h" 0010 #include <KConfigGroup> 0011 #include <KLocalizedString> 0012 #include <KSharedConfig> 0013 #include <KWindowConfig> 0014 #include <QDialogButtonBox> 0015 #include <QPushButton> 0016 #include <QVBoxLayout> 0017 #include <QWindow> 0018 0019 using namespace MailCommon; 0020 namespace 0021 { 0022 static const char myInvalidFilterDialogName[] = "InvalidFilterDialog"; 0023 } 0024 InvalidFilterDialog::InvalidFilterDialog(QWidget *parent) 0025 : QDialog(parent) 0026 , mInvalidFilterWidget(new InvalidFilterWidget(this)) 0027 , mInvalidFilterInfoWidget(new InvalidFilterInfoWidget(this)) 0028 { 0029 setWindowTitle(i18nc("@title:window", "Invalid Filters")); 0030 setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail"))); 0031 auto mainLayout = new QVBoxLayout(this); 0032 0033 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 0034 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); 0035 okButton->setShortcut(Qt::CTRL | Qt::Key_Return); 0036 connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 0037 connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 0038 okButton->setDefault(true); 0039 setModal(true); 0040 okButton->setText(i18n("Discard")); 0041 0042 auto w = new QWidget(this); 0043 auto vbox = new QVBoxLayout; 0044 vbox->setContentsMargins({}); 0045 w->setLayout(vbox); 0046 mInvalidFilterWidget->setObjectName(QLatin1StringView("invalid_filter_widget")); 0047 vbox->addWidget(mInvalidFilterWidget); 0048 0049 mInvalidFilterInfoWidget->setObjectName(QLatin1StringView("invalid_filter_infowidget")); 0050 vbox->addWidget(mInvalidFilterInfoWidget); 0051 connect(mInvalidFilterWidget, &InvalidFilterWidget::showDetails, mInvalidFilterInfoWidget, &InvalidFilterInfoWidget::slotShowDetails); 0052 connect(mInvalidFilterWidget, &InvalidFilterWidget::hideInformationWidget, mInvalidFilterInfoWidget, &KMessageWidget::animatedHide); 0053 mainLayout->addWidget(w); 0054 mainLayout->addWidget(buttonBox); 0055 readConfig(); 0056 } 0057 0058 InvalidFilterDialog::~InvalidFilterDialog() 0059 { 0060 writeConfig(); 0061 } 0062 0063 void InvalidFilterDialog::setInvalidFilters(const QList<InvalidFilterInfo> &lst) 0064 { 0065 mInvalidFilterWidget->setInvalidFilters(lst); 0066 } 0067 0068 void InvalidFilterDialog::readConfig() 0069 { 0070 create(); // ensure a window is created 0071 windowHandle()->resize(QSize(400, 500)); 0072 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myInvalidFilterDialogName)); 0073 KWindowConfig::restoreWindowSize(windowHandle(), group); 0074 resize(windowHandle()->size()); // workaround for QTBUG-40584 0075 } 0076 0077 void InvalidFilterDialog::writeConfig() 0078 { 0079 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myInvalidFilterDialogName)); 0080 KWindowConfig::saveWindowSize(windowHandle(), group); 0081 group.sync(); 0082 } 0083 0084 #include "moc_invalidfilterdialog.cpp"