Mailcommon

filteractionmissingidentitydialog.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 "filteractionmissingidentitydialog.h"
8 #include "kernel/mailkernel.h"
9 
10 #include <KConfigGroup>
11 #include <KLocalizedString>
12 #include <KSharedConfig>
13 
14 #include <QDialogButtonBox>
15 #include <QLabel>
16 #include <QPushButton>
17 #include <QVBoxLayout>
18 
19 #include <KIdentityManagement/IdentityCombo>
20 
21 using namespace MailCommon;
22 
23 FilterActionMissingIdentityDialog::FilterActionMissingIdentityDialog(const QString &filtername, QWidget *parent)
24  : QDialog(parent)
25 {
26  setModal(true);
27  setWindowTitle(i18nc("@title:window", "Select Identity"));
28  auto mainLayout = new QVBoxLayout(this);
29 
30  auto label = new QLabel(this);
31  label->setObjectName(QStringLiteral("label"));
32  label->setText(
33  i18n("Filter identity is missing. "
34  "Please select an identity to use with filter \"%1\"",
35  filtername));
36  label->setWordWrap(true);
37  mainLayout->addWidget(label);
38  mComboBoxIdentity = new KIdentityManagement::IdentityCombo(KernelIf->identityManager(), this);
39  mComboBoxIdentity->setObjectName(QStringLiteral("comboboxidentity"));
40  mainLayout->addWidget(mComboBoxIdentity);
41 
43  buttonBox->setObjectName(QStringLiteral("buttonbox"));
44 
45  QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
46  okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
47  connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingIdentityDialog::accept);
48  connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingIdentityDialog::reject);
49  mainLayout->addWidget(buttonBox);
50  okButton->setDefault(true);
51 
52  readConfig();
53 }
54 
55 FilterActionMissingIdentityDialog::~FilterActionMissingIdentityDialog()
56 {
57  writeConfig();
58 }
59 
60 void FilterActionMissingIdentityDialog::readConfig()
61 {
62  KConfigGroup group(KSharedConfig::openStateConfig(), "FilterActionMissingMissingIdentity");
63 
64  const QSize size = group.readEntry("Size", QSize(500, 300));
65  if (size.isValid()) {
66  resize(size);
67  }
68 }
69 
70 void FilterActionMissingIdentityDialog::writeConfig()
71 {
72  KConfigGroup group(KSharedConfig::openStateConfig(), "FilterActionMissingMissingIdentity");
73  group.writeEntry("Size", size());
74 }
75 
76 int FilterActionMissingIdentityDialog::selectedIdentity() const
77 {
78  return mComboBoxIdentity->currentIdentity();
79 }
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 Sep 24 2022 03:58:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.