Qt: Add translation support and language setting

This commit is contained in:
Connor McLaughlin
2020-07-28 19:14:44 +10:00
parent bb56b169fc
commit 3edb255eca
4 changed files with 80 additions and 1 deletions

View File

@@ -463,6 +463,31 @@ void MainWindow::setupAdditionalUi()
});
}
updateDebugMenuGPURenderer();
const QString current_language(
QString::fromStdString(m_host_interface->GetStringSettingValue("Main", "Language", "")));
for (const std::pair<QString, QString>& it : m_host_interface->getAvailableLanguageList())
{
QAction* action = m_ui.menuSettingsLanguage->addAction(it.first);
action->setCheckable(true);
action->setChecked(it.second == current_language);
action->setData(it.second);
connect(action, &QAction::triggered, [this, action]() {
const QString new_language = action->data().toString();
m_host_interface->SetStringSettingValue("Main", "Language", new_language.toUtf8().constData());
QMessageBox::information(this, tr("DuckStation"),
tr("Language changed. Please restart the application to apply."));
for (QObject* obj : m_ui.menuSettingsLanguage->children())
{
QAction* other_action = qobject_cast<QAction*>(obj);
if (other_action)
{
QSignalBlocker blocker(other_action);
action->setChecked(other_action == action);
}
}
});
}
}
void MainWindow::updateEmulationActions(bool starting, bool running)