mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix translation initialization (fixes #776)
This commit is contained in:
parent
d3678471f6
commit
9b6fc44825
1
CHANGES
1
CHANGES
|
@ -164,6 +164,7 @@ Bugfixes:
|
||||||
- Qt: Fix data directory path
|
- Qt: Fix data directory path
|
||||||
- Qt: Fix controls not saving on non-SDL builds
|
- Qt: Fix controls not saving on non-SDL builds
|
||||||
- GB Video: Fix LYC regression
|
- GB Video: Fix LYC regression
|
||||||
|
- Qt: Fix translation initialization (fixes mgba.io/i/776)
|
||||||
Misc:
|
Misc:
|
||||||
- Qt: Add language selector
|
- Qt: Add language selector
|
||||||
- GBA Timer: Improve accuracy of timers
|
- GBA Timer: Improve accuracy of timers
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
|
|
||||||
#include "AudioProcessor.h"
|
#include "AudioProcessor.h"
|
||||||
|
#include "ConfigController.h"
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "GameController.h"
|
#include "GameController.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
@ -14,11 +15,8 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QLibraryInfo>
|
|
||||||
#include <QTranslator>
|
|
||||||
|
|
||||||
#include <mgba/core/version.h>
|
#include <mgba/core/version.h>
|
||||||
#include <mgba/internal/gba/video.h>
|
|
||||||
#include <mgba-util/socket.h>
|
#include <mgba-util/socket.h>
|
||||||
#include <mgba-util/vfs.h>
|
#include <mgba-util/vfs.h>
|
||||||
|
|
||||||
|
@ -32,8 +30,9 @@ static GBAApp* g_app = nullptr;
|
||||||
|
|
||||||
mLOG_DEFINE_CATEGORY(QT, "Qt", "platform.qt");
|
mLOG_DEFINE_CATEGORY(QT, "Qt", "platform.qt");
|
||||||
|
|
||||||
GBAApp::GBAApp(int& argc, char* argv[])
|
GBAApp::GBAApp(int& argc, char* argv[], ConfigController* config)
|
||||||
: QApplication(argc, argv)
|
: QApplication(argc, argv)
|
||||||
|
, m_configController(config)
|
||||||
{
|
{
|
||||||
g_app = this;
|
g_app = this;
|
||||||
|
|
||||||
|
@ -45,21 +44,6 @@ GBAApp::GBAApp(int& argc, char* argv[])
|
||||||
setWindowIcon(QIcon(":/res/mgba-512.png"));
|
setWindowIcon(QIcon(":/res/mgba-512.png"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QLocale locale;
|
|
||||||
|
|
||||||
if (!m_configController.getQtOption("language").isNull()) {
|
|
||||||
locale = QLocale(m_configController.getQtOption("language").toString());
|
|
||||||
QLocale::setDefault(locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTranslator qtTranslator;
|
|
||||||
qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
|
||||||
installTranslator(&qtTranslator);
|
|
||||||
|
|
||||||
QTranslator langTranslator;
|
|
||||||
langTranslator.load(locale, binaryName, "-", ":/translations/");
|
|
||||||
installTranslator(&langTranslator);
|
|
||||||
|
|
||||||
SocketSubsystemInit();
|
SocketSubsystemInit();
|
||||||
qRegisterMetaType<const uint32_t*>("const uint32_t*");
|
qRegisterMetaType<const uint32_t*>("const uint32_t*");
|
||||||
qRegisterMetaType<mCoreThread*>("mCoreThread*");
|
qRegisterMetaType<mCoreThread*>("mCoreThread*");
|
||||||
|
@ -67,50 +51,15 @@ GBAApp::GBAApp(int& argc, char* argv[])
|
||||||
QApplication::setApplicationName(projectName);
|
QApplication::setApplicationName(projectName);
|
||||||
QApplication::setApplicationVersion(projectVersion);
|
QApplication::setApplicationVersion(projectVersion);
|
||||||
|
|
||||||
if (!m_configController.getQtOption("displayDriver").isNull()) {
|
if (!m_configController->getQtOption("displayDriver").isNull()) {
|
||||||
Display::setDriver(static_cast<Display::Driver>(m_configController.getQtOption("displayDriver").toInt()));
|
Display::setDriver(static_cast<Display::Driver>(m_configController->getQtOption("displayDriver").toInt()));
|
||||||
}
|
|
||||||
|
|
||||||
mArguments args;
|
|
||||||
mGraphicsOpts graphicsOpts;
|
|
||||||
mSubParser subparser;
|
|
||||||
initParserForGraphics(&subparser, &graphicsOpts);
|
|
||||||
bool loaded = m_configController.parseArguments(&args, argc, argv, &subparser);
|
|
||||||
if (loaded && args.showHelp) {
|
|
||||||
usage(argv[0], subparser.usage);
|
|
||||||
::exit(0);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadGameDB();
|
reloadGameDB();
|
||||||
|
|
||||||
if (!m_configController.getQtOption("audioDriver").isNull()) {
|
if (!m_configController->getQtOption("audioDriver").isNull()) {
|
||||||
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt()));
|
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController->getQtOption("audioDriver").toInt()));
|
||||||
}
|
}
|
||||||
Window* w = new Window(&m_configController);
|
|
||||||
connect(w, &Window::destroyed, [this, w]() {
|
|
||||||
m_windows.removeAll(w);
|
|
||||||
});
|
|
||||||
m_windows.append(w);
|
|
||||||
|
|
||||||
if (loaded) {
|
|
||||||
w->argumentsPassed(&args);
|
|
||||||
} else {
|
|
||||||
w->loadConfig();
|
|
||||||
}
|
|
||||||
freeArguments(&args);
|
|
||||||
|
|
||||||
if (graphicsOpts.multiplier) {
|
|
||||||
w->resizeFrame(QSize(VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier));
|
|
||||||
}
|
|
||||||
if (graphicsOpts.fullscreen) {
|
|
||||||
w->enterFullScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
w->show();
|
|
||||||
|
|
||||||
w->controller()->setMultiplayerController(&m_multiplayer);
|
|
||||||
w->multiplayerChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GBAApp::~GBAApp() {
|
GBAApp::~GBAApp() {
|
||||||
|
@ -132,7 +81,7 @@ Window* GBAApp::newWindow() {
|
||||||
if (m_windows.count() >= MAX_GBAS) {
|
if (m_windows.count() >= MAX_GBAS) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Window* w = new Window(&m_configController, m_multiplayer.attached());
|
Window* w = new Window(m_configController, m_multiplayer.attached());
|
||||||
int windowId = m_multiplayer.attached();
|
int windowId = m_multiplayer.attached();
|
||||||
connect(w, &Window::destroyed, [this, w]() {
|
connect(w, &Window::destroyed, [this, w]() {
|
||||||
m_windows.removeAll(w);
|
m_windows.removeAll(w);
|
||||||
|
@ -175,10 +124,10 @@ void GBAApp::continueAll(const QList<Window*>& paused) {
|
||||||
QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QString& filter) {
|
QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QString& filter) {
|
||||||
QList<Window*> paused;
|
QList<Window*> paused;
|
||||||
pauseAll(&paused);
|
pauseAll(&paused);
|
||||||
QString filename = QFileDialog::getOpenFileName(owner, title, m_configController.getOption("lastDirectory"), filter);
|
QString filename = QFileDialog::getOpenFileName(owner, title, m_configController->getOption("lastDirectory"), filter);
|
||||||
continueAll(paused);
|
continueAll(paused);
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
m_configController->setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
@ -186,10 +135,10 @@ QString GBAApp::getOpenFileName(QWidget* owner, const QString& title, const QStr
|
||||||
QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QString& filter) {
|
QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QString& filter) {
|
||||||
QList<Window*> paused;
|
QList<Window*> paused;
|
||||||
pauseAll(&paused);
|
pauseAll(&paused);
|
||||||
QString filename = QFileDialog::getSaveFileName(owner, title, m_configController.getOption("lastDirectory"), filter);
|
QString filename = QFileDialog::getSaveFileName(owner, title, m_configController->getOption("lastDirectory"), filter);
|
||||||
continueAll(paused);
|
continueAll(paused);
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
m_configController->setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
@ -197,10 +146,10 @@ QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QStr
|
||||||
QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title) {
|
QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title) {
|
||||||
QList<Window*> paused;
|
QList<Window*> paused;
|
||||||
pauseAll(&paused);
|
pauseAll(&paused);
|
||||||
QString filename = QFileDialog::getExistingDirectory(owner, title, m_configController.getOption("lastDirectory"));
|
QString filename = QFileDialog::getExistingDirectory(owner, title, m_configController->getOption("lastDirectory"));
|
||||||
continueAll(paused);
|
continueAll(paused);
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
m_configController.setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
m_configController->setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include "ConfigController.h"
|
|
||||||
#include "MultiplayerController.h"
|
#include "MultiplayerController.h"
|
||||||
|
|
||||||
struct NoIntroDB;
|
struct NoIntroDB;
|
||||||
|
@ -21,6 +20,7 @@ mLOG_DECLARE_CATEGORY(QT);
|
||||||
|
|
||||||
namespace QGBA {
|
namespace QGBA {
|
||||||
|
|
||||||
|
class ConfigController;
|
||||||
class GameController;
|
class GameController;
|
||||||
class Window;
|
class Window;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class GBAApp : public QApplication {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GBAApp(int& argc, char* argv[]);
|
GBAApp(int& argc, char* argv[], ConfigController*);
|
||||||
~GBAApp();
|
~GBAApp();
|
||||||
static GBAApp* app();
|
static GBAApp* app();
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ private:
|
||||||
void pauseAll(QList<Window*>* paused);
|
void pauseAll(QList<Window*>* paused);
|
||||||
void continueAll(const QList<Window*>& paused);
|
void continueAll(const QList<Window*>& paused);
|
||||||
|
|
||||||
ConfigController m_configController;
|
ConfigController* m_configController;
|
||||||
QList<Window*> m_windows;
|
QList<Window*> m_windows;
|
||||||
MultiplayerController m_multiplayer;
|
MultiplayerController m_multiplayer;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "InputController.h"
|
#include "InputController.h"
|
||||||
#include "LogController.h"
|
#include "LogController.h"
|
||||||
#include "MultiplayerController.h"
|
#include "MultiplayerController.h"
|
||||||
|
#include "Override.h"
|
||||||
#include "VFileDevice.h"
|
#include "VFileDevice.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
#include "LibraryController.h"
|
#include "LibraryController.h"
|
||||||
|
|
||||||
#include "../GBAApp.h"
|
#include "ConfigController.h"
|
||||||
|
#include "GBAApp.h"
|
||||||
#include "LibraryGrid.h"
|
#include "LibraryGrid.h"
|
||||||
#include "LibraryTree.h"
|
#include "LibraryTree.h"
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,15 @@
|
||||||
// This must be defined before anything else is included.
|
// This must be defined before anything else is included.
|
||||||
#define SDL_MAIN_HANDLED
|
#define SDL_MAIN_HANDLED
|
||||||
|
|
||||||
|
#include "ConfigController.h"
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
#include <mgba/core/version.h>
|
#include <mgba/core/version.h>
|
||||||
|
#include <mgba/internal/gba/video.h>
|
||||||
|
|
||||||
|
#include <QLibraryInfo>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
#ifdef QT_STATIC
|
#ifdef QT_STATIC
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
|
@ -22,11 +27,57 @@ Q_IMPORT_PLUGIN(QWindowsAudioPlugin);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace QGBA;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
SDL_SetMainReady();
|
SDL_SetMainReady();
|
||||||
#endif
|
#endif
|
||||||
QGBA::GBAApp application(argc, argv);
|
|
||||||
|
ConfigController configController;
|
||||||
|
|
||||||
|
QLocale locale;
|
||||||
|
if (!configController.getQtOption("language").isNull()) {
|
||||||
|
locale = QLocale(configController.getQtOption("language").toString());
|
||||||
|
QLocale::setDefault(locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
mArguments args;
|
||||||
|
mGraphicsOpts graphicsOpts;
|
||||||
|
mSubParser subparser;
|
||||||
|
initParserForGraphics(&subparser, &graphicsOpts);
|
||||||
|
bool loaded = configController.parseArguments(&args, argc, argv, &subparser);
|
||||||
|
if (loaded && args.showHelp) {
|
||||||
|
usage(argv[0], subparser.usage);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GBAApp application(argc, argv, &configController);
|
||||||
|
|
||||||
|
QTranslator qtTranslator;
|
||||||
|
qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
|
application.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
|
QTranslator langTranslator;
|
||||||
|
langTranslator.load(locale, binaryName, "-", ":/translations/");
|
||||||
|
application.installTranslator(&langTranslator);
|
||||||
|
|
||||||
|
Window* w = application.newWindow();
|
||||||
|
if (loaded) {
|
||||||
|
w->argumentsPassed(&args);
|
||||||
|
} else {
|
||||||
|
w->loadConfig();
|
||||||
|
}
|
||||||
|
freeArguments(&args);
|
||||||
|
|
||||||
|
if (graphicsOpts.multiplier) {
|
||||||
|
w->resizeFrame(QSize(VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier));
|
||||||
|
}
|
||||||
|
if (graphicsOpts.fullscreen) {
|
||||||
|
w->enterFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
w->show();
|
||||||
|
|
||||||
return application.exec();
|
return application.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue