Messagelib

mdnwarningwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "mdnwarningwidget.h"
8#include <KLocalizedString>
9#include <QAction>
10
11using namespace MessageViewer;
12MDNWarningWidget::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 setPosition(KMessageWidget::Header);
23 connect(mIgnoreAction, &QAction::triggered, this, &MDNWarningWidget::slotIgnore);
24 addAction(mIgnoreAction);
25 connect(mSendAction, &QAction::triggered, this, &MDNWarningWidget::slotSend);
26 addAction(mSendAction);
27 connect(mSendDenyAction, &QAction::triggered, this, &MDNWarningWidget::slotSendDeny);
28 addAction(mSendDenyAction);
29 mSendDenyAction->setVisible(false); // Hidden by default
30 mIgnoreAction->setObjectName(QLatin1StringView("mIgnoreAction"));
31 mSendAction->setObjectName(QLatin1StringView("mSendAction"));
32 mSendDenyAction->setObjectName(QLatin1StringView("mSendDenyAction"));
33}
34
35MDNWarningWidget::~MDNWarningWidget() = default;
36
37void MDNWarningWidget::setCanDeny(bool deny)
38{
39 mSendDenyAction->setVisible(deny);
40}
41
42void MDNWarningWidget::setInformation(const QString &str)
43{
44 setText(str);
46}
47
48void MDNWarningWidget::slotSend()
49{
51 Q_EMIT sendResponse(MessageViewer::MDNWarningWidget::ResponseType::Send, mSendingMode);
52}
53
54void MDNWarningWidget::slotIgnore()
55{
57 Q_EMIT sendResponse(MessageViewer::MDNWarningWidget::ResponseType::Ignore, mSendingMode);
58}
59
60void MDNWarningWidget::slotSendDeny()
61{
63 Q_EMIT sendResponse(MessageViewer::MDNWarningWidget::ResponseType::SendDeny, mSendingMode);
64}
65
66KMime::MDN::SendingMode MDNWarningWidget::sendingMode() const
67{
68 return mSendingMode;
69}
70
71void MDNWarningWidget::setSendingMode(KMime::MDN::SendingMode newSendingMode)
72{
73 mSendingMode = newSendingMode;
74}
75
76#include "moc_mdnwarningwidget.cpp"
void animatedHide()
void animatedShow()
void setText(const QString &text)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void triggered(bool checked)
void setVisible(bool)
Q_EMITQ_EMIT
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.