Pass ROM as launch argument

This commit is contained in:
Fabien Freling 2019-07-12 13:39:49 +02:00
parent fda60ba538
commit 690df0321f
2 changed files with 10 additions and 3 deletions

View file

@ -10,16 +10,19 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QCoreApplication::setApplicationName("OBoy");
QCoreApplication::setOrganizationName("ffreling");
QCoreApplication::setOrganizationDomain("ffreling.com");
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
caml_main(argv);
qmlRegisterType<OBoy>("com.oboy.oboy", 1, 0, "OBoy"); qmlRegisterType<OBoy>("com.oboy.oboy", 1, 0, "OBoy");
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
engine.addImageProvider(QLatin1String("oboy"), new OImageProvider(engine)); engine.addImageProvider(QLatin1String("oboy"), new OImageProvider(engine));
engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
caml_main(argv);
return app.exec(); return app.exec();
} }

View file

@ -1,6 +1,7 @@
#include "oboy.h" #include "oboy.h"
#include <QtGlobal> #include <QtGlobal>
#include <QCoreApplication>
#include <caml/mlvalues.h> #include <caml/mlvalues.h>
#include <caml/callback.h> #include <caml/callback.h>
@ -12,7 +13,10 @@
OBoy::OBoy(QObject *parent) : QObject(parent) OBoy::OBoy(QObject *parent) : QObject(parent)
{ {
// load("/Users/ffreling/Downloads/Super_Mario_Land.gb"); const QStringList args = QCoreApplication::arguments();
if (args.size() > 1) {
load(args.at(1));
}
} }
value *fetch_caml_callback(const char *name) { value *fetch_caml_callback(const char *name) {