From 88db89bf575a83e3a64967d11a478adfbaa7a623 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sat, 10 Aug 2019 03:00:56 -0400 Subject: [PATCH] configure_dialog: reverse tab map to avoid logic based on user-facing/translatable text (#4866) --- .../configuration/configure_dialog.cpp | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/citra_qt/configuration/configure_dialog.cpp b/src/citra_qt/configuration/configure_dialog.cpp index 46e09fbfb..e8815d760 100644 --- a/src/citra_qt/configuration/configure_dialog.cpp +++ b/src/citra_qt/configuration/configure_dialog.cpp @@ -68,19 +68,20 @@ void ConfigureDialog::ApplyConfiguration() { Settings::LogSettings(); } +Q_DECLARE_METATYPE(QList); + void ConfigureDialog::PopulateSelectionList() { ui->selectorList->clear(); - const std::array, 4> items{ - {{tr("General"), - {QT_TR_NOOP("General"), QT_TR_NOOP("Web"), QT_TR_NOOP("Debug"), QT_TR_NOOP("UI")}}, - {tr("System"), {QT_TR_NOOP("System"), QT_TR_NOOP("Audio"), QT_TR_NOOP("Camera")}}, - {tr("Graphics"), {QT_TR_NOOP("Graphics")}}, - {tr("Controls"), {QT_TR_NOOP("Input"), QT_TR_NOOP("Hotkeys")}}}}; + const std::array>, 4> items{ + {{tr("General"), {ui->generalTab, ui->webTab, ui->debugTab, ui->uiTab}}, + {tr("System"), {ui->systemTab, ui->audioTab, ui->cameraTab}}, + {tr("Graphics"), {ui->graphicsTab}}, + {tr("Controls"), {ui->inputTab, ui->hotkeysTab}}}}; for (const auto& entry : items) { auto* const item = new QListWidgetItem(entry.first); - item->setData(Qt::UserRole, entry.second); + item->setData(Qt::UserRole, QVariant::fromValue(entry.second)); ui->selectorList->addItem(item); } @@ -120,17 +121,17 @@ void ConfigureDialog::UpdateVisibleTabs() { if (items.isEmpty()) return; - const std::map widgets = { - {QStringLiteral("General"), ui->generalTab}, {QStringLiteral("System"), ui->systemTab}, - {QStringLiteral("Input"), ui->inputTab}, {QStringLiteral("Hotkeys"), ui->hotkeysTab}, - {QStringLiteral("Graphics"), ui->graphicsTab}, {QStringLiteral("Audio"), ui->audioTab}, - {QStringLiteral("Camera"), ui->cameraTab}, {QStringLiteral("Debug"), ui->debugTab}, - {QStringLiteral("Web"), ui->webTab}, {QStringLiteral("UI"), ui->uiTab}}; + const std::map widgets = { + {ui->generalTab, tr("General")}, {ui->systemTab, tr("System")}, + {ui->inputTab, tr("Input")}, {ui->hotkeysTab, tr("Hotkeys")}, + {ui->graphicsTab, tr("Graphics")}, {ui->audioTab, tr("Audio")}, + {ui->cameraTab, tr("Camera")}, {ui->debugTab, tr("Debug")}, + {ui->webTab, tr("Web")}, {ui->uiTab, tr("UI")}}; ui->tabWidget->clear(); - const QStringList tabs = items[0]->data(Qt::UserRole).toStringList(); + const QList tabs = qvariant_cast>(items[0]->data(Qt::UserRole)); - for (const auto& tab : tabs) - ui->tabWidget->addTab(widgets.at(tab), tr(qPrintable(tab))); + for (const auto tab : tabs) + ui->tabWidget->addTab(tab, widgets.at(tab)); }