yuzu: make tabbed config work with translations
This commit is contained in:
@@ -24,17 +24,11 @@
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="selectorList">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="minimumWidth">
|
||||
<number>150</number>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
<property name="maximumWidth">
|
||||
<number>150</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -48,11 +42,6 @@
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureGameList" name="gameListTab">
|
||||
<attribute name="title">
|
||||
<string>Game List</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureSystem" name="systemTab">
|
||||
<attribute name="title">
|
||||
<string>System</string>
|
||||
@@ -93,54 +82,14 @@
|
||||
<string>Web</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureUi" name="uiTab">
|
||||
<attribute name="title">
|
||||
<string>UI</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="ConfigureGeneral" name="generalTab">
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureUi" name="uiTab">
|
||||
<attribute name="title">
|
||||
<string>UI</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureSystem" name="systemTab">
|
||||
<attribute name="title">
|
||||
<string>System</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureInputSimple" name="inputTab">
|
||||
<attribute name="title">
|
||||
<string>Input</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureGraphics" name="graphicsTab">
|
||||
<attribute name="title">
|
||||
<string>Graphics</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureAudio" name="audioTab">
|
||||
<attribute name="title">
|
||||
<string>Audio</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureDebug" name="debugTab">
|
||||
<attribute name="title">
|
||||
<string>Debug</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="ConfigureWeb" name="webTab">
|
||||
<attribute name="title">
|
||||
<string>Web</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
@@ -158,12 +107,6 @@
|
||||
<header>configuration/configure_general.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ConfigureUi</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>configuration/configure_ui.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ConfigureSystem</class>
|
||||
<extends>QWidget</extends>
|
||||
@@ -201,9 +144,9 @@
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ConfigureGameList</class>
|
||||
<class>ConfigureUi</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>configuration/configure_gamelist.h</header>
|
||||
<header>configuration/configure_ui.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
|
||||
@@ -17,7 +17,6 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry)
|
||||
ui->hotkeysTab->Populate(registry);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
SetConfiguration();
|
||||
PopulateSelectionList();
|
||||
|
||||
connect(ui->uiTab, &ConfigureUi::languageChanged, this, &ConfigureDialog::onLanguageChanged);
|
||||
@@ -57,11 +56,14 @@ void ConfigureDialog::ApplyConfiguration() {
|
||||
}
|
||||
|
||||
void ConfigureDialog::PopulateSelectionList() {
|
||||
ui->selectorList->clear();
|
||||
|
||||
const std::array<std::pair<QString, QStringList>, 4> items{
|
||||
{{tr("General"), {tr("General"), tr("Web"), tr("Debug"), tr("Game List")}},
|
||||
{tr("System"), {tr("System"), tr("Profiles"), tr("Audio")}},
|
||||
{tr("Graphics"), {tr("Graphics")}},
|
||||
{tr("Controls"), {tr("Input"), tr("Hotkeys")}}}};
|
||||
{{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("Profiles"), QT_TR_NOOP("Audio")}},
|
||||
{tr("Graphics"), {QT_TR_NOOP("Graphics")}},
|
||||
{tr("Controls"), {QT_TR_NOOP("Input"), QT_TR_NOOP("Hotkeys")}}}};
|
||||
|
||||
for (const auto& entry : items) {
|
||||
auto* const item = new QListWidgetItem(entry.first);
|
||||
@@ -76,23 +78,23 @@ void ConfigureDialog::UpdateVisibleTabs() {
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
const std::map<QString, QWidget*> widgets = {{tr("General"), ui->generalTab},
|
||||
{tr("System"), ui->systemTab},
|
||||
{tr("Profiles"), ui->profileManagerTab},
|
||||
{tr("Input"), ui->inputTab},
|
||||
{tr("Hotkeys"), ui->hotkeysTab},
|
||||
{tr("Graphics"), ui->graphicsTab},
|
||||
{tr("Audio"), ui->audioTab},
|
||||
{tr("Debug"), ui->debugTab},
|
||||
{tr("Web"), ui->webTab},
|
||||
{tr("Game List"), ui->gameListTab}};
|
||||
const std::map<QString, QWidget*> widgets = {{"General", ui->generalTab},
|
||||
{"System", ui->systemTab},
|
||||
{"Profiles", ui->profileManagerTab},
|
||||
{"Input", ui->inputTab},
|
||||
{"Hotkeys", ui->hotkeysTab},
|
||||
{"Graphics", ui->graphicsTab},
|
||||
{"Audio", ui->audioTab},
|
||||
{"Debug", ui->debugTab},
|
||||
{"Web", ui->webTab},
|
||||
{"UI", ui->uiTab}};
|
||||
|
||||
ui->tabWidget->clear();
|
||||
|
||||
const QStringList tabs = items[0]->data(Qt::UserRole).toStringList();
|
||||
|
||||
for (const auto& tab : tabs)
|
||||
ui->tabWidget->addTab(widgets.find(tab)->second, tab);
|
||||
ui->tabWidget->addTab(widgets.find(tab)->second, tr(qPrintable(tab)));
|
||||
}
|
||||
|
||||
void ConfigureDialog::onLanguageChanged(const QString& locale) {
|
||||
@@ -104,9 +106,12 @@ void ConfigureDialog::onLanguageChanged(const QString& locale) {
|
||||
}
|
||||
|
||||
void ConfigureDialog::retranslateUi() {
|
||||
int old_row = ui->selectorList->currentRow();
|
||||
int old_index = ui->tabWidget->currentIndex();
|
||||
ui->retranslateUi(this);
|
||||
PopulateSelectionList();
|
||||
// restore selection after repopulating
|
||||
ui->selectorList->setCurrentRow(old_row);
|
||||
ui->tabWidget->setCurrentIndex(old_index);
|
||||
|
||||
ui->generalTab->retranslateUi();
|
||||
|
||||
Reference in New Issue
Block a user