all repos — mgba @ d744714ac58b5afea6d8117af5290caf76422797

mGBA Game Boy Advance Emulator

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

 1#include "GBAApp.h"
 2
 3#include "GameController.h"
 4
 5#include <QFileOpenEvent>
 6
 7#define PORT "qt"
 8
 9using namespace QGBA;
10
11GBAApp::GBAApp(int& argc, char* argv[])
12	: QApplication(argc, argv)
13	, m_args()
14	, m_opts()
15{
16    QApplication::setApplicationName(PROJECT_NAME);
17    QApplication::setApplicationVersion(PROJECT_VERSION);
18
19	struct Configuration config;
20
21	ConfigurationInit(&config);
22	GBAConfigLoad(&config);
23
24	GBAConfigMapGeneralOpts(&config, PORT, &m_opts);
25
26	ConfigurationDeinit(&config);
27
28	if (parseArguments(&m_args, &m_opts, argc, argv, 0)) {
29		m_window.setOptions(&m_opts);
30		m_window.argumentsPassed(&m_args);
31	} else {
32		m_window.setOptions(&m_opts);
33	}
34
35    m_window.show();
36}
37
38GBAApp::~GBAApp() {
39	freeArguments(&m_args);
40	GBAConfigFreeOpts(&m_opts);
41}
42
43bool GBAApp::event(QEvent* event) {
44	if (event->type() == QEvent::FileOpen) {
45		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
46		return true;
47	}
48	return QApplication::event(event);
49}