Merge pull request #2808 from FearlessTobi/port-4866
Port citra-emu/citra#4866: "configure_dialog: reverse tab map to avoid logic based on user-facing/translatable text"
This commit is contained in:
commit
aa8daaf22a
|
@ -68,12 +68,14 @@ void ConfigureDialog::RetranslateUI() {
|
||||||
ui->tabWidget->setCurrentIndex(old_index);
|
ui->tabWidget->setCurrentIndex(old_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QList<QWidget*>);
|
||||||
|
|
||||||
void ConfigureDialog::PopulateSelectionList() {
|
void ConfigureDialog::PopulateSelectionList() {
|
||||||
const std::array<std::pair<QString, QStringList>, 4> items{
|
const std::array<std::pair<QString, QList<QWidget*>>, 4> items{
|
||||||
{{tr("General"), {tr("General"), tr("Web"), tr("Debug"), tr("Game List")}},
|
{{tr("General"), {ui->generalTab, ui->webTab, ui->debugTab, ui->gameListTab}},
|
||||||
{tr("System"), {tr("System"), tr("Profiles"), tr("Audio")}},
|
{tr("System"), {ui->systemTab, ui->profileManagerTab, ui->audioTab}},
|
||||||
{tr("Graphics"), {tr("Graphics")}},
|
{tr("Graphics"), {ui->graphicsTab}},
|
||||||
{tr("Controls"), {tr("Input"), tr("Hotkeys")}}},
|
{tr("Controls"), {ui->inputTab, ui->hotkeysTab}}},
|
||||||
};
|
};
|
||||||
|
|
||||||
[[maybe_unused]] const QSignalBlocker blocker(ui->selectorList);
|
[[maybe_unused]] const QSignalBlocker blocker(ui->selectorList);
|
||||||
|
@ -81,7 +83,7 @@ void ConfigureDialog::PopulateSelectionList() {
|
||||||
ui->selectorList->clear();
|
ui->selectorList->clear();
|
||||||
for (const auto& entry : items) {
|
for (const auto& entry : items) {
|
||||||
auto* const item = new QListWidgetItem(entry.first);
|
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);
|
ui->selectorList->addItem(item);
|
||||||
}
|
}
|
||||||
|
@ -93,24 +95,26 @@ void ConfigureDialog::UpdateVisibleTabs() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<QString, QWidget*> widgets = {
|
const std::map<QWidget*, QString> widgets = {
|
||||||
{tr("General"), ui->generalTab},
|
{ui->generalTab, tr("General")},
|
||||||
{tr("System"), ui->systemTab},
|
{ui->systemTab, tr("System")},
|
||||||
{tr("Profiles"), ui->profileManagerTab},
|
{ui->profileManagerTab, tr("Profiles")},
|
||||||
{tr("Input"), ui->inputTab},
|
{ui->inputTab, tr("Input")},
|
||||||
{tr("Hotkeys"), ui->hotkeysTab},
|
{ui->hotkeysTab, tr("Hotkeys")},
|
||||||
{tr("Graphics"), ui->graphicsTab},
|
{ui->graphicsTab, tr("Graphics")},
|
||||||
{tr("Audio"), ui->audioTab},
|
{ui->audioTab, tr("Audio")},
|
||||||
{tr("Debug"), ui->debugTab},
|
{ui->debugTab, tr("Debug")},
|
||||||
{tr("Web"), ui->webTab},
|
{ui->webTab, tr("Web")},
|
||||||
{tr("Game List"), ui->gameListTab},
|
{ui->gameListTab, tr("Game List")},
|
||||||
};
|
};
|
||||||
|
|
||||||
[[maybe_unused]] const QSignalBlocker blocker(ui->tabWidget);
|
[[maybe_unused]] const QSignalBlocker blocker(ui->tabWidget);
|
||||||
|
|
||||||
ui->tabWidget->clear();
|
ui->tabWidget->clear();
|
||||||
const QStringList tabs = items[0]->data(Qt::UserRole).toStringList();
|
|
||||||
for (const auto& tab : tabs) {
|
const QList<QWidget*> tabs = qvariant_cast<QList<QWidget*>>(items[0]->data(Qt::UserRole));
|
||||||
ui->tabWidget->addTab(widgets.find(tab)->second, tab);
|
|
||||||
|
for (const auto tab : tabs) {
|
||||||
|
ui->tabWidget->addTab(tab, widgets.at(tab));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue