mirror of https://github.com/mgba-emu/mgba.git
Qt: Add language selector
This commit is contained in:
parent
f91a4195b6
commit
4d3d579cae
2
CHANGES
2
CHANGES
|
@ -150,6 +150,8 @@ Misc:
|
|||
Bugfixes:
|
||||
- Qt: Fix memory search close button (fixes mgba.io/i/769)
|
||||
- Qt: Fix window icon being stretched
|
||||
Misc:
|
||||
- Qt: Add language selector
|
||||
|
||||
0.6 beta 1: (2017-06-29)
|
||||
- Initial beta for 0.6
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QIcon>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
|
||||
#include <mgba/core/version.h>
|
||||
|
@ -44,11 +45,19 @@ GBAApp::GBAApp(int& argc, char* argv[])
|
|||
setWindowIcon(QIcon(":/res/mgba-512.png"));
|
||||
#endif
|
||||
|
||||
QTranslator* translator = new QTranslator(this);
|
||||
if (translator->load(QLocale(), QLatin1String(binaryName), QLatin1String("-"), QLatin1String(":/translations"))) {
|
||||
installTranslator(translator);
|
||||
QLocale locale;
|
||||
|
||||
if (!m_configController.getQtOption("language").isNull()) {
|
||||
locale = QLocale(m_configController.getQtOption("language").toString());
|
||||
}
|
||||
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
installTranslator(&qtTranslator);
|
||||
|
||||
QTranslator langTranslator;
|
||||
langTranslator.load(locale, binaryName, "-", ":/translations/");
|
||||
installTranslator(&langTranslator);
|
||||
|
||||
SocketSubsystemInit();
|
||||
qRegisterMetaType<const uint32_t*>("const uint32_t*");
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "ShortcutView.h"
|
||||
|
||||
#include <mgba/core/serialize.h>
|
||||
#include <mgba/core/version.h>
|
||||
#include <mgba/internal/gba/gba.h>
|
||||
|
||||
using namespace QGBA;
|
||||
|
@ -164,6 +165,19 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
|
|||
}
|
||||
});
|
||||
|
||||
m_ui.languages->setItemData(0, QLocale("en"));
|
||||
QDir ts(":/translations/");
|
||||
for (auto name : ts.entryList()) {
|
||||
if (!name.endsWith(".qm")) {
|
||||
continue;
|
||||
}
|
||||
QLocale locale(name.remove(QString("%0-").arg(binaryName)).remove(".qm"));
|
||||
m_ui.languages->addItem(locale.nativeLanguageName(), locale);
|
||||
if (locale == QLocale()) {
|
||||
m_ui.languages->setCurrentIndex(m_ui.languages->count() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
ShortcutView* shortcutView = new ShortcutView();
|
||||
shortcutView->setController(shortcutController);
|
||||
shortcutView->setInputController(inputController);
|
||||
|
@ -253,6 +267,12 @@ void SettingsView::updateConfig() {
|
|||
emit displayDriverChanged();
|
||||
}
|
||||
|
||||
QLocale language = m_ui.languages->itemData(m_ui.languages->currentIndex()).toLocale();
|
||||
if (language != m_controller->getQtOption("language").toLocale() && !(language.bcp47Name() == QLocale::system().bcp47Name() && m_controller->getQtOption("language").isNull())) {
|
||||
m_controller->setQtOption("language", language.bcp47Name());
|
||||
emit languageChanged();
|
||||
}
|
||||
|
||||
m_controller->write();
|
||||
|
||||
emit pathsChanged();
|
||||
|
|
|
@ -29,6 +29,7 @@ signals:
|
|||
void audioDriverChanged();
|
||||
void displayDriverChanged();
|
||||
void pathsChanged();
|
||||
void languageChanged();
|
||||
void libraryCleared();
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -398,17 +398,30 @@
|
|||
</widget>
|
||||
<widget class="QWidget" name="interface_2">
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="showLibrary">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="text">
|
||||
<string>Show when no game open</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="languages">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>English</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Library:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="libraryStyle">
|
||||
<item>
|
||||
<property name="text">
|
||||
|
@ -422,35 +435,38 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="showLibrary">
|
||||
<property name="text">
|
||||
<string>Library:</string>
|
||||
<string>Show when no game open</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="clearCache">
|
||||
<property name="text">
|
||||
<string>Clear cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="Line" name="line_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="allowOpposingDirections">
|
||||
<property name="text">
|
||||
<string>Allow opposing input directions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QCheckBox" name="suspendScreensaver">
|
||||
<property name="text">
|
||||
<string>Suspend screensaver</string>
|
||||
|
@ -460,13 +476,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="pauseOnFocusLost">
|
||||
<property name="text">
|
||||
<string>Pause when inactive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="Line" name="line_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="emulation">
|
||||
|
|
|
@ -459,6 +459,7 @@ void Window::openSettingsWindow() {
|
|||
connect(settingsWindow, &SettingsView::biosLoaded, m_controller, &GameController::loadBIOS);
|
||||
connect(settingsWindow, &SettingsView::audioDriverChanged, m_controller, &GameController::reloadAudioDriver);
|
||||
connect(settingsWindow, &SettingsView::displayDriverChanged, this, &Window::mustRestart);
|
||||
connect(settingsWindow, &SettingsView::languageChanged, this, &Window::mustRestart);
|
||||
connect(settingsWindow, &SettingsView::pathsChanged, this, &Window::reloadConfig);
|
||||
connect(settingsWindow, &SettingsView::libraryCleared, m_libraryView, &LibraryController::clear);
|
||||
openView(settingsWindow);
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#include "GBAApp.h"
|
||||
#include "Window.h"
|
||||
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
|
||||
#include <mgba/core/version.h>
|
||||
|
||||
#ifdef QT_STATIC
|
||||
|
@ -31,15 +28,5 @@ int main(int argc, char* argv[]) {
|
|||
#endif
|
||||
QGBA::GBAApp application(argc, argv);
|
||||
|
||||
QLocale locale = QLocale::system();
|
||||
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
application.installTranslator(&qtTranslator);
|
||||
|
||||
QTranslator langTranslator;
|
||||
langTranslator.load(locale, binaryName, "-", ":/translations/");
|
||||
application.installTranslator(&langTranslator);
|
||||
|
||||
return application.exec();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue