all repos — mgba @ 19758d711528b15a255b353d1ef740d516b8685e

mGBA Game Boy Advance Emulator

src/platform/qt/GBAApp.cpp (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "GBAApp.h"
 7
 8#include "GameController.h"
 9
10#include <QFileOpenEvent>
11
12extern "C" {
13#include "platform/commandline.h"
14}
15
16using namespace QGBA;
17
18GBAApp::GBAApp(int& argc, char* argv[])
19	: QApplication(argc, argv)
20	, m_window(&m_configController)
21{
22#ifdef BUILD_SDL
23	SDL_Init(SDL_INIT_NOPARACHUTE);
24#endif
25
26    QApplication::setApplicationName(PROJECT_NAME);
27    QApplication::setApplicationVersion(PROJECT_VERSION);
28
29    m_window.show();
30
31	GBAArguments args = {};
32    if (m_configController.parseArguments(&args, argc, argv)) {
33		m_window.argumentsPassed(&args);
34    } else {
35		m_window.loadConfig();
36    }
37	freeArguments(&args);
38}
39
40bool GBAApp::event(QEvent* event) {
41	if (event->type() == QEvent::FileOpen) {
42		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
43		return true;
44	}
45	return QApplication::event(event);
46}