diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-01-01 19:59:46 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-01-01 20:04:08 +0100 |
commit | a666dc0a1afa69b5b42aa3a487c8fa971c01cde1 (patch) | |
tree | e226954e1af8f1dce0f9e73898331aef2481503b /application/pages/global/MultiMCPage.cpp | |
parent | 722896d41f15a8bc78a864f7adcfd0527648073c (diff) | |
download | MultiMC-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.tar MultiMC-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.tar.gz MultiMC-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.tar.lz MultiMC-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.tar.xz MultiMC-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.zip |
NOISSUE fix up translation selection in settings and add OS/sys arch reporting
Diffstat (limited to 'application/pages/global/MultiMCPage.cpp')
-rw-r--r-- | application/pages/global/MultiMCPage.cpp | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/application/pages/global/MultiMCPage.cpp b/application/pages/global/MultiMCPage.cpp index 11129d86..b2ef325d 100644 --- a/application/pages/global/MultiMCPage.cpp +++ b/application/pages/global/MultiMCPage.cpp @@ -55,6 +55,7 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP defaultFormat = new QTextCharFormat(ui->fontPreview->currentCharFormat()); + m_languageModel = MMC->translations(); loadSettings(); if(BuildConfig.UPDATER_ENABLED) @@ -82,6 +83,7 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP } connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview())); connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview())); + connect(ui->languageBox, SIGNAL(currentIndexChanged(int)), SLOT(languageIndexChanged(int))); } MultiMCPage::~MultiMCPage() @@ -190,6 +192,19 @@ void MultiMCPage::on_lwjglDirBrowseBtn_clicked() } } +void MultiMCPage::languageIndexChanged(int index) +{ + auto languageCode = ui->languageBox->itemData(ui->languageBox->currentIndex()).toString(); + if(languageCode.isEmpty()) + { + qWarning() << "Unknown language at index" << index; + return; + } + auto translations = MMC->translations(); + translations->selectLanguage(languageCode); + translations->updateLanguage(languageCode); +} + void MultiMCPage::refreshUpdateChannelList() { // Stop listening for selection changes. It's going to change a lot while we update it and @@ -363,29 +378,7 @@ void MultiMCPage::loadSettings() auto s = MMC->settings(); // Language { - using LanguageItem = std::pair<QString, QString>; - std::vector<LanguageItem> items; - - QLocale english("en"); - items.push_back(std::make_pair(english.nativeLanguageName(), "en")); - for(QString lang: QDir("translations").entryList(QStringList() << "*.qm", QDir::Files)) - { - lang.remove(".qm"); - lang.remove("mmc_"); - QLocale locale(lang); - QString fullLangName = locale.nativeLanguageName(); - qDebug() << fullLangName << lang; - items.push_back(std::make_pair(fullLangName, lang)); - } - std::sort(items.begin(), items.end(), [](const LanguageItem & a, const LanguageItem & b) - { - return a.first.localeAwareCompare(b.first) < 0; - }); - ui->languageBox->clear(); - for(auto & item: items) - { - ui->languageBox->addItem(item.first, item.second); - } + ui->languageBox->setModel(m_languageModel.get()); ui->languageBox->setCurrentIndex(ui->languageBox->findData(s->get("Language").toString())); } |