44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
#pragma once
|
||
#include "webqt_global.h"
|
||
#include "qwebengineview.h"
|
||
#include <qwidget.h>
|
||
#include <QMouseEvent>
|
||
#include <QtCore/qglobal.h>
|
||
#include "json.hpp"
|
||
using json = nlohmann::json;
|
||
|
||
class EventModule;
|
||
struct WEBQT_EXPORT TitleRectData {
|
||
bool status;
|
||
QRect rect;
|
||
};
|
||
class WEBQT_EXPORT WebEngineView :
|
||
public QWebEngineView
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
/**
|
||
* @brief web浏览器渲染引擎视图构造函数。
|
||
* @param url 需要加载的网页资源路径,可以是本地路径,也可以是远程路径
|
||
* @param beFrameless 是否是无边框窗体。true为无边框窗体,false是原生窗体。注意,当为该窗体作为其他非主窗体控件的子控件时,不能使用true选项,否则程序会报错。因为它会设置其mainWin的窗体类型为frameless。
|
||
* @param mainWin 该视图所在的主控件。该控件非父类控件,而是作为该视图外包围的上一层控件。
|
||
* @param parent QObject对应的父类控件。
|
||
*/
|
||
WebEngineView(QUrl url, QWidget* parent = nullptr);
|
||
~WebEngineView();
|
||
void addEventModule(EventModule* eventModule, bool deleted = true);
|
||
void addSystemEventHandle(QObject* obj);
|
||
|
||
protected:
|
||
bool eventFilter(QObject* watched, QEvent* event);
|
||
void updateRect(int margin);
|
||
void resizeEvent(QResizeEvent* event);
|
||
public slots:
|
||
bool checkTitleBar(QPoint pos);
|
||
bool onMessage(const std::string& eventName, json& parameter);
|
||
private:
|
||
void* _webEventDispatch;
|
||
QList<TitleRectData> _titleRect;
|
||
};
|
||
|