Display maps from OCaml

This commit is contained in:
Fabien Freling 2019-07-05 14:20:17 +02:00
parent d4e753a6e1
commit 35ea1690fe
11 changed files with 121 additions and 10 deletions

22
src/qt/oimageprovider.cpp Normal file
View file

@ -0,0 +1,22 @@
#include "oimageprovider.h"
#include "oboy.h"
OImageProvider::OImageProvider(QQmlApplicationEngine &engine)
: QQuickImageProvider(QQuickImageProvider::Image)
, _engine(engine)
{
}
QImage OImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
QList<QObject*> roots = _engine.rootObjects();
OBoy *oboy = roots[0]->findChild<OBoy*>("qml_oboy");
if (!oboy) {
qFatal("Cannot find oboy instance.");
}
Q_ASSERT(oboy->loaded());
QImage img = oboy->backgroundMap();
return img;
}