src/platform/qt/GBAApp.cpp (view raw)
1#include "GBAApp.h"
2
3#include "GameController.h"
4
5#include <QFileOpenEvent>
6
7extern "C" {
8#include "platform/commandline.h"
9}
10
11using namespace QGBA;
12
13GBAApp::GBAApp(int& argc, char* argv[])
14 : QApplication(argc, argv)
15{
16 QApplication::setApplicationName(PROJECT_NAME);
17 QApplication::setApplicationVersion(PROJECT_VERSION);
18
19 GBAArguments args = {};
20 m_window.setConfig(&m_configController);
21 if (m_configController.parseArguments(&args, argc, argv)) {
22 m_window.argumentsPassed(&args);
23 } else {
24 m_window.loadConfig();
25 }
26 freeArguments(&args);
27
28 m_window.show();
29}
30
31bool GBAApp::event(QEvent* event) {
32 if (event->type() == QEvent::FileOpen) {
33 m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
34 return true;
35 }
36 return QApplication::event(event);
37}