all repos — mgba @ a3fff6d1a5a93bd7eb36f174d498ccf1770cb26e

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
 7extern "C" {
 8#include "platform/commandline.h"
 9}
10
11using namespace QGBA;
12
13GBAApp::GBAApp(int& argc, char* argv[])
14	: QApplication(argc, argv)
15	, m_window(&m_configController)
16{
17    QApplication::setApplicationName(PROJECT_NAME);
18    QApplication::setApplicationVersion(PROJECT_VERSION);
19
20	GBAArguments args = {};
21    if (m_configController.parseArguments(&args, argc, argv)) {
22    	m_window.argumentsPassed(&args);
23    } else {
24    	m_window.loadConfig();
25    }
26	freeArguments(&args);
27
28    m_window.show();
29}
30
31bool GBAApp::event(QEvent* event) {
32	if (event->type() == QEvent::FileOpen) {
33		m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
34		return true;
35	}
36	return QApplication::event(event);
37}