10402
|
1 |
#include <QLibrary>
|
|
2 |
#include <QtQml>
|
|
3 |
|
|
4 |
#include "hwengine.h"
|
|
5 |
|
|
6 |
extern "C" {
|
|
7 |
void (*RunEngine)(int argc, char ** argv);
|
|
8 |
}
|
|
9 |
|
|
10 |
HWEngine::HWEngine(QObject *parent) :
|
|
11 |
QObject(parent)
|
|
12 |
{
|
|
13 |
QLibrary hwlib("hwengine");
|
|
14 |
|
|
15 |
if(!hwlib.load())
|
|
16 |
qWarning("Engine library not found");
|
|
17 |
|
|
18 |
RunEngine = (void (*)(int, char **))hwlib.resolve("RunEngine");
|
|
19 |
}
|
|
20 |
|
|
21 |
HWEngine::~HWEngine()
|
|
22 |
{
|
|
23 |
|
|
24 |
}
|
|
25 |
|
|
26 |
void HWEngine::run()
|
|
27 |
{
|
|
28 |
RunEngine(0, nullptr);
|
|
29 |
}
|
|
30 |
|
|
31 |
static QObject *hwengine_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
|
32 |
{
|
|
33 |
Q_UNUSED(engine)
|
|
34 |
Q_UNUSED(scriptEngine)
|
|
35 |
|
|
36 |
HWEngine *hwengine = new HWEngine();
|
|
37 |
return hwengine;
|
|
38 |
}
|
|
39 |
|
|
40 |
void HWEngine::exposeToQML()
|
|
41 |
{
|
|
42 |
qDebug("HWEngine::exposeToQML");
|
|
43 |
qmlRegisterSingletonType<HWEngine>("Hedgewars.Engine", 1, 0, "HWEngine", hwengine_singletontype_provider);
|
|
44 |
}
|