mailwebengineview.h 3.23 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   SPDX-FileCopyrightText: 2016-2021 Laurent Montel <montel@kde.org>
3

4
   SPDX-License-Identifier: LGPL-2.0-or-later
5
6
7
8
*/

#ifndef MAILWEBENGINE_H
#define MAILWEBENGINE_H
Laurent Montel's avatar
Laurent Montel committed
9
#include "messageviewer_export.h"
Laurent Montel's avatar
Laurent Montel committed
10
#include <MessageViewer/BlockMailTrackingUrlInterceptor>
Laurent Montel's avatar
Laurent Montel committed
11
#include <WebEngineViewer/WebEngineView>
Laurent Montel's avatar
Laurent Montel committed
12
#include <boost/function.hpp>
13
class QPrinter;
Laurent Montel's avatar
Laurent Montel committed
14
class KActionCollection;
Laurent Montel's avatar
Laurent Montel committed
15
16
namespace WebEngineViewer
{
Laurent Montel's avatar
Laurent Montel committed
17
class WebHitTestResult;
Laurent Montel's avatar
Laurent Montel committed
18
}
Laurent Montel's avatar
Laurent Montel committed
19
20
namespace MessageViewer
{
21
class ViewerPrivate;
Laurent Montel's avatar
Laurent Montel committed
22
class MailWebEngineViewPrivate;
23
24
25
26
/**
 * @brief The MailWebEngineView class
 * @author Laurent Montel <montel@kde.org>
 */
Laurent Montel's avatar
Laurent Montel committed
27
class MESSAGEVIEWER_EXPORT MailWebEngineView : public WebEngineViewer::WebEngineView
28
{
Laurent Montel's avatar
Laurent Montel committed
29
    Q_OBJECT
30
public:
Laurent Montel's avatar
Laurent Montel committed
31
    explicit MailWebEngineView(KActionCollection *ac, QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
32
    ~MailWebEngineView() override;
Laurent Montel's avatar
Laurent Montel committed
33

Laurent Montel's avatar
Laurent Montel committed
34
35
36
    void scrollUp(int pixels);
    void scrollDown(int pixels);

Laurent Montel's avatar
Laurent Montel committed
37
    void selectAll();
Laurent Montel's avatar
Laurent Montel committed
38
    void scamCheck();
Laurent Montel's avatar
Laurent Montel committed
39

40
    void saveMainFrameScreenshotInFile(const QString &filename);
Laurent Montel's avatar
Laurent Montel committed
41
    void showAccessKeys();
42
    void hideAccessKeys();
43
    void isScrolledToBottom();
44

Laurent Montel's avatar
Laurent Montel committed
45
    void setElementByIdVisible(const QString &id, bool visible);
Laurent Montel's avatar
Laurent Montel committed
46
    void removeAttachmentMarking(const QString &id);
Laurent Montel's avatar
Laurent Montel committed
47
48
    void markAttachment(const QString &id, const QString &style);
    void scrollToAnchor(const QString &anchor);
49
50
    void scrollPageDown(int percent);
    void scrollPageUp(int percent);
Laurent Montel's avatar
Laurent Montel committed
51

52
    void scrollToRelativePosition(qreal pos);
Laurent Montel's avatar
Laurent Montel committed
53

54
55
    void setAllowExternalContent(bool b);

Laurent Montel's avatar
Laurent Montel committed
56
    Q_REQUIRED_RESULT QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
57

Laurent Montel's avatar
Laurent Montel committed
58
59
    void setPrintElementBackground(bool printElementBackground);

60
61
    void setLinkHovered(const QUrl &url);
    void setViewer(MessageViewer::ViewerPrivate *viewer);
Laurent Montel's avatar
Laurent Montel committed
62
    Q_REQUIRED_RESULT bool execPrintPreviewPage(QPrinter *printer, int timeout);
63
    void readConfig();
64
65

    static void initializeCustomScheme();
Laurent Montel's avatar
Laurent Montel committed
66
67
68
public Q_SLOTS:
    void slotZoomChanged(qreal zoom);
    void slotShowDetails();
69
70

protected:
71
72
73
74
75
76
    void forwardWheelEvent(QWheelEvent *event) override;
    void forwardKeyPressEvent(QKeyEvent *event) override;
    void forwardKeyReleaseEvent(QKeyEvent *event) override;
    void forwardMousePressEvent(QMouseEvent *event) override;
    void forwardMouseMoveEvent(QMouseEvent *event) override;
    void forwardMouseReleaseEvent(QMouseEvent *event) override;
Laurent Montel's avatar
Laurent Montel committed
77

78
    void resizeEvent(QResizeEvent *e) override;
79

80
    void contextMenuEvent(QContextMenuEvent *e) override;
Laurent Montel's avatar
Laurent Montel committed
81
Q_SIGNALS:
82
    void wheelZoomChanged(int numSteps);
Laurent Montel's avatar
Laurent Montel committed
83
    void openUrl(const QUrl &url);
Laurent Montel's avatar
Laurent Montel committed
84
    void urlBlocked(const QUrl &url);
85
    void messageMayBeAScam();
Laurent Montel's avatar
Laurent Montel committed
86
    void formSubmittedForbidden();
Laurent Montel's avatar
Laurent Montel committed
87
    void mailTrackingFound(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &);
Laurent Montel's avatar
Laurent Montel committed
88
    /// Emitted when the user right-clicks somewhere
Laurent Montel's avatar
Laurent Montel committed
89
    void popupMenu(const WebEngineViewer::WebHitTestResult &result);
90
    void pageIsScrolledToBottom(bool);
Laurent Montel's avatar
Laurent Montel committed
91
92
93

private Q_SLOTS:
    void handleScrollToAnchor(const QVariant &result);
94
    void handleIsScrolledToBottom(const QVariant &result);
Laurent Montel's avatar
Laurent Montel committed
95

Laurent Montel's avatar
Laurent Montel committed
96
    void slotWebHitFinished(const WebEngineViewer::WebHitTestResult &result);
Laurent Montel's avatar
Laurent Montel committed
97
    void slotLoadFinished();
Laurent Montel's avatar
Laurent Montel committed
98

99
private:
100
    void runJavaScriptInWordId(const QString &script);
Laurent Montel's avatar
Laurent Montel committed
101
    MailWebEngineViewPrivate *const d;
102
103
104
105
};
}

#endif // MAILWEBENGINE_H