From ed0e9e95930ae5f17e5d9e19d9f36a34cdfe9dec Mon Sep 17 00:00:00 2001 From: Kyle K <190571+Docteh@users.noreply.github.com> Date: Wed, 13 Apr 2022 13:29:59 -0700 Subject: [PATCH 1/2] ui: Fix Game Compatibility list translations Reported by GillianMC on Discord. Looks to be a small quirk in the QT API. setText(QObject::tr(status.text)); bringing up QObject breaks the link with the GameListItemCompat --- src/citra_qt/compatdb.ui | 2 +- src/citra_qt/game_list_p.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/citra_qt/compatdb.ui b/src/citra_qt/compatdb.ui index 2e00550f2..33519814c 100644 --- a/src/citra_qt/compatdb.ui +++ b/src/citra_qt/compatdb.ui @@ -86,7 +86,7 @@ - Great + Great diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index cde8445bc..26cbe081e 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -264,8 +264,8 @@ public: } const CompatStatus& status = iterator->second; setData(compatibility, CompatNumberRole); - setText(QObject::tr(status.text)); - setToolTip(QObject::tr(status.tooltip)); + setText(tr(status.text)); + setToolTip(tr(status.tooltip)); setData(CreateCirclePixmapFromColor(status.color), Qt::DecorationRole); } From 854fe203e86f96ed9fd98523b7046de6044279db Mon Sep 17 00:00:00 2001 From: Kyle Kienapfel Date: Sat, 20 Aug 2022 07:49:29 -0700 Subject: [PATCH 2/2] Qt: Retranslate GameList header and Filter line Didn't notice this until I was trying to change the default font to Comic Sans MS when language is set to English in yuzu. --- src/citra_qt/game_list.cpp | 38 +++++++++++++++++++++++++++++++------- src/citra_qt/game_list.h | 3 +++ src/citra_qt/game_list_p.h | 3 +++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index db7cb7370..daeded538 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -136,10 +136,8 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} { layout_filter = new QHBoxLayout; layout_filter->setContentsMargins(8, 8, 8, 8); label_filter = new QLabel; - label_filter->setText(tr("Filter:")); edit_filter = new QLineEdit; edit_filter->clear(); - edit_filter->setPlaceholderText(tr("Enter pattern to filter")); edit_filter->installEventFilter(key_release_eater); edit_filter->setClearButtonEnabled(true); connect(edit_filter, &QLineEdit::textChanged, parent, &GameList::OnTextChanged); @@ -159,6 +157,7 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} { layout_filter->addWidget(label_filter_result); layout_filter->addWidget(button_filter_close); setLayout(layout_filter); + RetranslateUI(); } /** @@ -306,11 +305,7 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} { tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }")); item_model->insertColumns(0, COLUMN_COUNT); - item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); - item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); - item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, tr("Region")); - item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); - item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); + RetranslateUI(); item_model->setSortRole(GameListItemPath::SortRole); connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::OnUpdateThemedIcons); @@ -667,6 +662,35 @@ void GameList::LoadCompatibilityList() { } } +void GameList::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void GameList::RetranslateUI() { + item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); + item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); + item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, tr("Region")); + item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); + item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); +} + +void GameListSearchField::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void GameListSearchField::RetranslateUI() { + label_filter->setText(tr("Filter:")); + edit_filter->setPlaceholderText(tr("Enter pattern to filter")); +} + QStandardItemModel* GameList::GetModel() const { return item_model; } diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index e76c0edee..bf20cc9b8 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h @@ -107,6 +107,9 @@ private: QString FindGameByProgramID(QStandardItem* current_item, u64 program_id, int role); + void changeEvent(QEvent*) override; + void RetranslateUI(); + GameListSearchField* search_field; GMainWindow* main_window = nullptr; QVBoxLayout* layout = nullptr; diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 26cbe081e..75f1b90fa 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -431,6 +431,9 @@ public: void setFocus(); private: + void changeEvent(QEvent*) override; + void RetranslateUI(); + class KeyReleaseEater : public QObject { public: explicit KeyReleaseEater(GameList* gamelist, QObject* parent = nullptr);