Messagelib

mdnadvicedialog.cpp
1/*
2 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
3 SPDX-FileCopyrightText: 2009 Michael Leupold <lemma@confuego.org>
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
16using namespace MessageComposer;
17
18MDNAdviceDialog::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(this);
24 buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
25 connect(user1Button, &QPushButton::clicked, this, &MDNAdviceDialog::slotUser1Clicked);
26 if (canDeny) {
27 auto user2Button = new QPushButton(this);
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
39MDNAdviceDialog::~MDNAdviceDialog() = default;
40
41MessageComposer::MDNAdvice MDNAdviceDialog::result() const
42{
43 return m_result;
44}
45
46void MDNAdviceDialog::slotUser1Clicked()
47{
48 m_result = MessageComposer::MDNSend;
49 accept();
50}
51
52void MDNAdviceDialog::slotUser2Clicked()
53{
54 m_result = MessageComposer::MDNSendDenied;
55 accept();
56}
57
58void MDNAdviceDialog::slotYesClicked()
59{
60 m_result = MessageComposer::MDNIgnore;
61 accept();
62}
63
64#include "moc_mdnadvicedialog.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
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)
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
void clicked(bool checked)
virtual void accept()
Key_Escape
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:37:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.