From 92bc65d88350dd6fe737d43e60c9a5c71a9303fb Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 7 Aug 2020 03:34:40 +1000 Subject: [PATCH] Qt: Turn language list into radio buttons --- src/duckstation-qt/mainwindow.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 510de9def..3bf5c69d7 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -467,26 +468,19 @@ void MainWindow::setupAdditionalUi() const QString current_language( QString::fromStdString(m_host_interface->GetStringSettingValue("Main", "Language", ""))); + QActionGroup* language_group = new QActionGroup(m_ui.menuSettingsLanguage); for (const std::pair& it : m_host_interface->getAvailableLanguageList()) { - QAction* action = m_ui.menuSettingsLanguage->addAction(it.first); + QAction* action = language_group->addAction(it.first); action->setCheckable(true); - action->setChecked(it.second == current_language); + action->setChecked(current_language == it.second); + m_ui.menuSettingsLanguage->addAction(action); 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(obj); - if (other_action) - { - QSignalBlocker blocker(other_action); - action->setChecked(other_action == action); - } - } }); } }