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

4
   SPDX-License-Identifier: LGPL-2.0-or-later
Laurent Montel's avatar
Laurent Montel committed
5 6 7 8 9 10
*/

#ifndef WEBENGINEVIEW_H
#define WEBENGINEVIEW_H

#include <QWebEngineView>
Laurent Montel's avatar
Laurent Montel committed
11
#include <QWebEngineScript>
Laurent Montel's avatar
Laurent Montel committed
12
#include "webengineviewer_export.h"
Laurent Montel's avatar
Laurent Montel committed
13
namespace WebEngineViewer {
Laurent Montel's avatar
Laurent Montel committed
14
class WebEngineViewPrivate;
15
class WebEngineManageScript;
16 17
class LocalDataBaseManager;

18 19 20 21
/**
 * @brief The WebEngineView class
 * @author Laurent Montel <montel@kde.org>
 */
Laurent Montel's avatar
Laurent Montel committed
22 23 24 25
class WEBENGINEVIEWER_EXPORT WebEngineView : public QWebEngineView
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
26
    explicit WebEngineView(QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
27
    ~WebEngineView() override;
Laurent Montel's avatar
Laurent Montel committed
28

Laurent Montel's avatar
Laurent Montel committed
29 30
    void clearRelativePosition();
    void saveRelativePosition();
Laurent Montel's avatar
Laurent Montel committed
31
    Q_REQUIRED_RESULT qreal relativePosition() const;
Laurent Montel's avatar
Laurent Montel committed
32

Laurent Montel's avatar
Laurent Montel committed
33
    void addScript(const QString &source, const QString &scriptName, QWebEngineScript::InjectionPoint injectionPoint);
34

Laurent Montel's avatar
Laurent Montel committed
35
    Q_REQUIRED_RESULT WebEngineManageScript *webEngineManagerScript() const;
36

Laurent Montel's avatar
Laurent Montel committed
37
    Q_REQUIRED_RESULT WebEngineViewer::LocalDataBaseManager *phishingDatabase() const;
38

Laurent Montel's avatar
Laurent Montel committed
39
protected:
40 41
    bool eventFilter(QObject *obj, QEvent *event) override;
    QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) override;
Laurent Montel's avatar
Laurent Montel committed
42

Laurent Montel's avatar
Laurent Montel committed
43 44 45 46 47 48 49 50 51 52 53
    virtual void forwardWheelEvent(QWheelEvent *event);
    virtual void forwardKeyPressEvent(QKeyEvent *event);
    virtual void forwardKeyReleaseEvent(QKeyEvent *event);
    virtual void forwardMousePressEvent(QMouseEvent *event);
    virtual void forwardMouseMoveEvent(QMouseEvent *event);
    virtual void forwardMouseReleaseEvent(QMouseEvent *event);
private:
    WebEngineViewPrivate *const d;
};
}
#endif // WEBENGINEVIEW_H