all repos — mgba @ 4a9b87cfd08e15d1980b4df68ba02745303752e5

mGBA Game Boy Advance Emulator

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	, m_window(&m_configController)
16{
17#ifdef BUILD_SDL
18	SDL_Init(SDL_INIT_NOPARACHUTE);
19#endif
20
21    QApplication::setApplicationName(PROJECT_NAME);
22    QApplication::setApplicationVersion(PROJECT_VERSION);
23
24	GBAArguments args = {};
25    if (m_configController.parseArguments(&args, argc, argv)) {
26    	m_window.argumentsPassed(&args);
27    } else {
28    	m_window.loadConfig();
29    }
30	freeArguments(&args);
31
32    m_window.show();
33}
34
35bool GBAApp::event(QEvent* event) {
36	if (event->type() == QEvent::FileOpen) {
37		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
38		return true;
39	}
40	return QApplication::event(event);
41}