all repos — mgba @ 65543bdd69d97d4d8e9da098f2661cfc09191fc7

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