DPS/include/WebEngineView.h

44 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "webqt_global.h"
#include "webengineview.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;
};