DPS/include/WebEngineView.h

44 lines
1.4 KiB
C
Raw Normal View History

2025-06-23 18:01:09 +08:00
#pragma once
2025-06-23 10:41:33 +08:00
#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;
};