Qt: Add translation support and language setting
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user