yuzu/configure_gamelist: Make combo box strings translatable
Given these are shown to the user, they should be translatable. While we're at it, also set up the dialog to automatically retranslate the dialog along with the combo boxes if it receives a LanguageChange event.
This commit is contained in:
parent
a9b953e6d4
commit
e89c22c147
|
@ -11,6 +11,23 @@
|
||||||
#include "yuzu/configuration/configure_gamelist.h"
|
#include "yuzu/configuration/configure_gamelist.h"
|
||||||
#include "yuzu/ui_settings.h"
|
#include "yuzu/ui_settings.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr std::array<std::pair<u32, const char*>, 5> default_icon_sizes{{
|
||||||
|
std::make_pair(0, QT_TR_NOOP("None")),
|
||||||
|
std::make_pair(32, QT_TR_NOOP("Small (32x32)")),
|
||||||
|
std::make_pair(64, QT_TR_NOOP("Standard (64x64)")),
|
||||||
|
std::make_pair(128, QT_TR_NOOP("Large (128x128)")),
|
||||||
|
std::make_pair(256, QT_TR_NOOP("Full Size (256x256)")),
|
||||||
|
}};
|
||||||
|
|
||||||
|
constexpr std::array<const char*, 4> row_text_names{{
|
||||||
|
QT_TR_NOOP("Filename"),
|
||||||
|
QT_TR_NOOP("Filetype"),
|
||||||
|
QT_TR_NOOP("Title ID"),
|
||||||
|
QT_TR_NOOP("Title Name"),
|
||||||
|
}};
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
ConfigureGameList::ConfigureGameList(QWidget* parent)
|
ConfigureGameList::ConfigureGameList(QWidget* parent)
|
||||||
: QWidget(parent), ui(new Ui::ConfigureGameList) {
|
: QWidget(parent), ui(new Ui::ConfigureGameList) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -41,33 +58,39 @@ void ConfigureGameList::setConfiguration() {
|
||||||
ui->row_2_text_combobox->findData(UISettings::values.row_2_text_id));
|
ui->row_2_text_combobox->findData(UISettings::values.row_2_text_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGameList::InitializeIconSizeComboBox() {
|
void ConfigureGameList::changeEvent(QEvent* event) {
|
||||||
static const std::array<std::pair<u32, std::string>, 5> default_icon_sizes{{
|
if (event->type() == QEvent::LanguageChange) {
|
||||||
std::make_pair(0, "None"), std::make_pair(32, "Small"),
|
RetranslateUI();
|
||||||
std::make_pair(64, "Standard"), std::make_pair(128, "Large"),
|
return;
|
||||||
std::make_pair(256, "Full Size"),
|
}
|
||||||
}};
|
|
||||||
|
|
||||||
|
QWidget::changeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureGameList::RetranslateUI() {
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
|
||||||
|
for (int i = 0; i < ui->icon_size_combobox->count(); i++) {
|
||||||
|
ui->icon_size_combobox->setItemText(i, tr(default_icon_sizes[i].second));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ui->row_1_text_combobox->count(); i++) {
|
||||||
|
const QString name = tr(row_text_names[i]);
|
||||||
|
|
||||||
|
ui->row_1_text_combobox->setItemText(i, name);
|
||||||
|
ui->row_2_text_combobox->setItemText(i, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureGameList::InitializeIconSizeComboBox() {
|
||||||
for (const auto& size : default_icon_sizes) {
|
for (const auto& size : default_icon_sizes) {
|
||||||
ui->icon_size_combobox->addItem(QString::fromStdString(size.second + " (" +
|
ui->icon_size_combobox->addItem(size.second, size.first);
|
||||||
std::to_string(size.first) + "x" +
|
|
||||||
std::to_string(size.first) + ")"),
|
|
||||||
size.first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGameList::InitializeRowComboBoxes() {
|
void ConfigureGameList::InitializeRowComboBoxes() {
|
||||||
static const std::array<std::string, 4> row_text_names{{
|
|
||||||
"Filename",
|
|
||||||
"Filetype",
|
|
||||||
"Title ID",
|
|
||||||
"Title Name",
|
|
||||||
}};
|
|
||||||
|
|
||||||
for (size_t i = 0; i < row_text_names.size(); ++i) {
|
for (size_t i = 0; i < row_text_names.size(); ++i) {
|
||||||
ui->row_1_text_combobox->addItem(QString::fromStdString(row_text_names[i]),
|
ui->row_1_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i));
|
||||||
QVariant::fromValue(i));
|
ui->row_2_text_combobox->addItem(row_text_names[i], QVariant::fromValue(i));
|
||||||
ui->row_2_text_combobox->addItem(QString::fromStdString(row_text_names[i]),
|
|
||||||
QVariant::fromValue(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ public:
|
||||||
private:
|
private:
|
||||||
void setConfiguration();
|
void setConfiguration();
|
||||||
|
|
||||||
|
void changeEvent(QEvent*) override;
|
||||||
|
void RetranslateUI();
|
||||||
|
|
||||||
void InitializeIconSizeComboBox();
|
void InitializeIconSizeComboBox();
|
||||||
void InitializeRowComboBoxes();
|
void InitializeRowComboBoxes();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue