all repos — mgba @ 7cad9ab33a3ac07060bc971c3a2f9e86d15424ff

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#ifndef Q_OS_MAC
30	m_window.show();
31#endif
32
33	GBAArguments args = {};
34	if (m_configController.parseArguments(&args, argc, argv)) {
35		m_window.argumentsPassed(&args);
36	} else {
37		m_window.loadConfig();
38	}
39	freeArguments(&args);
40
41#ifdef Q_OS_MAC
42	m_window.show();
43#endif
44}
45
46bool GBAApp::event(QEvent* event) {
47	if (event->type() == QEvent::FileOpen) {
48		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
49		return true;
50	}
51	return QApplication::event(event);
52}