Merge branch 'feature_localization' of https://github.com/02JanDal/MultiMC5 into develop

Conflicts:
	gui/dialogs/SettingsDialog.cpp
	gui/dialogs/SettingsDialog.ui
This commit is contained in:
Petr Mrázek 2014-01-12 23:04:05 +01:00
commit 54a9ee5eb0
7 changed files with 1784 additions and 615 deletions

View File

@ -282,7 +282,6 @@ gui/dialogs/SettingsDialog.h
gui/dialogs/SettingsDialog.cpp gui/dialogs/SettingsDialog.cpp
gui/dialogs/CopyInstanceDialog.h gui/dialogs/CopyInstanceDialog.h
gui/dialogs/CopyInstanceDialog.cpp gui/dialogs/CopyInstanceDialog.cpp
gui/dialogs/dialogs/
gui/dialogs/NewInstanceDialog.cpp gui/dialogs/NewInstanceDialog.cpp
gui/dialogs/ProgressDialog.h gui/dialogs/ProgressDialog.h
gui/dialogs/ProgressDialog.cpp gui/dialogs/ProgressDialog.cpp

View File

@ -47,8 +47,6 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override)
setOrganizationName("MultiMC"); setOrganizationName("MultiMC");
setApplicationName("MultiMC5"); setApplicationName("MultiMC5");
initTranslations();
setAttribute(Qt::AA_UseHighDpiPixmaps); setAttribute(Qt::AA_UseHighDpiPixmaps);
// Don't quit on hiding the last window // Don't quit on hiding the last window
this->setQuitOnLastWindowClosed(false); this->setQuitOnLastWindowClosed(false);
@ -175,6 +173,9 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override)
// load settings // load settings
initGlobalSettings(); initGlobalSettings();
// load translations
initTranslations();
// initialize the updater // initialize the updater
m_updateChecker.reset(new UpdateChecker()); m_updateChecker.reset(new UpdateChecker());
@ -240,18 +241,20 @@ MultiMC::~MultiMC()
void MultiMC::initTranslations() void MultiMC::initTranslations()
{ {
QLocale locale(m_settings->get("Language").toString());
QLocale::setDefault(locale);
QLOG_INFO() << "Your language is" << locale.bcp47Name();
m_qt_translator.reset(new QTranslator()); m_qt_translator.reset(new QTranslator());
if (m_qt_translator->load("qt_" + QLocale::system().name(), if (m_qt_translator->load("qt_" + locale.bcp47Name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath))) QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
{ {
std::cout << "Loading Qt Language File for " QLOG_DEBUG() << "Loading Qt Language File for"
<< QLocale::system().name().toLocal8Bit().constData() << "..."; << locale.bcp47Name().toLocal8Bit().constData() << "...";
if (!installTranslator(m_qt_translator.get())) if (!installTranslator(m_qt_translator.get()))
{ {
std::cout << " failed."; QLOG_ERROR() << "Loading Qt Language File failed.";
m_qt_translator.reset(); m_qt_translator.reset();
} }
std::cout << std::endl;
} }
else else
{ {
@ -259,17 +262,15 @@ void MultiMC::initTranslations()
} }
m_mmc_translator.reset(new QTranslator()); m_mmc_translator.reset(new QTranslator());
if (m_mmc_translator->load("mmc_" + QLocale::system().name(), if (m_mmc_translator->load("mmc_" + locale.bcp47Name(), MMC->root() + "/translations"))
QDir("translations").absolutePath()))
{ {
std::cout << "Loading MMC Language File for " QLOG_DEBUG() << "Loading MMC Language File for"
<< QLocale::system().name().toLocal8Bit().constData() << "..."; << locale.bcp47Name().toLocal8Bit().constData() << "...";
if (!installTranslator(m_mmc_translator.get())) if (!installTranslator(m_mmc_translator.get()))
{ {
std::cout << " failed."; QLOG_ERROR() << "Loading MMC Language File failed.";
m_mmc_translator.reset(); m_mmc_translator.reset();
} }
std::cout << std::endl;
} }
else else
{ {
@ -372,6 +373,9 @@ void MultiMC::initGlobalSettings()
// Editors // Editors
m_settings->registerSetting("JsonEditor", QString()); m_settings->registerSetting("JsonEditor", QString());
// Language
m_settings->registerSetting("Language", QLocale(QLocale::system().language()).bcp47Name());
// Console // Console
m_settings->registerSetting("ShowConsole", true); m_settings->registerSetting("ShowConsole", true);
m_settings->registerSetting("AutoCloseConsole", true); m_settings->registerSetting("AutoCloseConsole", true);

View File

@ -50,8 +50,8 @@ void showWebsiteForMod(QWidget *parentDlg, Mod &m)
else else
{ {
CustomMessageBox::selectable( CustomMessageBox::selectable(
parentDlg, parentDlg->tr("How sad!"), parentDlg, QObject::tr("How sad!"),
parentDlg->tr("The mod author didn't provide a website link for this mod."), QObject::tr("The mod author didn't provide a website link for this mod."),
QMessageBox::Warning); QMessageBox::Warning);
} }
} }

View File

@ -284,6 +284,9 @@ void SettingsDialog::refreshUpdateChannelDesc()
void SettingsDialog::applySettings(SettingsObject *s) void SettingsDialog::applySettings(SettingsObject *s)
{ {
// Language
s->set("Language", ui->languageBox->itemData(ui->languageBox->currentIndex()).toLocale().bcp47Name());
// Updates // Updates
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked()); s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
s->set("UpdateChannel", m_currentUpdateChannel); s->set("UpdateChannel", m_currentUpdateChannel);
@ -365,6 +368,19 @@ void SettingsDialog::applySettings(SettingsObject *s)
void SettingsDialog::loadSettings(SettingsObject *s) void SettingsDialog::loadSettings(SettingsObject *s)
{ {
// Language
ui->languageBox->clear();
ui->languageBox->addItem(tr("English"), QLocale(QLocale::English));
foreach(const QString & lang,
QDir(MMC->root() + "/translations").entryList(QStringList() << "*.qm", QDir::Files))
{
QLocale locale(lang.section(QRegExp("[_\.]"), 1));
ui->languageBox->addItem(
QLocale::languageToString(locale.language()),
locale);
}
ui->languageBox->setCurrentIndex(ui->languageBox->findData(QLocale(s->get("Language").toString())));
// Updates // Updates
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool()); ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
m_currentUpdateChannel = s->get("UpdateChannel").toString(); m_currentUpdateChannel = s->get("UpdateChannel").toString();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>526</width> <width>545</width>
<height>723</height> <height>609</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -35,43 +35,11 @@
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="generalTab"> <widget class="QWidget" name="featuresTab">
<attribute name="title"> <attribute name="title">
<string>General</string> <string>Features</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QGroupBox" name="sortingModeBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Sorting Mode</string>
</property>
<layout class="QHBoxLayout" name="sortingModeBoxLayout">
<item>
<widget class="QRadioButton" name="sortLastLaunchedBtn">
<property name="text">
<string>By last launched</string>
</property>
<attribute name="buttonGroup">
<string notr="true">sortingModeGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="sortByNameBtn">
<property name="text">
<string>By name</string>
</property>
<attribute name="buttonGroup">
<string notr="true">sortingModeGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="updateSettingsBox"> <widget class="QGroupBox" name="updateSettingsBox">
<property name="title"> <property name="title">
@ -85,8 +53,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QVBoxLayout" name="channelVerticalLayout">
<item> <item>
<widget class="QLabel" name="updateChannelLabel"> <widget class="QLabel" name="updateChannelLabel">
<property name="text"> <property name="text">
@ -112,8 +78,6 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
@ -280,6 +244,78 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="generalTab">
<attribute name="title">
<string>User Interface</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Language (needs restart):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="languageBox"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="sortingModeBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Sorting Mode</string>
</property>
<layout class="QHBoxLayout" name="sortingModeBoxLayout">
<item>
<widget class="QRadioButton" name="sortLastLaunchedBtn">
<property name="text">
<string>By last launched</string>
</property>
<attribute name="buttonGroup">
<string notr="true">sortingModeGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="sortByNameBtn">
<property name="text">
<string>By name</string>
</property>
<attribute name="buttonGroup">
<string notr="true">sortingModeGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="editorsBox"> <widget class="QGroupBox" name="editorsBox">
<property name="title"> <property name="title">
@ -427,165 +463,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="networkTab">
<property name="toolTip">
<string>Network settings.</string>
</property>
<attribute name="title">
<string>Network</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QGroupBox" name="proxySettingsBox">
<property name="title">
<string>Proxy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="proxyTypeBox">
<property name="title">
<string>Type</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="proxyDefaultBtn">
<property name="toolTip">
<string>Uses your system's default proxy settings.</string>
</property>
<property name="text">
<string>Default</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxyNoneBtn">
<property name="text">
<string>None</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxySOCKS5Btn">
<property name="text">
<string>SOCKS5</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxyHTTPBtn">
<property name="text">
<string>HTTP</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="proxyAddrBox">
<property name="title">
<string>Address and Port</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="proxyAddrEdit">
<property name="placeholderText">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="proxyPortEdit">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="proxyAuthBox">
<property name="title">
<string>Authentication</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<widget class="QLineEdit" name="proxyUserEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="proxyUsernameLabel">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="proxyPasswordLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="proxyPassEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="proxyPlainTextWarningLabel">
<property name="text">
<string>Note: Proxy username and password are stored in plain text inside MultiMC's configuration file!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="javaTab"> <widget class="QWidget" name="javaTab">
<attribute name="title"> <attribute name="title">
<string>Java</string> <string>Java</string>
@ -827,6 +704,165 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="networkTab">
<property name="toolTip">
<string>Network settings.</string>
</property>
<attribute name="title">
<string>Network</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QGroupBox" name="proxySettingsBox">
<property name="title">
<string>Proxy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="proxyTypeBox">
<property name="title">
<string>Type</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="proxyDefaultBtn">
<property name="toolTip">
<string>Uses your system's default proxy settings.</string>
</property>
<property name="text">
<string>Default</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxyNoneBtn">
<property name="text">
<string>None</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxySOCKS5Btn">
<property name="text">
<string>SOCKS5</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxyHTTPBtn">
<property name="text">
<string>HTTP</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="proxyAddrBox">
<property name="title">
<string>Address and Port</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="proxyAddrEdit">
<property name="placeholderText">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="proxyPortEdit">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="proxyAuthBox">
<property name="title">
<string>Authentication</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<widget class="QLineEdit" name="proxyUserEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="proxyUsernameLabel">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="proxyPasswordLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="proxyPassEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="proxyPlainTextWarningLabel">
<property name="text">
<string>Note: Proxy username and password are stored in plain text inside MultiMC's configuration file!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>
@ -845,20 +881,6 @@
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
<tabstop>sortLastLaunchedBtn</tabstop> <tabstop>sortLastLaunchedBtn</tabstop>
<tabstop>sortByNameBtn</tabstop> <tabstop>sortByNameBtn</tabstop>
<tabstop>autoUpdateCheckBox</tabstop>
<tabstop>trackFtbBox</tabstop>
<tabstop>ftbLauncherBox</tabstop>
<tabstop>ftbLauncherBrowseBtn</tabstop>
<tabstop>ftbBox</tabstop>
<tabstop>ftbBrowseBtn</tabstop>
<tabstop>instDirTextBox</tabstop>
<tabstop>instDirBrowseBtn</tabstop>
<tabstop>modsDirTextBox</tabstop>
<tabstop>modsDirBrowseBtn</tabstop>
<tabstop>lwjglDirTextBox</tabstop>
<tabstop>lwjglDirBrowseBtn</tabstop>
<tabstop>iconsDirTextBox</tabstop>
<tabstop>iconsDirBrowseBtn</tabstop>
<tabstop>jsonEditorTextBox</tabstop> <tabstop>jsonEditorTextBox</tabstop>
<tabstop>jsonEditorBrowseBtn</tabstop> <tabstop>jsonEditorBrowseBtn</tabstop>
<tabstop>maximizedCheckBox</tabstop> <tabstop>maximizedCheckBox</tabstop>
@ -916,7 +938,7 @@
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="sortingModeGroup"/>
<buttongroup name="proxyGroup"/> <buttongroup name="proxyGroup"/>
<buttongroup name="sortingModeGroup"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -23,8 +23,8 @@ void checkJVMArgs(QString jvmargs, QWidget *parent)
if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]"))) if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]")))
{ {
CustomMessageBox::selectable( CustomMessageBox::selectable(
parent, parent->tr("JVM arguments warning"), parent, QObject::tr("JVM arguments warning"),
parent->tr("You tried to manually set a JVM memory option (using " QObject::tr("You tried to manually set a JVM memory option (using "
" \"-XX:PermSize\", \"-Xmx\" or \"-Xms\") - there" " \"-XX:PermSize\", \"-Xmx\" or \"-Xms\") - there"
" are dedicated boxes for these in the settings (Java" " are dedicated boxes for these in the settings (Java"
" tab, in the Memory group at the top).\n" " tab, in the Memory group at the top).\n"

File diff suppressed because it is too large Load Diff