Mailcommon

filteractionmissingtransportdialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2016-2022 Laurent Montel <[email protected]>
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 <QDialogButtonBox>
13 #include <QLabel>
14 #include <QPushButton>
15 #include <QVBoxLayout>
16 
17 #include <MailTransport/TransportComboBox>
18 
19 using namespace MailCommon;
20 
21 FilterActionMissingTransportDialog::FilterActionMissingTransportDialog(const QString &filtername, QWidget *parent)
22  : QDialog(parent)
23  , mComboBoxTransport(new MailTransport::TransportComboBox(this))
24 {
25  setModal(true);
26  setWindowTitle(i18nc("@title:window", "Select Transport"));
27  auto mainLayout = new QVBoxLayout(this);
28 
29  auto label = new QLabel(this);
30  label->setObjectName(QStringLiteral("label"));
31  label->setText(
32  i18n("Filter transport is missing. "
33  "Please select a transport to use with filter \"%1\"",
34  filtername));
35  label->setWordWrap(true);
36  mainLayout->addWidget(label);
37  mComboBoxTransport->setObjectName(QStringLiteral("comboboxtransport"));
38  mainLayout->addWidget(mComboBoxTransport);
40  buttonBox->setObjectName(QStringLiteral("buttonbox"));
41  QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
42  okButton->setDefault(true);
43  okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
44  connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingTransportDialog::accept);
45  connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingTransportDialog::reject);
46  mainLayout->addWidget(buttonBox);
47  readConfig();
48 }
49 
50 FilterActionMissingTransportDialog::~FilterActionMissingTransportDialog()
51 {
52  writeConfig();
53 }
54 
55 void FilterActionMissingTransportDialog::readConfig()
56 {
57  KConfigGroup group(KSharedConfig::openStateConfig(), "FilterActionMissingTransportDialog");
58 
59  const QSize size = group.readEntry("Size", QSize(500, 300));
60  if (size.isValid()) {
61  resize(size);
62  }
63 }
64 
65 void FilterActionMissingTransportDialog::writeConfig()
66 {
67  KConfigGroup group(KSharedConfig::openStateConfig(), "FilterActionMissingTransportDialog");
68  group.writeEntry("Size", size());
69 }
70 
71 int FilterActionMissingTransportDialog::selectedTransport() const
72 {
73  return mComboBoxTransport->currentTransportId();
74 }
bool isValid() const const
void setShortcut(const QKeySequence &key)
void readConfig()
QString i18n(const char *text, const TYPE &arg...)
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
Key_Return
QString label(StandardShortcut id)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setDefault(bool)
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Oct 1 2022 04:00:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.