cleaned up and commented code
This commit is contained in:
+13
-8
@@ -6,26 +6,31 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// creates our Qt GUI app
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
// creats InputManager and installs it as an application-wide event filter so it can observe input events before normal delivery
|
||||
InputManager inputManager;
|
||||
app.installEventFilter(&inputManager);
|
||||
|
||||
qmlRegisterUncreatableMetaObject(
|
||||
InputManager::staticMetaObject,
|
||||
"NomadInput",
|
||||
1, 0,
|
||||
"InputManager",
|
||||
"InputManager is created by nomad"
|
||||
);
|
||||
// Expose InputManager's Qt meta-object to QML under the NomadInput module, for ease of reading code.
|
||||
// This lets us refer to inputs as InputManager.Left, InputManager.Right, et cetera
|
||||
// QML isn't allowed to create it's own
|
||||
qmlRegisterUncreatableMetaObject(InputManager::staticMetaObject, "NomadInput", 1, 0, "InputManager", "InputManager is created by nomad");
|
||||
|
||||
// start up the QML engine
|
||||
QQmlApplicationEngine engine;
|
||||
// make our InputManager instance available to QML for signals
|
||||
engine.rootContext()->setContextProperty("inputManager", &inputManager);
|
||||
|
||||
// load our Main.qml into the engine to start things off
|
||||
engine.loadFromModule("nomad", "Main");
|
||||
|
||||
if (engine.rootObjects().isEmpty())
|
||||
// makes sure we've got QML objects
|
||||
if (engine.rootObjects().isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Start the event loop and keeps nomad running until it exits
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user