all repos — mgba @ a0b94db9a78a6482579edd35e6eefeb4b15bb257

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 "AudioProcessor.h"
 9#include "GameController.h"
10
11#include <QFileOpenEvent>
12
13extern "C" {
14#include "platform/commandline.h"
15}
16
17using namespace QGBA;
18
19GBAApp::GBAApp(int& argc, char* argv[])
20	: QApplication(argc, argv)
21	, m_window(&m_configController)
22{
23#ifdef BUILD_SDL
24	SDL_Init(SDL_INIT_NOPARACHUTE);
25#endif
26
27	SocketSubsystemInit();
28
29	QApplication::setApplicationName(PROJECT_NAME);
30	QApplication::setApplicationVersion(PROJECT_VERSION);
31
32#ifndef Q_OS_MAC
33	m_window.show();
34#endif
35
36	GBAArguments args;
37	if (m_configController.parseArguments(&args, argc, argv)) {
38		m_window.argumentsPassed(&args);
39	} else {
40		m_window.loadConfig();
41	}
42	freeArguments(&args);
43
44	AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt()));
45	m_window.controller()->reloadAudioDriver();
46
47#ifdef Q_OS_MAC
48	m_window.show();
49#endif
50}
51
52bool GBAApp::event(QEvent* event) {
53	if (event->type() == QEvent::FileOpen) {
54		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
55		return true;
56	}
57	return QApplication::event(event);
58}