diff options
| author | 2019-06-05 18:39:46 -0400 | |
|---|---|---|
| committer | 2019-06-05 21:57:21 -0400 | |
| commit | c09ff382a41cfc631efa9392bdb3143bd4c713a5 (patch) | |
| tree | a1755331546012b9c1e5711d78372bc4dda1bce7 /src | |
| parent | Merge pull request #2521 from lioncash/naming (diff) | |
| download | yuzu-c09ff382a41cfc631efa9392bdb3143bd4c713a5.tar.gz yuzu-c09ff382a41cfc631efa9392bdb3143bd4c713a5.tar.xz yuzu-c09ff382a41cfc631efa9392bdb3143bd4c713a5.zip | |
yuzu/configuration: Make all widgets and dialogs aware of language changes
To prepare for translation support, this makes all of the widgets
cognizant of the language change event that occurs whenever
installTranslator() is called and automatically retranslates their text
where necessary.
This is important as calling the backing UI's retranslateUi() is often
not enough, particularly in cases where we add our own strings that
aren't controlled by it. In that case we need to manually refresh the
strings ourselves.
Diffstat (limited to 'src')
31 files changed, 326 insertions, 58 deletions
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 110842eb2..f370c690f 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | 6 | ||
| 7 | #include <QSignalBlocker> | ||
| 8 | |||
| 7 | #include "audio_core/sink.h" | 9 | #include "audio_core/sink.h" |
| 8 | #include "audio_core/sink_details.h" | 10 | #include "audio_core/sink_details.h" |
| 9 | #include "core/core.h" | 11 | #include "core/core.h" |
| @@ -15,19 +17,15 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) | |||
| 15 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()) { | 17 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()) { |
| 16 | ui->setupUi(this); | 18 | ui->setupUi(this); |
| 17 | 19 | ||
| 18 | ui->output_sink_combo_box->clear(); | 20 | InitializeAudioOutputSinkComboBox(); |
| 19 | ui->output_sink_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name)); | ||
| 20 | for (const char* id : AudioCore::GetSinkIDs()) { | ||
| 21 | ui->output_sink_combo_box->addItem(QString::fromUtf8(id)); | ||
| 22 | } | ||
| 23 | 21 | ||
| 24 | connect(ui->volume_slider, &QSlider::valueChanged, this, | 22 | connect(ui->volume_slider, &QSlider::valueChanged, this, |
| 25 | &ConfigureAudio::SetVolumeIndicatorText); | 23 | &ConfigureAudio::SetVolumeIndicatorText); |
| 26 | |||
| 27 | SetConfiguration(); | ||
| 28 | connect(ui->output_sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this, | 24 | connect(ui->output_sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this, |
| 29 | &ConfigureAudio::UpdateAudioDevices); | 25 | &ConfigureAudio::UpdateAudioDevices); |
| 30 | 26 | ||
| 27 | SetConfiguration(); | ||
| 28 | |||
| 31 | const bool is_powered_on = Core::System::GetInstance().IsPoweredOn(); | 29 | const bool is_powered_on = Core::System::GetInstance().IsPoweredOn(); |
| 32 | ui->output_sink_combo_box->setEnabled(!is_powered_on); | 30 | ui->output_sink_combo_box->setEnabled(!is_powered_on); |
| 33 | ui->audio_device_combo_box->setEnabled(!is_powered_on); | 31 | ui->audio_device_combo_box->setEnabled(!is_powered_on); |
| @@ -49,8 +47,9 @@ void ConfigureAudio::SetConfiguration() { | |||
| 49 | } | 47 | } |
| 50 | 48 | ||
| 51 | void ConfigureAudio::SetOutputSinkFromSinkID() { | 49 | void ConfigureAudio::SetOutputSinkFromSinkID() { |
| 52 | int new_sink_index = 0; | 50 | [[maybe_unused]] const QSignalBlocker blocker(ui->output_sink_combo_box); |
| 53 | 51 | ||
| 52 | int new_sink_index = 0; | ||
| 54 | const QString sink_id = QString::fromStdString(Settings::values.sink_id); | 53 | const QString sink_id = QString::fromStdString(Settings::values.sink_id); |
| 55 | for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { | 54 | for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { |
| 56 | if (ui->output_sink_combo_box->itemText(index) == sink_id) { | 55 | if (ui->output_sink_combo_box->itemText(index) == sink_id) { |
| @@ -92,6 +91,14 @@ void ConfigureAudio::ApplyConfiguration() { | |||
| 92 | static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum(); | 91 | static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum(); |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 94 | void ConfigureAudio::changeEvent(QEvent* event) { | ||
| 95 | if (event->type() == QEvent::LanguageChange) { | ||
| 96 | RetranslateUI(); | ||
| 97 | } | ||
| 98 | |||
| 99 | QWidget::changeEvent(event); | ||
| 100 | } | ||
| 101 | |||
| 95 | void ConfigureAudio::UpdateAudioDevices(int sink_index) { | 102 | void ConfigureAudio::UpdateAudioDevices(int sink_index) { |
| 96 | ui->audio_device_combo_box->clear(); | 103 | ui->audio_device_combo_box->clear(); |
| 97 | ui->audio_device_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name)); | 104 | ui->audio_device_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name)); |
| @@ -102,6 +109,16 @@ void ConfigureAudio::UpdateAudioDevices(int sink_index) { | |||
| 102 | } | 109 | } |
| 103 | } | 110 | } |
| 104 | 111 | ||
| 112 | void ConfigureAudio::InitializeAudioOutputSinkComboBox() { | ||
| 113 | ui->output_sink_combo_box->clear(); | ||
| 114 | ui->output_sink_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name)); | ||
| 115 | |||
| 116 | for (const char* id : AudioCore::GetSinkIDs()) { | ||
| 117 | ui->output_sink_combo_box->addItem(QString::fromUtf8(id)); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 105 | void ConfigureAudio::RetranslateUI() { | 121 | void ConfigureAudio::RetranslateUI() { |
| 106 | ui->retranslateUi(this); | 122 | ui->retranslateUi(this); |
| 123 | SetVolumeIndicatorText(ui->volume_slider->sliderPosition()); | ||
| 107 | } | 124 | } |
diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h index 2bb92d9b5..ea83bd72d 100644 --- a/src/yuzu/configuration/configure_audio.h +++ b/src/yuzu/configuration/configure_audio.h | |||
| @@ -19,9 +19,14 @@ public: | |||
| 19 | ~ConfigureAudio() override; | 19 | ~ConfigureAudio() override; |
| 20 | 20 | ||
| 21 | void ApplyConfiguration(); | 21 | void ApplyConfiguration(); |
| 22 | void RetranslateUI(); | ||
| 23 | 22 | ||
| 24 | private: | 23 | private: |
| 24 | void changeEvent(QEvent* event) override; | ||
| 25 | |||
| 26 | void InitializeAudioOutputSinkComboBox(); | ||
| 27 | |||
| 28 | void RetranslateUI(); | ||
| 29 | |||
| 25 | void UpdateAudioDevices(int sink_index); | 30 | void UpdateAudioDevices(int sink_index); |
| 26 | 31 | ||
| 27 | void SetConfiguration(); | 32 | void SetConfiguration(); |
diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index afc2e3b38..efc2bedfd 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp | |||
| @@ -51,3 +51,15 @@ void ConfigureDebug::ApplyConfiguration() { | |||
| 51 | filter.ParseFilterString(Settings::values.log_filter); | 51 | filter.ParseFilterString(Settings::values.log_filter); |
| 52 | Log::SetGlobalFilter(filter); | 52 | Log::SetGlobalFilter(filter); |
| 53 | } | 53 | } |
| 54 | |||
| 55 | void ConfigureDebug::changeEvent(QEvent* event) { | ||
| 56 | if (event->type() == QEvent::LanguageChange) { | ||
| 57 | RetranslateUI(); | ||
| 58 | } | ||
| 59 | |||
| 60 | QWidget::changeEvent(event); | ||
| 61 | } | ||
| 62 | |||
| 63 | void ConfigureDebug::RetranslateUI() { | ||
| 64 | ui->retranslateUi(this); | ||
| 65 | } | ||
diff --git a/src/yuzu/configuration/configure_debug.h b/src/yuzu/configuration/configure_debug.h index 06b89026c..f4805a1d8 100644 --- a/src/yuzu/configuration/configure_debug.h +++ b/src/yuzu/configuration/configure_debug.h | |||
| @@ -21,6 +21,9 @@ public: | |||
| 21 | void ApplyConfiguration(); | 21 | void ApplyConfiguration(); |
| 22 | 22 | ||
| 23 | private: | 23 | private: |
| 24 | void changeEvent(QEvent* event) override; | ||
| 25 | |||
| 26 | void RetranslateUI(); | ||
| 24 | void SetConfiguration(); | 27 | void SetConfiguration(); |
| 25 | 28 | ||
| 26 | std::unique_ptr<Ui::ConfigureDebug> ui; | 29 | std::unique_ptr<Ui::ConfigureDebug> ui; |
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index a1b1e00bc..e636964e3 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <QHash> | 5 | #include <QHash> |
| 6 | #include <QListWidgetItem> | 6 | #include <QListWidgetItem> |
| 7 | #include <QSignalBlocker> | ||
| 7 | #include "core/settings.h" | 8 | #include "core/settings.h" |
| 8 | #include "ui_configure.h" | 9 | #include "ui_configure.h" |
| 9 | #include "yuzu/configuration/config.h" | 10 | #include "yuzu/configuration/config.h" |
| @@ -46,13 +47,38 @@ void ConfigureDialog::ApplyConfiguration() { | |||
| 46 | Settings::LogSettings(); | 47 | Settings::LogSettings(); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 50 | void ConfigureDialog::changeEvent(QEvent* event) { | ||
| 51 | if (event->type() == QEvent::LanguageChange) { | ||
| 52 | RetranslateUI(); | ||
| 53 | } | ||
| 54 | |||
| 55 | QDialog::changeEvent(event); | ||
| 56 | } | ||
| 57 | |||
| 58 | void ConfigureDialog::RetranslateUI() { | ||
| 59 | const int old_row = ui->selectorList->currentRow(); | ||
| 60 | const int old_index = ui->tabWidget->currentIndex(); | ||
| 61 | |||
| 62 | ui->retranslateUi(this); | ||
| 63 | |||
| 64 | PopulateSelectionList(); | ||
| 65 | ui->selectorList->setCurrentRow(old_row); | ||
| 66 | |||
| 67 | UpdateVisibleTabs(); | ||
| 68 | ui->tabWidget->setCurrentIndex(old_index); | ||
| 69 | } | ||
| 70 | |||
| 49 | void ConfigureDialog::PopulateSelectionList() { | 71 | void ConfigureDialog::PopulateSelectionList() { |
| 50 | const std::array<std::pair<QString, QStringList>, 4> items{ | 72 | const std::array<std::pair<QString, QStringList>, 4> items{ |
| 51 | {{tr("General"), {tr("General"), tr("Web"), tr("Debug"), tr("Game List")}}, | 73 | {{tr("General"), {tr("General"), tr("Web"), tr("Debug"), tr("Game List")}}, |
| 52 | {tr("System"), {tr("System"), tr("Profiles"), tr("Audio")}}, | 74 | {tr("System"), {tr("System"), tr("Profiles"), tr("Audio")}}, |
| 53 | {tr("Graphics"), {tr("Graphics")}}, | 75 | {tr("Graphics"), {tr("Graphics")}}, |
| 54 | {tr("Controls"), {tr("Input"), tr("Hotkeys")}}}}; | 76 | {tr("Controls"), {tr("Input"), tr("Hotkeys")}}}, |
| 77 | }; | ||
| 55 | 78 | ||
| 79 | [[maybe_unused]] const QSignalBlocker blocker(ui->selectorList); | ||
| 80 | |||
| 81 | ui->selectorList->clear(); | ||
| 56 | for (const auto& entry : items) { | 82 | for (const auto& entry : items) { |
| 57 | auto* const item = new QListWidgetItem(entry.first); | 83 | auto* const item = new QListWidgetItem(entry.first); |
| 58 | item->setData(Qt::UserRole, entry.second); | 84 | item->setData(Qt::UserRole, entry.second); |
| @@ -63,24 +89,28 @@ void ConfigureDialog::PopulateSelectionList() { | |||
| 63 | 89 | ||
| 64 | void ConfigureDialog::UpdateVisibleTabs() { | 90 | void ConfigureDialog::UpdateVisibleTabs() { |
| 65 | const auto items = ui->selectorList->selectedItems(); | 91 | const auto items = ui->selectorList->selectedItems(); |
| 66 | if (items.isEmpty()) | 92 | if (items.isEmpty()) { |
| 67 | return; | 93 | return; |
| 94 | } | ||
| 68 | 95 | ||
| 69 | const std::map<QString, QWidget*> widgets = {{tr("General"), ui->generalTab}, | 96 | const std::map<QString, QWidget*> widgets = { |
| 70 | {tr("System"), ui->systemTab}, | 97 | {tr("General"), ui->generalTab}, |
| 71 | {tr("Profiles"), ui->profileManagerTab}, | 98 | {tr("System"), ui->systemTab}, |
| 72 | {tr("Input"), ui->inputTab}, | 99 | {tr("Profiles"), ui->profileManagerTab}, |
| 73 | {tr("Hotkeys"), ui->hotkeysTab}, | 100 | {tr("Input"), ui->inputTab}, |
| 74 | {tr("Graphics"), ui->graphicsTab}, | 101 | {tr("Hotkeys"), ui->hotkeysTab}, |
| 75 | {tr("Audio"), ui->audioTab}, | 102 | {tr("Graphics"), ui->graphicsTab}, |
| 76 | {tr("Debug"), ui->debugTab}, | 103 | {tr("Audio"), ui->audioTab}, |
| 77 | {tr("Web"), ui->webTab}, | 104 | {tr("Debug"), ui->debugTab}, |
| 78 | {tr("Game List"), ui->gameListTab}}; | 105 | {tr("Web"), ui->webTab}, |
| 106 | {tr("Game List"), ui->gameListTab}, | ||
| 107 | }; | ||
| 108 | |||
| 109 | [[maybe_unused]] const QSignalBlocker blocker(ui->tabWidget); | ||
| 79 | 110 | ||
| 80 | ui->tabWidget->clear(); | 111 | ui->tabWidget->clear(); |
| 81 | |||
| 82 | const QStringList tabs = items[0]->data(Qt::UserRole).toStringList(); | 112 | const QStringList tabs = items[0]->data(Qt::UserRole).toStringList(); |
| 83 | 113 | for (const auto& tab : tabs) { | |
| 84 | for (const auto& tab : tabs) | ||
| 85 | ui->tabWidget->addTab(widgets.find(tab)->second, tab); | 114 | ui->tabWidget->addTab(widgets.find(tab)->second, tab); |
| 115 | } | ||
| 86 | } | 116 | } |
diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index 7e7d90f59..2d3bfc2da 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h | |||
| @@ -23,6 +23,10 @@ public: | |||
| 23 | void ApplyConfiguration(); | 23 | void ApplyConfiguration(); |
| 24 | 24 | ||
| 25 | private: | 25 | private: |
| 26 | void changeEvent(QEvent* event) override; | ||
| 27 | |||
| 28 | void RetranslateUI(); | ||
| 29 | |||
| 26 | void SetConfiguration(); | 30 | void SetConfiguration(); |
| 27 | void UpdateVisibleTabs(); | 31 | void UpdateVisibleTabs(); |
| 28 | void PopulateSelectionList(); | 32 | void PopulateSelectionList(); |
diff --git a/src/yuzu/configuration/configure_gamelist.cpp b/src/yuzu/configuration/configure_gamelist.cpp index 4b5b0ee48..d1724ba89 100644 --- a/src/yuzu/configuration/configure_gamelist.cpp +++ b/src/yuzu/configuration/configure_gamelist.cpp | |||
| @@ -77,7 +77,6 @@ void ConfigureGameList::SetConfiguration() { | |||
| 77 | void ConfigureGameList::changeEvent(QEvent* event) { | 77 | void ConfigureGameList::changeEvent(QEvent* event) { |
| 78 | if (event->type() == QEvent::LanguageChange) { | 78 | if (event->type() == QEvent::LanguageChange) { |
| 79 | RetranslateUI(); | 79 | RetranslateUI(); |
| 80 | return; | ||
| 81 | } | 80 | } |
| 82 | 81 | ||
| 83 | QWidget::changeEvent(event); | 82 | QWidget::changeEvent(event); |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 8bdc1787a..06d368dfc 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -45,3 +45,15 @@ void ConfigureGeneral::ApplyConfiguration() { | |||
| 45 | 45 | ||
| 46 | Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); | 46 | Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); |
| 47 | } | 47 | } |
| 48 | |||
| 49 | void ConfigureGeneral::changeEvent(QEvent* event) { | ||
| 50 | if (event->type() == QEvent::LanguageChange) { | ||
| 51 | RetranslateUI(); | ||
| 52 | } | ||
| 53 | |||
| 54 | QWidget::changeEvent(event); | ||
| 55 | } | ||
| 56 | |||
| 57 | void ConfigureGeneral::RetranslateUI() { | ||
| 58 | ui->retranslateUi(this); | ||
| 59 | } | ||
diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index fd5fd2a91..ef05ce065 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h | |||
| @@ -23,6 +23,9 @@ public: | |||
| 23 | void ApplyConfiguration(); | 23 | void ApplyConfiguration(); |
| 24 | 24 | ||
| 25 | private: | 25 | private: |
| 26 | void changeEvent(QEvent* event) override; | ||
| 27 | void RetranslateUI(); | ||
| 28 | |||
| 26 | void SetConfiguration(); | 29 | void SetConfiguration(); |
| 27 | 30 | ||
| 28 | std::unique_ptr<Ui::ConfigureGeneral> ui; | 31 | std::unique_ptr<Ui::ConfigureGeneral> ui; |
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 02e91701a..45e87248c 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -104,6 +104,18 @@ void ConfigureGraphics::ApplyConfiguration() { | |||
| 104 | Settings::values.bg_blue = static_cast<float>(bg_color.blueF()); | 104 | Settings::values.bg_blue = static_cast<float>(bg_color.blueF()); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | void ConfigureGraphics::changeEvent(QEvent* event) { | ||
| 108 | if (event->type() == QEvent::LanguageChange) { | ||
| 109 | RetranslateUI(); | ||
| 110 | } | ||
| 111 | |||
| 112 | QWidget::changeEvent(event); | ||
| 113 | } | ||
| 114 | |||
| 115 | void ConfigureGraphics::RetranslateUI() { | ||
| 116 | ui->retranslateUi(this); | ||
| 117 | } | ||
| 118 | |||
| 107 | void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { | 119 | void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { |
| 108 | bg_color = color; | 120 | bg_color = color; |
| 109 | 121 | ||
diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 6b3c39705..fae28d98e 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h | |||
| @@ -21,6 +21,9 @@ public: | |||
| 21 | void ApplyConfiguration(); | 21 | void ApplyConfiguration(); |
| 22 | 22 | ||
| 23 | private: | 23 | private: |
| 24 | void changeEvent(QEvent* event) override; | ||
| 25 | void RetranslateUI(); | ||
| 26 | |||
| 24 | void SetConfiguration(); | 27 | void SetConfiguration(); |
| 25 | 28 | ||
| 26 | void UpdateBackgroundColorButton(QColor color); | 29 | void UpdateBackgroundColorButton(QColor color); |
diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index 04119e9d7..3ea0b8d67 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp | |||
| @@ -17,7 +17,6 @@ ConfigureHotkeys::ConfigureHotkeys(QWidget* parent) | |||
| 17 | 17 | ||
| 18 | model = new QStandardItemModel(this); | 18 | model = new QStandardItemModel(this); |
| 19 | model->setColumnCount(3); | 19 | model->setColumnCount(3); |
| 20 | model->setHorizontalHeaderLabels({tr("Action"), tr("Hotkey"), tr("Context")}); | ||
| 21 | 20 | ||
| 22 | connect(ui->hotkey_list, &QTreeView::doubleClicked, this, &ConfigureHotkeys::Configure); | 21 | connect(ui->hotkey_list, &QTreeView::doubleClicked, this, &ConfigureHotkeys::Configure); |
| 23 | ui->hotkey_list->setModel(model); | 22 | ui->hotkey_list->setModel(model); |
| @@ -27,6 +26,8 @@ ConfigureHotkeys::ConfigureHotkeys(QWidget* parent) | |||
| 27 | 26 | ||
| 28 | ui->hotkey_list->setColumnWidth(0, 200); | 27 | ui->hotkey_list->setColumnWidth(0, 200); |
| 29 | ui->hotkey_list->resizeColumnToContents(1); | 28 | ui->hotkey_list->resizeColumnToContents(1); |
| 29 | |||
| 30 | RetranslateUI(); | ||
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | ConfigureHotkeys::~ConfigureHotkeys() = default; | 33 | ConfigureHotkeys::~ConfigureHotkeys() = default; |
| @@ -49,6 +50,20 @@ void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) { | |||
| 49 | ui->hotkey_list->expandAll(); | 50 | ui->hotkey_list->expandAll(); |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 53 | void ConfigureHotkeys::changeEvent(QEvent* event) { | ||
| 54 | if (event->type() == QEvent::LanguageChange) { | ||
| 55 | RetranslateUI(); | ||
| 56 | } | ||
| 57 | |||
| 58 | QWidget::changeEvent(event); | ||
| 59 | } | ||
| 60 | |||
| 61 | void ConfigureHotkeys::RetranslateUI() { | ||
| 62 | ui->retranslateUi(this); | ||
| 63 | |||
| 64 | model->setHorizontalHeaderLabels({tr("Action"), tr("Hotkey"), tr("Context")}); | ||
| 65 | } | ||
| 66 | |||
| 52 | void ConfigureHotkeys::Configure(QModelIndex index) { | 67 | void ConfigureHotkeys::Configure(QModelIndex index) { |
| 53 | if (!index.parent().isValid()) { | 68 | if (!index.parent().isValid()) { |
| 54 | return; | 69 | return; |
| @@ -112,7 +127,3 @@ void ConfigureHotkeys::ApplyConfiguration(HotkeyRegistry& registry) { | |||
| 112 | 127 | ||
| 113 | registry.SaveHotkeys(); | 128 | registry.SaveHotkeys(); |
| 114 | } | 129 | } |
| 115 | |||
| 116 | void ConfigureHotkeys::RetranslateUI() { | ||
| 117 | ui->retranslateUi(this); | ||
| 118 | } | ||
diff --git a/src/yuzu/configuration/configure_hotkeys.h b/src/yuzu/configuration/configure_hotkeys.h index a1f4c7134..8f8c6173b 100644 --- a/src/yuzu/configuration/configure_hotkeys.h +++ b/src/yuzu/configuration/configure_hotkeys.h | |||
| @@ -22,7 +22,6 @@ public: | |||
| 22 | ~ConfigureHotkeys() override; | 22 | ~ConfigureHotkeys() override; |
| 23 | 23 | ||
| 24 | void ApplyConfiguration(HotkeyRegistry& registry); | 24 | void ApplyConfiguration(HotkeyRegistry& registry); |
| 25 | void RetranslateUI(); | ||
| 26 | 25 | ||
| 27 | /** | 26 | /** |
| 28 | * Populates the hotkey list widget using data from the provided registry. | 27 | * Populates the hotkey list widget using data from the provided registry. |
| @@ -32,6 +31,9 @@ public: | |||
| 32 | void Populate(const HotkeyRegistry& registry); | 31 | void Populate(const HotkeyRegistry& registry); |
| 33 | 32 | ||
| 34 | private: | 33 | private: |
| 34 | void changeEvent(QEvent* event) override; | ||
| 35 | void RetranslateUI(); | ||
| 36 | |||
| 35 | void Configure(QModelIndex index); | 37 | void Configure(QModelIndex index); |
| 36 | bool IsUsedKey(QKeySequence key_sequence) const; | 38 | bool IsUsedKey(QKeySequence key_sequence) const; |
| 37 | 39 | ||
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index fb1210bcb..4dd775aab 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | 7 | ||
| 8 | #include <QSignalBlocker> | ||
| 8 | #include <QTimer> | 9 | #include <QTimer> |
| 9 | 10 | ||
| 10 | #include "configuration/configure_touchscreen_advanced.h" | 11 | #include "configuration/configure_touchscreen_advanced.h" |
| @@ -74,11 +75,7 @@ ConfigureInput::ConfigureInput(QWidget* parent) | |||
| 74 | ui->player5_configure, ui->player6_configure, ui->player7_configure, ui->player8_configure, | 75 | ui->player5_configure, ui->player6_configure, ui->player7_configure, ui->player8_configure, |
| 75 | }; | 76 | }; |
| 76 | 77 | ||
| 77 | for (auto* controller_box : players_controller) { | 78 | RetranslateUI(); |
| 78 | controller_box->addItems({tr("None"), tr("Pro Controller"), tr("Dual Joycons"), | ||
| 79 | tr("Single Right Joycon"), tr("Single Left Joycon")}); | ||
| 80 | } | ||
| 81 | |||
| 82 | LoadConfiguration(); | 79 | LoadConfiguration(); |
| 83 | UpdateUIEnabled(); | 80 | UpdateUIEnabled(); |
| 84 | 81 | ||
| @@ -144,6 +141,31 @@ void ConfigureInput::ApplyConfiguration() { | |||
| 144 | Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); | 141 | Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); |
| 145 | } | 142 | } |
| 146 | 143 | ||
| 144 | void ConfigureInput::changeEvent(QEvent* event) { | ||
| 145 | if (event->type() == QEvent::LanguageChange) { | ||
| 146 | RetranslateUI(); | ||
| 147 | } | ||
| 148 | |||
| 149 | QDialog::changeEvent(event); | ||
| 150 | } | ||
| 151 | |||
| 152 | void ConfigureInput::RetranslateUI() { | ||
| 153 | ui->retranslateUi(this); | ||
| 154 | RetranslateControllerComboBoxes(); | ||
| 155 | } | ||
| 156 | |||
| 157 | void ConfigureInput::RetranslateControllerComboBoxes() { | ||
| 158 | for (auto* controller_box : players_controller) { | ||
| 159 | [[maybe_unused]] const QSignalBlocker blocker(controller_box); | ||
| 160 | |||
| 161 | controller_box->clear(); | ||
| 162 | controller_box->addItems({tr("None"), tr("Pro Controller"), tr("Dual Joycons"), | ||
| 163 | tr("Single Right Joycon"), tr("Single Left Joycon")}); | ||
| 164 | } | ||
| 165 | |||
| 166 | LoadPlayerControllerIndices(); | ||
| 167 | } | ||
| 168 | |||
| 147 | void ConfigureInput::UpdateUIEnabled() { | 169 | void ConfigureInput::UpdateUIEnabled() { |
| 148 | bool hit_disabled = false; | 170 | bool hit_disabled = false; |
| 149 | for (auto* player : players_controller) { | 171 | for (auto* player : players_controller) { |
| @@ -175,11 +197,7 @@ void ConfigureInput::LoadConfiguration() { | |||
| 175 | Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD), | 197 | Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD), |
| 176 | [](const auto& player) { return player.connected; }); | 198 | [](const auto& player) { return player.connected; }); |
| 177 | 199 | ||
| 178 | for (std::size_t i = 0; i < players_controller.size(); ++i) { | 200 | LoadPlayerControllerIndices(); |
| 179 | const auto connected = Settings::values.players[i].connected; | ||
| 180 | players_controller[i]->setCurrentIndex( | ||
| 181 | connected ? static_cast<u8>(Settings::values.players[i].type) + 1 : 0); | ||
| 182 | } | ||
| 183 | 201 | ||
| 184 | ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); | 202 | ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); |
| 185 | ui->handheld_connected->setChecked( | 203 | ui->handheld_connected->setChecked( |
| @@ -194,6 +212,14 @@ void ConfigureInput::LoadConfiguration() { | |||
| 194 | UpdateUIEnabled(); | 212 | UpdateUIEnabled(); |
| 195 | } | 213 | } |
| 196 | 214 | ||
| 215 | void ConfigureInput::LoadPlayerControllerIndices() { | ||
| 216 | for (std::size_t i = 0; i < players_controller.size(); ++i) { | ||
| 217 | const auto connected = Settings::values.players[i].connected; | ||
| 218 | players_controller[i]->setCurrentIndex( | ||
| 219 | connected ? static_cast<u8>(Settings::values.players[i].type) + 1 : 0); | ||
| 220 | } | ||
| 221 | } | ||
| 222 | |||
| 197 | void ConfigureInput::RestoreDefaults() { | 223 | void ConfigureInput::RestoreDefaults() { |
| 198 | players_controller[0]->setCurrentIndex(2); | 224 | players_controller[0]->setCurrentIndex(2); |
| 199 | 225 | ||
diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h index 6a2125215..2f70cb3ca 100644 --- a/src/yuzu/configuration/configure_input.h +++ b/src/yuzu/configuration/configure_input.h | |||
| @@ -33,10 +33,16 @@ public: | |||
| 33 | void ApplyConfiguration(); | 33 | void ApplyConfiguration(); |
| 34 | 34 | ||
| 35 | private: | 35 | private: |
| 36 | void changeEvent(QEvent* event) override; | ||
| 37 | void RetranslateUI(); | ||
| 38 | void RetranslateControllerComboBoxes(); | ||
| 39 | |||
| 36 | void UpdateUIEnabled(); | 40 | void UpdateUIEnabled(); |
| 37 | 41 | ||
| 38 | /// Load configuration settings. | 42 | /// Load configuration settings. |
| 39 | void LoadConfiguration(); | 43 | void LoadConfiguration(); |
| 44 | void LoadPlayerControllerIndices(); | ||
| 45 | |||
| 40 | /// Restore all buttons to their default values. | 46 | /// Restore all buttons to their default values. |
| 41 | void RestoreDefaults(); | 47 | void RestoreDefaults(); |
| 42 | 48 | ||
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 32d2a6815..916baccc1 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -373,6 +373,19 @@ void ConfigureInputPlayer::ApplyConfiguration() { | |||
| 373 | Settings::values.players[player_index].button_color_right = colors[3]; | 373 | Settings::values.players[player_index].button_color_right = colors[3]; |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | void ConfigureInputPlayer::changeEvent(QEvent* event) { | ||
| 377 | if (event->type() == QEvent::LanguageChange) { | ||
| 378 | RetranslateUI(); | ||
| 379 | } | ||
| 380 | |||
| 381 | QDialog::changeEvent(event); | ||
| 382 | } | ||
| 383 | |||
| 384 | void ConfigureInputPlayer::RetranslateUI() { | ||
| 385 | ui->retranslateUi(this); | ||
| 386 | UpdateButtonLabels(); | ||
| 387 | } | ||
| 388 | |||
| 376 | void ConfigureInputPlayer::OnControllerButtonClick(int i) { | 389 | void ConfigureInputPlayer::OnControllerButtonClick(int i) { |
| 377 | const QColor new_bg_color = QColorDialog::getColor(controller_colors[i]); | 390 | const QColor new_bg_color = QColorDialog::getColor(controller_colors[i]); |
| 378 | if (!new_bg_color.isValid()) | 391 | if (!new_bg_color.isValid()) |
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 27924fcce..c66027651 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h | |||
| @@ -41,6 +41,9 @@ public: | |||
| 41 | void ApplyConfiguration(); | 41 | void ApplyConfiguration(); |
| 42 | 42 | ||
| 43 | private: | 43 | private: |
| 44 | void changeEvent(QEvent* event) override; | ||
| 45 | void RetranslateUI(); | ||
| 46 | |||
| 44 | void OnControllerButtonClick(int i); | 47 | void OnControllerButtonClick(int i); |
| 45 | 48 | ||
| 46 | /// Load configuration settings. | 49 | /// Load configuration settings. |
diff --git a/src/yuzu/configuration/configure_input_simple.cpp b/src/yuzu/configuration/configure_input_simple.cpp index 6140a5573..864803ea3 100644 --- a/src/yuzu/configuration/configure_input_simple.cpp +++ b/src/yuzu/configuration/configure_input_simple.cpp | |||
| @@ -119,6 +119,18 @@ void ConfigureInputSimple::ApplyConfiguration() { | |||
| 119 | UISettings::values.profile_index = index; | 119 | UISettings::values.profile_index = index; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | void ConfigureInputSimple::changeEvent(QEvent* event) { | ||
| 123 | if (event->type() == QEvent::LanguageChange) { | ||
| 124 | RetranslateUI(); | ||
| 125 | } | ||
| 126 | |||
| 127 | QWidget::changeEvent(event); | ||
| 128 | } | ||
| 129 | |||
| 130 | void ConfigureInputSimple::RetranslateUI() { | ||
| 131 | ui->retranslateUi(this); | ||
| 132 | } | ||
| 133 | |||
| 122 | void ConfigureInputSimple::LoadConfiguration() { | 134 | void ConfigureInputSimple::LoadConfiguration() { |
| 123 | const auto index = UISettings::values.profile_index; | 135 | const auto index = UISettings::values.profile_index; |
| 124 | if (index >= static_cast<int>(INPUT_PROFILES.size()) || index < 0) { | 136 | if (index >= static_cast<int>(INPUT_PROFILES.size()) || index < 0) { |
diff --git a/src/yuzu/configuration/configure_input_simple.h b/src/yuzu/configuration/configure_input_simple.h index 573c2db2b..bb5050224 100644 --- a/src/yuzu/configuration/configure_input_simple.h +++ b/src/yuzu/configuration/configure_input_simple.h | |||
| @@ -30,6 +30,9 @@ public: | |||
| 30 | void ApplyConfiguration(); | 30 | void ApplyConfiguration(); |
| 31 | 31 | ||
| 32 | private: | 32 | private: |
| 33 | void changeEvent(QEvent* event) override; | ||
| 34 | void RetranslateUI(); | ||
| 35 | |||
| 33 | /// Load configuration settings. | 36 | /// Load configuration settings. |
| 34 | void LoadConfiguration(); | 37 | void LoadConfiguration(); |
| 35 | 38 | ||
diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp index 26f53128f..b7305e653 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ b/src/yuzu/configuration/configure_mouse_advanced.cpp | |||
| @@ -140,6 +140,18 @@ void ConfigureMouseAdvanced::LoadConfiguration() { | |||
| 140 | UpdateButtonLabels(); | 140 | UpdateButtonLabels(); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | void ConfigureMouseAdvanced::changeEvent(QEvent* event) { | ||
| 144 | if (event->type() == QEvent::LanguageChange) { | ||
| 145 | RetranslateUI(); | ||
| 146 | } | ||
| 147 | |||
| 148 | QDialog::changeEvent(event); | ||
| 149 | } | ||
| 150 | |||
| 151 | void ConfigureMouseAdvanced::RetranslateUI() { | ||
| 152 | ui->retranslateUi(this); | ||
| 153 | } | ||
| 154 | |||
| 143 | void ConfigureMouseAdvanced::RestoreDefaults() { | 155 | void ConfigureMouseAdvanced::RestoreDefaults() { |
| 144 | for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { | 156 | for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { |
| 145 | buttons_param[button_id] = Common::ParamPackage{ | 157 | buttons_param[button_id] = Common::ParamPackage{ |
diff --git a/src/yuzu/configuration/configure_mouse_advanced.h b/src/yuzu/configuration/configure_mouse_advanced.h index 373f992c9..342b82412 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.h +++ b/src/yuzu/configuration/configure_mouse_advanced.h | |||
| @@ -28,6 +28,9 @@ public: | |||
| 28 | void ApplyConfiguration(); | 28 | void ApplyConfiguration(); |
| 29 | 29 | ||
| 30 | private: | 30 | private: |
| 31 | void changeEvent(QEvent* event) override; | ||
| 32 | void RetranslateUI(); | ||
| 33 | |||
| 31 | /// Load configuration settings. | 34 | /// Load configuration settings. |
| 32 | void LoadConfiguration(); | 35 | void LoadConfiguration(); |
| 33 | /// Restore all buttons to their default values. | 36 | /// Restore all buttons to their default values. |
diff --git a/src/yuzu/configuration/configure_per_general.cpp b/src/yuzu/configuration/configure_per_general.cpp index 275519c7b..90336e235 100644 --- a/src/yuzu/configuration/configure_per_general.cpp +++ b/src/yuzu/configuration/configure_per_general.cpp | |||
| @@ -92,6 +92,18 @@ void ConfigurePerGameGeneral::ApplyConfiguration() { | |||
| 92 | Settings::values.disabled_addons[title_id] = disabled_addons; | 92 | Settings::values.disabled_addons[title_id] = disabled_addons; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | void ConfigurePerGameGeneral::changeEvent(QEvent* event) { | ||
| 96 | if (event->type() == QEvent::LanguageChange) { | ||
| 97 | RetranslateUI(); | ||
| 98 | } | ||
| 99 | |||
| 100 | QDialog::changeEvent(event); | ||
| 101 | } | ||
| 102 | |||
| 103 | void ConfigurePerGameGeneral::RetranslateUI() { | ||
| 104 | ui->retranslateUi(this); | ||
| 105 | } | ||
| 106 | |||
| 95 | void ConfigurePerGameGeneral::LoadFromFile(FileSys::VirtualFile file) { | 107 | void ConfigurePerGameGeneral::LoadFromFile(FileSys::VirtualFile file) { |
| 96 | this->file = std::move(file); | 108 | this->file = std::move(file); |
| 97 | LoadConfiguration(); | 109 | LoadConfiguration(); |
diff --git a/src/yuzu/configuration/configure_per_general.h b/src/yuzu/configuration/configure_per_general.h index b95e07079..a3b2cdeff 100644 --- a/src/yuzu/configuration/configure_per_general.h +++ b/src/yuzu/configuration/configure_per_general.h | |||
| @@ -35,6 +35,9 @@ public: | |||
| 35 | void LoadFromFile(FileSys::VirtualFile file); | 35 | void LoadFromFile(FileSys::VirtualFile file); |
| 36 | 36 | ||
| 37 | private: | 37 | private: |
| 38 | void changeEvent(QEvent* event) override; | ||
| 39 | void RetranslateUI(); | ||
| 40 | |||
| 38 | void LoadConfiguration(); | 41 | void LoadConfiguration(); |
| 39 | 42 | ||
| 40 | std::unique_ptr<Ui::ConfigurePerGameGeneral> ui; | 43 | std::unique_ptr<Ui::ConfigurePerGameGeneral> ui; |
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 7c1597488..c90f4cdd8 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp | |||
| @@ -80,11 +80,10 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) | |||
| 80 | profile_manager(std::make_unique<Service::Account::ProfileManager>()) { | 80 | profile_manager(std::make_unique<Service::Account::ProfileManager>()) { |
| 81 | ui->setupUi(this); | 81 | ui->setupUi(this); |
| 82 | 82 | ||
| 83 | layout = new QVBoxLayout; | ||
| 84 | tree_view = new QTreeView; | 83 | tree_view = new QTreeView; |
| 85 | item_model = new QStandardItemModel(tree_view); | 84 | item_model = new QStandardItemModel(tree_view); |
| 85 | item_model->insertColumns(0, 1); | ||
| 86 | tree_view->setModel(item_model); | 86 | tree_view->setModel(item_model); |
| 87 | |||
| 88 | tree_view->setAlternatingRowColors(true); | 87 | tree_view->setAlternatingRowColors(true); |
| 89 | tree_view->setSelectionMode(QHeaderView::SingleSelection); | 88 | tree_view->setSelectionMode(QHeaderView::SingleSelection); |
| 90 | tree_view->setSelectionBehavior(QHeaderView::SelectRows); | 89 | tree_view->setSelectionBehavior(QHeaderView::SelectRows); |
| @@ -96,13 +95,11 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) | |||
| 96 | tree_view->setIconSize({64, 64}); | 95 | tree_view->setIconSize({64, 64}); |
| 97 | tree_view->setContextMenuPolicy(Qt::NoContextMenu); | 96 | tree_view->setContextMenuPolicy(Qt::NoContextMenu); |
| 98 | 97 | ||
| 99 | item_model->insertColumns(0, 1); | ||
| 100 | item_model->setHeaderData(0, Qt::Horizontal, tr("Users")); | ||
| 101 | |||
| 102 | // We must register all custom types with the Qt Automoc system so that we are able to use it | 98 | // We must register all custom types with the Qt Automoc system so that we are able to use it |
| 103 | // with signals/slots. In this case, QList falls under the umbrells of custom types. | 99 | // with signals/slots. In this case, QList falls under the umbrells of custom types. |
| 104 | qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>"); | 100 | qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>"); |
| 105 | 101 | ||
| 102 | layout = new QVBoxLayout; | ||
| 106 | layout->setContentsMargins(0, 0, 0, 0); | 103 | layout->setContentsMargins(0, 0, 0, 0); |
| 107 | layout->setSpacing(0); | 104 | layout->setSpacing(0); |
| 108 | layout->addWidget(tree_view); | 105 | layout->addWidget(tree_view); |
| @@ -120,10 +117,24 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) | |||
| 120 | ui->current_user_icon->setScene(scene); | 117 | ui->current_user_icon->setScene(scene); |
| 121 | 118 | ||
| 122 | SetConfiguration(); | 119 | SetConfiguration(); |
| 120 | RetranslateUI(); | ||
| 123 | } | 121 | } |
| 124 | 122 | ||
| 125 | ConfigureProfileManager::~ConfigureProfileManager() = default; | 123 | ConfigureProfileManager::~ConfigureProfileManager() = default; |
| 126 | 124 | ||
| 125 | void ConfigureProfileManager::changeEvent(QEvent* event) { | ||
| 126 | if (event->type() == QEvent::LanguageChange) { | ||
| 127 | RetranslateUI(); | ||
| 128 | } | ||
| 129 | |||
| 130 | QWidget::changeEvent(event); | ||
| 131 | } | ||
| 132 | |||
| 133 | void ConfigureProfileManager::RetranslateUI() { | ||
| 134 | ui->retranslateUi(this); | ||
| 135 | item_model->setHeaderData(0, Qt::Horizontal, tr("Users")); | ||
| 136 | } | ||
| 137 | |||
| 127 | void ConfigureProfileManager::SetConfiguration() { | 138 | void ConfigureProfileManager::SetConfiguration() { |
| 128 | enabled = !Core::System::GetInstance().IsPoweredOn(); | 139 | enabled = !Core::System::GetInstance().IsPoweredOn(); |
| 129 | item_model->removeRows(0, item_model->rowCount()); | 140 | item_model->removeRows(0, item_model->rowCount()); |
diff --git a/src/yuzu/configuration/configure_profile_manager.h b/src/yuzu/configuration/configure_profile_manager.h index 4e9b4e8ea..0a9bca2a6 100644 --- a/src/yuzu/configuration/configure_profile_manager.h +++ b/src/yuzu/configuration/configure_profile_manager.h | |||
| @@ -33,6 +33,9 @@ public: | |||
| 33 | void ApplyConfiguration(); | 33 | void ApplyConfiguration(); |
| 34 | 34 | ||
| 35 | private: | 35 | private: |
| 36 | void changeEvent(QEvent* event) override; | ||
| 37 | void RetranslateUI(); | ||
| 38 | |||
| 36 | void SetConfiguration(); | 39 | void SetConfiguration(); |
| 37 | 40 | ||
| 38 | void PopulateUserList(); | 41 | void PopulateUserList(); |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 5f0ed2f61..e1b52f8d9 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -40,6 +40,18 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui:: | |||
| 40 | 40 | ||
| 41 | ConfigureSystem::~ConfigureSystem() = default; | 41 | ConfigureSystem::~ConfigureSystem() = default; |
| 42 | 42 | ||
| 43 | void ConfigureSystem::changeEvent(QEvent* event) { | ||
| 44 | if (event->type() == QEvent::LanguageChange) { | ||
| 45 | RetranslateUI(); | ||
| 46 | } | ||
| 47 | |||
| 48 | QWidget::changeEvent(event); | ||
| 49 | } | ||
| 50 | |||
| 51 | void ConfigureSystem::RetranslateUI() { | ||
| 52 | ui->retranslateUi(this); | ||
| 53 | } | ||
| 54 | |||
| 43 | void ConfigureSystem::SetConfiguration() { | 55 | void ConfigureSystem::SetConfiguration() { |
| 44 | enabled = !Core::System::GetInstance().IsPoweredOn(); | 56 | enabled = !Core::System::GetInstance().IsPoweredOn(); |
| 45 | 57 | ||
diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h index 4c0329d57..1eab3781d 100644 --- a/src/yuzu/configuration/configure_system.h +++ b/src/yuzu/configuration/configure_system.h | |||
| @@ -23,6 +23,9 @@ public: | |||
| 23 | void ApplyConfiguration(); | 23 | void ApplyConfiguration(); |
| 24 | 24 | ||
| 25 | private: | 25 | private: |
| 26 | void changeEvent(QEvent* event) override; | ||
| 27 | void RetranslateUI(); | ||
| 28 | |||
| 26 | void SetConfiguration(); | 29 | void SetConfiguration(); |
| 27 | 30 | ||
| 28 | void ReadSystemSettings(); | 31 | void ReadSystemSettings(); |
diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.cpp b/src/yuzu/configuration/configure_touchscreen_advanced.cpp index bad224239..8ced28c75 100644 --- a/src/yuzu/configuration/configure_touchscreen_advanced.cpp +++ b/src/yuzu/configuration/configure_touchscreen_advanced.cpp | |||
| @@ -20,6 +20,18 @@ ConfigureTouchscreenAdvanced::ConfigureTouchscreenAdvanced(QWidget* parent) | |||
| 20 | 20 | ||
| 21 | ConfigureTouchscreenAdvanced::~ConfigureTouchscreenAdvanced() = default; | 21 | ConfigureTouchscreenAdvanced::~ConfigureTouchscreenAdvanced() = default; |
| 22 | 22 | ||
| 23 | void ConfigureTouchscreenAdvanced::changeEvent(QEvent* event) { | ||
| 24 | if (event->type() == QEvent::LanguageChange) { | ||
| 25 | RetranslateUI(); | ||
| 26 | } | ||
| 27 | |||
| 28 | QDialog::changeEvent(event); | ||
| 29 | } | ||
| 30 | |||
| 31 | void ConfigureTouchscreenAdvanced::RetranslateUI() { | ||
| 32 | ui->retranslateUi(this); | ||
| 33 | } | ||
| 34 | |||
| 23 | void ConfigureTouchscreenAdvanced::ApplyConfiguration() { | 35 | void ConfigureTouchscreenAdvanced::ApplyConfiguration() { |
| 24 | Settings::values.touchscreen.finger = ui->finger_box->value(); | 36 | Settings::values.touchscreen.finger = ui->finger_box->value(); |
| 25 | Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value(); | 37 | Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value(); |
diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.h b/src/yuzu/configuration/configure_touchscreen_advanced.h index 94edd85b1..72061492c 100644 --- a/src/yuzu/configuration/configure_touchscreen_advanced.h +++ b/src/yuzu/configuration/configure_touchscreen_advanced.h | |||
| @@ -21,6 +21,9 @@ public: | |||
| 21 | void ApplyConfiguration(); | 21 | void ApplyConfiguration(); |
| 22 | 22 | ||
| 23 | private: | 23 | private: |
| 24 | void changeEvent(QEvent* event) override; | ||
| 25 | void RetranslateUI(); | ||
| 26 | |||
| 24 | /// Load configuration settings. | 27 | /// Load configuration settings. |
| 25 | void LoadConfiguration(); | 28 | void LoadConfiguration(); |
| 26 | /// Restore all buttons to their default values. | 29 | /// Restore all buttons to their default values. |
diff --git a/src/yuzu/configuration/configure_web.cpp b/src/yuzu/configuration/configure_web.cpp index 8cacb75f3..5a70ef168 100644 --- a/src/yuzu/configuration/configure_web.cpp +++ b/src/yuzu/configuration/configure_web.cpp | |||
| @@ -22,35 +22,55 @@ ConfigureWeb::ConfigureWeb(QWidget* parent) | |||
| 22 | #ifndef USE_DISCORD_PRESENCE | 22 | #ifndef USE_DISCORD_PRESENCE |
| 23 | ui->discord_group->setVisible(false); | 23 | ui->discord_group->setVisible(false); |
| 24 | #endif | 24 | #endif |
| 25 | |||
| 25 | SetConfiguration(); | 26 | SetConfiguration(); |
| 27 | RetranslateUI(); | ||
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | ConfigureWeb::~ConfigureWeb() = default; | 30 | ConfigureWeb::~ConfigureWeb() = default; |
| 29 | 31 | ||
| 30 | void ConfigureWeb::SetConfiguration() { | 32 | void ConfigureWeb::changeEvent(QEvent* event) { |
| 31 | ui->web_credentials_disclaimer->setWordWrap(true); | 33 | if (event->type() == QEvent::LanguageChange) { |
| 32 | ui->telemetry_learn_more->setOpenExternalLinks(true); | 34 | RetranslateUI(); |
| 35 | } | ||
| 36 | |||
| 37 | QWidget::changeEvent(event); | ||
| 38 | } | ||
| 39 | |||
| 40 | void ConfigureWeb::RetranslateUI() { | ||
| 41 | ui->retranslateUi(this); | ||
| 42 | |||
| 33 | ui->telemetry_learn_more->setText( | 43 | ui->telemetry_learn_more->setText( |
| 34 | tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'><span style=\"text-decoration: " | 44 | tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'><span style=\"text-decoration: " |
| 35 | "underline; color:#039be5;\">Learn more</span></a>")); | 45 | "underline; color:#039be5;\">Learn more</span></a>")); |
| 36 | 46 | ||
| 37 | ui->web_signup_link->setOpenExternalLinks(true); | ||
| 38 | ui->web_signup_link->setText( | 47 | ui->web_signup_link->setText( |
| 39 | tr("<a href='https://profile.yuzu-emu.org/'><span style=\"text-decoration: underline; " | 48 | tr("<a href='https://profile.yuzu-emu.org/'><span style=\"text-decoration: underline; " |
| 40 | "color:#039be5;\">Sign up</span></a>")); | 49 | "color:#039be5;\">Sign up</span></a>")); |
| 41 | ui->web_token_info_link->setOpenExternalLinks(true); | 50 | |
| 42 | ui->web_token_info_link->setText( | 51 | ui->web_token_info_link->setText( |
| 43 | tr("<a href='https://yuzu-emu.org/wiki/yuzu-web-service/'><span style=\"text-decoration: " | 52 | tr("<a href='https://yuzu-emu.org/wiki/yuzu-web-service/'><span style=\"text-decoration: " |
| 44 | "underline; color:#039be5;\">What is my token?</span></a>")); | 53 | "underline; color:#039be5;\">What is my token?</span></a>")); |
| 45 | 54 | ||
| 55 | ui->label_telemetry_id->setText( | ||
| 56 | tr("Telemetry ID: 0x%1").arg(QString::number(Core::GetTelemetryId(), 16).toUpper())); | ||
| 57 | } | ||
| 58 | |||
| 59 | void ConfigureWeb::SetConfiguration() { | ||
| 60 | ui->web_credentials_disclaimer->setWordWrap(true); | ||
| 61 | |||
| 62 | ui->telemetry_learn_more->setOpenExternalLinks(true); | ||
| 63 | ui->web_signup_link->setOpenExternalLinks(true); | ||
| 64 | ui->web_token_info_link->setOpenExternalLinks(true); | ||
| 65 | |||
| 46 | ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); | 66 | ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); |
| 47 | ui->edit_username->setText(QString::fromStdString(Settings::values.yuzu_username)); | 67 | ui->edit_username->setText(QString::fromStdString(Settings::values.yuzu_username)); |
| 48 | ui->edit_token->setText(QString::fromStdString(Settings::values.yuzu_token)); | 68 | ui->edit_token->setText(QString::fromStdString(Settings::values.yuzu_token)); |
| 69 | |||
| 49 | // Connect after setting the values, to avoid calling OnLoginChanged now | 70 | // Connect after setting the values, to avoid calling OnLoginChanged now |
| 50 | connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); | 71 | connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); |
| 51 | connect(ui->edit_username, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); | 72 | connect(ui->edit_username, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); |
| 52 | ui->label_telemetry_id->setText( | 73 | |
| 53 | tr("Telemetry ID: 0x%1").arg(QString::number(Core::GetTelemetryId(), 16).toUpper())); | ||
| 54 | user_verified = true; | 74 | user_verified = true; |
| 55 | 75 | ||
| 56 | ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence); | 76 | ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence); |
| @@ -120,7 +140,3 @@ void ConfigureWeb::OnLoginVerified() { | |||
| 120 | "correctly, and that your internet connection is working.")); | 140 | "correctly, and that your internet connection is working.")); |
| 121 | } | 141 | } |
| 122 | } | 142 | } |
| 123 | |||
| 124 | void ConfigureWeb::RetranslateUI() { | ||
| 125 | ui->retranslateUi(this); | ||
| 126 | } | ||
diff --git a/src/yuzu/configuration/configure_web.h b/src/yuzu/configuration/configure_web.h index 49bee171b..9054711ea 100644 --- a/src/yuzu/configuration/configure_web.h +++ b/src/yuzu/configuration/configure_web.h | |||
| @@ -20,9 +20,11 @@ public: | |||
| 20 | ~ConfigureWeb() override; | 20 | ~ConfigureWeb() override; |
| 21 | 21 | ||
| 22 | void ApplyConfiguration(); | 22 | void ApplyConfiguration(); |
| 23 | void RetranslateUI(); | ||
| 24 | 23 | ||
| 25 | private: | 24 | private: |
| 25 | void changeEvent(QEvent* event) override; | ||
| 26 | void RetranslateUI(); | ||
| 27 | |||
| 26 | void RefreshTelemetryID(); | 28 | void RefreshTelemetryID(); |
| 27 | void OnLoginChanged(); | 29 | void OnLoginChanged(); |
| 28 | void VerifyLogin(); | 30 | void VerifyLogin(); |