23 lines
636 B
C
23 lines
636 B
C
|
|
#pragma once
|
||
|
|
/****************************
|
||
|
|
* 脚本执行处理器
|
||
|
|
* *************************/
|
||
|
|
#include "eventHandler.h"
|
||
|
|
|
||
|
|
class ScriptEventHandler : public EventHandler {
|
||
|
|
public:
|
||
|
|
bool canHandle(const QString& eventType) const override {
|
||
|
|
return eventType == "runScript";
|
||
|
|
}
|
||
|
|
|
||
|
|
void handle(const EventData& event, GraphicsFunctionModelItem* item) override {
|
||
|
|
QString script = event.parameters.value("script").toString();
|
||
|
|
|
||
|
|
if (auto context = item->eventContext()) {
|
||
|
|
context->emitScriptExecuted(script);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
QString handlerName() const override { return "ScriptHandler"; }
|
||
|
|
};
|