Messagelib

mdnadvicedialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2022-2023 Laurent Montel <[email protected]>
3  SPDX-FileCopyrightText: 2009 Michael Leupold <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #include "mdnadvicedialog.h"
9 
10 #include <KLocalizedString>
11 #include <KMessageBox>
12 
13 #include <QDialogButtonBox>
14 #include <QPushButton>
15 
16 using namespace MessageComposer;
17 
18 MDNAdviceDialog::MDNAdviceDialog(const QString &text, bool canDeny, QWidget *parent)
19  : QDialog(parent)
20 {
21  setWindowTitle(i18nc("@title:window", "Message Disposition Notification Request"));
22  auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Yes, this);
23  auto user1Button = new QPushButton;
24  buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
25  connect(user1Button, &QPushButton::clicked, this, &MDNAdviceDialog::slotUser1Clicked);
26  if (canDeny) {
27  auto user2Button = new QPushButton;
28  connect(user2Button, &QPushButton::clicked, this, &MDNAdviceDialog::slotUser2Clicked);
29  buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);
30  user2Button->setText(i18n("Send \"&denied\""));
31  }
32  buttonBox->button(QDialogButtonBox::Yes)->setText(i18n("&Ignore"));
33  connect(buttonBox->button(QDialogButtonBox::Yes), &QPushButton::clicked, this, &MDNAdviceDialog::slotYesClicked);
34  user1Button->setText(i18n("&Send"));
35  buttonBox->button(QDialogButtonBox::Yes)->setShortcut(Qt::Key_Escape);
37 }
38 
39 MDNAdviceDialog::~MDNAdviceDialog() = default;
40 
41 MessageComposer::MDNAdvice MDNAdviceDialog::result() const
42 {
43  return m_result;
44 }
45 
46 void MDNAdviceDialog::slotUser1Clicked()
47 {
48  m_result = MessageComposer::MDNSend;
49  accept();
50 }
51 
52 void MDNAdviceDialog::slotUser2Clicked()
53 {
54  m_result = MessageComposer::MDNSendDenied;
55  accept();
56 }
57 
58 void MDNAdviceDialog::slotYesClicked()
59 {
60  m_result = MessageComposer::MDNIgnore;
61  accept();
62 }
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
void clicked(bool checked)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString i18n(const char *text, const TYPE &arg...)
Key_Escape
QDialogButtonBox::StandardButton createKMessageBox(QDialog *dialog, QDialogButtonBox *buttons, const QIcon &icon, const QString &text, const QStringList &strlist, const QString &ask, bool *checkboxReturn, Options options, const QString &details=QString(), QMessageBox::Icon notifyType=QMessageBox::Information)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:01:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.