author | unc0rr |
Sat, 13 Sep 2014 00:27:10 +0400 | |
branch | qmlfrontend |
changeset 10404 | 1baaab44a0b2 |
parent 10402 | 3313336c1ee0 |
child 10416 | 1c301054694d |
permissions | -rw-r--r-- |
10402 | 1 |
#include <QLibrary> |
2 |
#include <QtQml> |
|
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
3 |
#include <QDebug> |
10402 | 4 |
|
5 |
#include "hwengine.h" |
|
6 |
||
7 |
extern "C" { |
|
8 |
void (*RunEngine)(int argc, char ** argv); |
|
9 |
} |
|
10 |
||
11 |
HWEngine::HWEngine(QObject *parent) : |
|
12 |
QObject(parent) |
|
13 |
{ |
|
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
14 |
QLibrary hwlib("./libhwengine.so"); |
10402 | 15 |
|
16 |
if(!hwlib.load()) |
|
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
17 |
qWarning() << "Engine library not found" << hwlib.errorString(); |
10402 | 18 |
|
19 |
RunEngine = (void (*)(int, char **))hwlib.resolve("RunEngine"); |
|
20 |
} |
|
21 |
||
22 |
HWEngine::~HWEngine() |
|
23 |
{ |
|
24 |
||
25 |
} |
|
26 |
||
27 |
void HWEngine::run() |
|
28 |
{ |
|
10404
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
29 |
char* args[2] = {"", "--help"}; |
1baaab44a0b2
- Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents:
10402
diff
changeset
|
30 |
RunEngine(2, args); |
10402 | 31 |
} |
32 |
||
33 |
static QObject *hwengine_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) |
|
34 |
{ |
|
35 |
Q_UNUSED(engine) |
|
36 |
Q_UNUSED(scriptEngine) |
|
37 |
||
38 |
HWEngine *hwengine = new HWEngine(); |
|
39 |
return hwengine; |
|
40 |
} |
|
41 |
||
42 |
void HWEngine::exposeToQML() |
|
43 |
{ |
|
44 |
qDebug("HWEngine::exposeToQML"); |
|
45 |
qmlRegisterSingletonType<HWEngine>("Hedgewars.Engine", 1, 0, "HWEngine", hwengine_singletontype_provider); |
|
46 |
} |