Mailcommon

filteractionmissingtransportdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "filteractionmissingtransportdialog.h"
8
9#include <KLocalizedString>
10#include <KSharedConfig>
11
12#include <KWindowConfig>
13#include <QDialogButtonBox>
14#include <QLabel>
15#include <QPushButton>
16#include <QVBoxLayout>
17#include <QWindow>
18
19#include <MailTransport/TransportComboBox>
20
21using namespace MailCommon;
22namespace
23{
24static const char myFilterActionMissingTransportDialogGroupName[] = "FilterActionMissingTransportDialog";
25}
26FilterActionMissingTransportDialog::FilterActionMissingTransportDialog(const QString &filtername, QWidget *parent)
27 : QDialog(parent)
28 , mComboBoxTransport(new MailTransport::TransportComboBox(this))
29{
30 setModal(true);
31 setWindowTitle(i18nc("@title:window", "Select Transport"));
32 auto mainLayout = new QVBoxLayout(this);
33
34 auto label = new QLabel(this);
35 label->setObjectName(QLatin1StringView("label"));
36 label->setText(
37 i18n("Filter transport is missing. "
38 "Please select a transport to use with filter \"%1\"",
39 filtername));
40 label->setWordWrap(true);
41 mainLayout->addWidget(label);
42 mComboBoxTransport->setObjectName(QLatin1StringView("comboboxtransport"));
43 mainLayout->addWidget(mComboBoxTransport);
45 buttonBox->setObjectName(QLatin1StringView("buttonbox"));
46 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
47 okButton->setDefault(true);
49 connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingTransportDialog::accept);
50 connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingTransportDialog::reject);
51 mainLayout->addWidget(buttonBox);
52 readConfig();
53}
54
55FilterActionMissingTransportDialog::~FilterActionMissingTransportDialog()
56{
57 writeConfig();
58}
59
60void FilterActionMissingTransportDialog::readConfig()
61{
62 create(); // ensure a window is created
63 windowHandle()->resize(QSize(500, 300));
64 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myFilterActionMissingTransportDialogGroupName));
66 resize(windowHandle()->size()); // workaround for QTBUG-40584
67}
68
69void FilterActionMissingTransportDialog::writeConfig()
70{
71 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myFilterActionMissingTransportDialogGroupName));
73 group.sync();
74}
75
76int FilterActionMissingTransportDialog::selectedTransport() const
77{
78 return mComboBoxTransport->currentTransportId();
79}
80
81#include "moc_filteractionmissingtransportdialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
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 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.