blob: dd5c0ec403a021bc1c7109e6cae6de2675930bc6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#pragma once
#include <QtCore>
#include <lua.hpp>
#include "AsyncEventLoop.hpp"
#include "widgets/WebViewStack.hpp"
class LuaRuntime : public QObject {
Q_OBJECT
public:
static LuaRuntime *instance() {
static LuaRuntime inst;
return &inst;
}
void evaluate(QString code);
QVariant evaluateSync(QString code);
void stopEventLoop();
void startEventLoop();
QVariant getValue(int idx);
DELEGATE(eventLoop, queueTask, queueTask)
signals:
void urlOpened(QString url, OpenType openType);
void evaluationCompleted(QVariant value);
void evaluationFailed(QString value);
// void outputProduced(QVariant value);
protected:
LuaRuntime();
~LuaRuntime();
static int lua_onUrlOpen(lua_State *state);
static int lua_onUrlTabOpen(lua_State *state);
private:
lua_State *state;
AsyncEventLoop *eventLoop = nullptr;
};
|