#include #include #include #include #include #include "input/InputManager.h" #include "library/LibraryDatabase.h" #include "library/GameRepository.h" #include "library/GameLibraryModel.h" int main(int argc, char *argv[]) { // creates our Qt GUI app QGuiApplication app(argc, argv); // opens nomad's persistent library database, ensures ready schema, etc LibraryDatabase libraryDatabase; if (!libraryDatabase.open()) { qCritical() << "Failed to open nomad library:" << libraryDatabase.lastError(); return -1; } // GameRepository hadnles reading our game records from the database, while // GameLibraryModel exposes those records in a QML-friendly list model GameRepository gameRepository(libraryDatabase.database()); GameLibraryModel gameLibraryModel(gameRepository); // database diagnostics qDebug() << "Library database:" << libraryDatabase.databasePath(); qDebug() << "Games loaded:" << gameLibraryModel.rowCount(); // 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); // 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); engine.rootContext()->setContextProperty("gameLibraryModel", &gameLibraryModel); // load our Main.qml into the engine to start things off engine.loadFromModule("nomad", "Main"); // 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(); }