all repos — mgba @ 9b6fc4482555e1a9e06b088604ebaabbc8325e2b

mGBA Game Boy Advance Emulator

src/platform/qt/main.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
 7// This must be defined before anything else is included.
 8#define SDL_MAIN_HANDLED
 9
10#include "ConfigController.h"
11#include "GBAApp.h"
12#include "Window.h"
13
14#include <mgba/core/version.h>
15#include <mgba/internal/gba/video.h>
16
17#include <QLibraryInfo>
18#include <QTranslator>
19
20#ifdef QT_STATIC
21#include <QtPlugin>
22#ifdef _WIN32
23Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
24#ifdef BUILD_QT_MULTIMEDIA
25Q_IMPORT_PLUGIN(QWindowsAudioPlugin);
26#endif
27#endif
28#endif
29
30using namespace QGBA;
31
32int main(int argc, char* argv[]) {
33#ifdef BUILD_SDL
34	SDL_SetMainReady();
35#endif
36
37	ConfigController configController;
38
39	QLocale locale;
40	if (!configController.getQtOption("language").isNull()) {
41		locale = QLocale(configController.getQtOption("language").toString());
42		QLocale::setDefault(locale);
43	}
44
45	mArguments args;
46	mGraphicsOpts graphicsOpts;
47	mSubParser subparser;
48	initParserForGraphics(&subparser, &graphicsOpts);
49	bool loaded = configController.parseArguments(&args, argc, argv, &subparser);
50	if (loaded && args.showHelp) {
51		usage(argv[0], subparser.usage);
52		return 0;
53	}
54
55	GBAApp application(argc, argv, &configController);
56
57	QTranslator qtTranslator;
58	qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
59	application.installTranslator(&qtTranslator);
60
61	QTranslator langTranslator;
62	langTranslator.load(locale, binaryName, "-", ":/translations/");
63	application.installTranslator(&langTranslator);
64
65	Window* w = application.newWindow();
66	if (loaded) {
67		w->argumentsPassed(&args);
68	} else {
69		w->loadConfig();
70	}
71	freeArguments(&args);
72
73	if (graphicsOpts.multiplier) {
74		w->resizeFrame(QSize(VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier));
75	}
76	if (graphicsOpts.fullscreen) {
77		w->enterFullScreen();
78	}
79
80	w->show();
81
82	return application.exec();
83}