DPS/include/WebEventDispatch.h

41 lines
857 B
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <QObject>
#include <unordered_map>
#include <string>
#include "EventModule.h"
/**
* @brief 消息分发器
*/
class WEBQT_EXPORT WebEventDispatch : public QObject
{
Q_OBJECT
public:
/**
* @brief WebEngineView 消息分发器
* @param parent原生父类对象
*/
WebEventDispatch(QObject* parent);
~WebEventDispatch();
signals:
void signalToWeb(const QString& json); // QT给JS发送数据
public slots:
QString msgToQt(const QString& msg);
/**
* @brief 添加事件处理模块
* @param eventModule 事件处理模块
*/
void addEventModule(EventModule* eventModule, bool deleted = true);
private:
struct EventData {
EventModule* eventModule;
bool deleted;
};
static void brostcastToWeb(const QString& json);
std::unordered_map<std::string, EventData> _events;
friend class EventModule;
};