Messagelib
8 #include "scamdetectionwarningwidget.h"
9 #include "settings/messageviewersettings.h"
11 #include <KLocalizedString>
15 using namespace MessageViewer;
17 class MessageViewer::ScamDetectionWarningWidgetPrivate
20 ScamDetectionWarningWidgetPrivate() =
default;
22 bool mUseInTestApps =
false;
25 ScamDetectionWarningWidget::ScamDetectionWarningWidget(
QWidget *parent)
27 , d(new MessageViewer::ScamDetectionWarningWidgetPrivate)
30 setCloseButtonVisible(
true);
31 setMessageType(Warning);
33 setText(
i18n(
"This message may be a scam. <a href=\"scamdetails\">(Details...)</a>"));
35 connect(
this, &ScamDetectionWarningWidget::linkActivated,
this, &ScamDetectionWarningWidget::slotShowDetails);
37 auto menu =
new QMenu(
this);
38 auto action =
new QAction(
i18n(
"Move to Trash"),
this);
39 connect(action, &
QAction::triggered,
this, &ScamDetectionWarningWidget::moveMessageToTrash);
40 action->setMenu(menu);
43 action =
new QAction(
i18n(
"I confirm it's not a scam"),
this);
44 menu->addAction(action);
45 connect(action, &
QAction::triggered,
this, &ScamDetectionWarningWidget::slotMessageIsNotAScam);
47 action =
new QAction(
i18n(
"Add email to whitelist"),
this);
48 menu->addAction(action);
49 connect(action, &
QAction::triggered,
this, &ScamDetectionWarningWidget::slotAddToWhiteList);
51 action =
new QAction(
i18n(
"Disable scam detection for all messages"),
this);
52 menu->addAction(action);
53 connect(action, &
QAction::triggered,
this, &ScamDetectionWarningWidget::slotDisableScamDetection);
56 ScamDetectionWarningWidget::~ScamDetectionWarningWidget() =
default;
58 void ScamDetectionWarningWidget::setUseInTestApps(
bool b)
60 d->mUseInTestApps = b;
63 void ScamDetectionWarningWidget::slotMessageIsNotAScam()
65 Q_EMIT messageIsNotAScam();
69 void ScamDetectionWarningWidget::slotShowDetails(
const QString &content)
76 void ScamDetectionWarningWidget::slotShowWarning()
81 void ScamDetectionWarningWidget::slotDisableScamDetection()
83 if (!d->mUseInTestApps) {
84 MessageViewer::MessageViewerSettings::self()->setScamDetectionEnabled(
false);
85 MessageViewer::MessageViewerSettings::self()->save();
90 void ScamDetectionWarningWidget::slotAddToWhiteList()
93 Q_EMIT addToWhiteList();
QString i18n(const char *text, const TYPE &arg...)
void triggered(bool checked)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:08:12 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.