all repos — mgba @ 6d89c37886d461c0fad868a4c1dc12fd29a2b8af

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	GBAConfigMapGraphicsOpts(&config, PORT, &m_opts);
26
27	ConfigurationDeinit(&config);
28
29	if (parseArguments(&m_args, &m_opts, argc, argv, 0)) {
30		m_window.setOptions(&m_opts);
31		m_window.argumentsPassed(&m_args);
32	} else {
33		m_window.setOptions(&m_opts);
34	}
35
36    m_window.show();
37}
38
39GBAApp::~GBAApp() {
40	freeArguments(&m_args);
41	GBAConfigFreeOpts(&m_opts);
42}
43
44bool GBAApp::event(QEvent* event) {
45	if (event->type() == QEvent::FileOpen) {
46		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
47		return true;
48	}
49	return QApplication::event(event);
50}