all repos — mgba @ 284f4df31ba30f917d717485505d73f7465a9209

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	qRegisterMetaType<const uint32_t*>("const uint32_t*");
30
31	QApplication::setApplicationName(PROJECT_NAME);
32	QApplication::setApplicationVersion(PROJECT_VERSION);
33
34#ifndef Q_OS_MAC
35	m_window.show();
36#endif
37
38	GBAArguments args;
39	if (m_configController.parseArguments(&args, argc, argv)) {
40		m_window.argumentsPassed(&args);
41	} else {
42		m_window.loadConfig();
43	}
44	freeArguments(&args);
45
46	AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt()));
47	m_window.controller()->reloadAudioDriver();
48
49#ifdef Q_OS_MAC
50	m_window.show();
51#endif
52}
53
54bool GBAApp::event(QEvent* event) {
55	if (event->type() == QEvent::FileOpen) {
56		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
57		return true;
58	}
59	return QApplication::event(event);
60}