• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.14
  • kdepim
  • messageviewer
  • scamdetection
scamdetectionwarningwidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "scamdetectionwarningwidget.h"
19 #include "settings/globalsettings.h"
20 
21 #include <KLocalizedString>
22 #include <KAction>
23 #include <QMenu>
24 
25 #include <QDebug>
26 
27 using namespace MessageViewer;
28 
29 ScamDetectionWarningWidget::ScamDetectionWarningWidget(QWidget *parent)
30  : KMessageWidget(parent),
31  mUseInTestApps(false)
32 {
33  setVisible(false);
34  setCloseButtonVisible(true);
35  setMessageType(Warning);
36  setWordWrap(true);
37  setText(i18n("This message may be a scam. <a href=\"scamdetails\">(Details...)</a>"));
38 
39  connect(this, SIGNAL(linkActivated(QString)), SLOT(slotShowDetails(QString)));
40 
41  QMenu *menu = new QMenu();
42  KAction *action = new KAction( i18n( "Move to Trash" ), this );
43  connect( action, SIGNAL(triggered(bool)), SIGNAL(moveMessageToTrash()) );
44  action->setMenu(menu);
45  addAction( action );
46 
47  action = new KAction( i18n( "I confirm it's not a scam" ), this );
48  menu->addAction(action);
49  connect( action, SIGNAL(triggered(bool)), SLOT(slotMessageIsNotAScam()) );
50 
51  action = new KAction( i18n( "Add email to whitelist" ), this );
52  menu->addAction(action);
53  connect( action, SIGNAL(triggered(bool)), SLOT(slotAddToWhiteList()) );
54 
55  action = new KAction( i18n( "Disable scam detection for all messages" ), this );
56  menu->addAction(action);
57  connect( action, SIGNAL(triggered(bool)), SLOT(slotDisableScamDetection()) );
58 }
59 
60 ScamDetectionWarningWidget::~ScamDetectionWarningWidget()
61 {
62 }
63 
64 void ScamDetectionWarningWidget::setUseInTestApps(bool b)
65 {
66  mUseInTestApps = b;
67 }
68 
69 void ScamDetectionWarningWidget::slotMessageIsNotAScam()
70 {
71  Q_EMIT messageIsNotAScam();
72  setVisible(false);
73 }
74 
75 void ScamDetectionWarningWidget::slotShowDetails(const QString &content)
76 {
77  if (content == QLatin1String("scamdetails")) {
78  Q_EMIT showDetails();
79  }
80 }
81 
82 void ScamDetectionWarningWidget::slotShowWarning()
83 {
84  animatedShow();
85 }
86 
87 void ScamDetectionWarningWidget::slotDisableScamDetection()
88 {
89  if (!mUseInTestApps) {
90  MessageViewer::GlobalSettings::self()->setScamDetectionEnabled( false );
91  MessageViewer::GlobalSettings::self()->writeConfig();
92  }
93  setVisible(false);
94 }
95 
96 void ScamDetectionWarningWidget::slotAddToWhiteList()
97 {
98  setVisible(false);
99  Q_EMIT addToWhiteList();
100 }
101 
MessageViewer::ScamDetectionWarningWidget::slotShowWarning
void slotShowWarning()
Definition: scamdetectionwarningwidget.cpp:82
MessageViewer::ScamDetectionWarningWidget::messageIsNotAScam
void messageIsNotAScam()
MessageViewer::ScamDetectionWarningWidget::moveMessageToTrash
void moveMessageToTrash()
globalsettings.h
QWidget
MessageViewer::ScamDetectionWarningWidget::setUseInTestApps
void setUseInTestApps(bool b)
Definition: scamdetectionwarningwidget.cpp:64
QMenu::addAction
void addAction(QAction *action)
MessageViewer::GlobalSettings::self
static GlobalSettings * self()
Definition: globalsettings.cpp:34
QString
QMenu
MessageViewer::ScamDetectionWarningWidget::showDetails
void showDetails()
QLatin1String
scamdetectionwarningwidget.h
MessageViewer::ScamDetectionWarningWidget::addToWhiteList
void addToWhiteList()
KMessageWidget
MessageViewer::ScamDetectionWarningWidget::~ScamDetectionWarningWidget
~ScamDetectionWarningWidget()
Definition: scamdetectionwarningwidget.cpp:60
MessageViewer::ScamDetectionWarningWidget::ScamDetectionWarningWidget
ScamDetectionWarningWidget(QWidget *parent=0)
Definition: scamdetectionwarningwidget.cpp:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:45 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal