Messagelib

mdnwarningwidget.cpp
1 /*
2  SPDX-FileCopyrightText: 2022 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "mdnwarningwidget.h"
8 #include <KLocalizedString>
9 #include <QAction>
10 
11 using namespace MessageViewer;
12 MDNWarningWidget::MDNWarningWidget(QWidget *parent)
13  : KMessageWidget(parent)
14  , mIgnoreAction(new QAction(i18nc("@action", "Ignore"), this))
15  , mSendAction(new QAction(i18nc("@action", "Send"), this))
16  , mSendDenyAction(new QAction(i18nc("@action", "Send Deny"), this))
17 {
18  setVisible(false);
19  setMessageType(Information);
20  setWordWrap(true);
21  setCloseButtonVisible(false);
22  connect(mIgnoreAction, &QAction::triggered, this, &MDNWarningWidget::slotIgnore);
23  addAction(mIgnoreAction);
24  connect(mSendAction, &QAction::triggered, this, &MDNWarningWidget::slotSend);
25  addAction(mSendAction);
26  connect(mSendDenyAction, &QAction::triggered, this, &MDNWarningWidget::slotSendDeny);
27  addAction(mSendDenyAction);
28  mSendDenyAction->setVisible(false); // Hidden by default
29  mIgnoreAction->setObjectName(QStringLiteral("mIgnoreAction"));
30  mSendAction->setObjectName(QStringLiteral("mSendAction"));
31  mSendDenyAction->setObjectName(QStringLiteral("mSendDenyAction"));
32 }
33 
34 MDNWarningWidget::~MDNWarningWidget() = default;
35 
36 void MDNWarningWidget::setCanDeny(bool deny)
37 {
38  mSendDenyAction->setVisible(deny);
39 }
40 
41 void MDNWarningWidget::setInformation(const QString &str)
42 {
43  setText(str);
44  animatedShow();
45 }
46 
47 void MDNWarningWidget::slotSend()
48 {
49  animatedHide();
50  Q_EMIT sendResponse(MessageViewer::MDNWarningWidget::ResponseType::Send, mSendingMode);
51 }
52 
53 void MDNWarningWidget::slotIgnore()
54 {
55  animatedHide();
56  Q_EMIT sendResponse(MessageViewer::MDNWarningWidget::ResponseType::Ignore, mSendingMode);
57 }
58 
59 void MDNWarningWidget::slotSendDeny()
60 {
61  animatedHide();
62  Q_EMIT sendResponse(MessageViewer::MDNWarningWidget::ResponseType::SendDeny, mSendingMode);
63 }
64 
65 KMime::MDN::SendingMode MDNWarningWidget::sendingMode() const
66 {
67  return mSendingMode;
68 }
69 
70 void MDNWarningWidget::setSendingMode(KMime::MDN::SendingMode newSendingMode)
71 {
72  mSendingMode = newSendingMode;
73 }
void setText(const QString &text)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void animatedHide()
void animatedShow()
void setVisible(bool)
void triggered(bool checked)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Oct 6 2022 04:07:44 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.