yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Merge pull request #2553 from lioncash/language

yuzu/configuration: Make all widgets and dialogs aware of language changes
This commit is contained in:
Zach Hilman 2019-06-07 21:46:08 -04:00 committed by GitHub
commit ac54f1a967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 326 additions and 58 deletions

View File

@ -4,6 +4,8 @@
#include <memory> #include <memory>
#include <QSignalBlocker>
#include "audio_core/sink.h" #include "audio_core/sink.h"
#include "audio_core/sink_details.h" #include "audio_core/sink_details.h"
#include "core/core.h" #include "core/core.h"
@ -15,19 +17,15 @@ ConfigureAudio::ConfigureAudio(QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()) { : QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()) {
ui->setupUi(this); ui->setupUi(this);
ui->output_sink_combo_box->clear(); InitializeAudioOutputSinkComboBox();
ui->output_sink_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name));
for (const char* id : AudioCore::GetSinkIDs()) {
ui->output_sink_combo_box->addItem(QString::fromUtf8(id));
}
connect(ui->volume_slider, &QSlider::valueChanged, this, connect(ui->volume_slider, &QSlider::valueChanged, this,
&ConfigureAudio::SetVolumeIndicatorText); &ConfigureAudio::SetVolumeIndicatorText);
SetConfiguration();
connect(ui->output_sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this, connect(ui->output_sink_combo_box, qOverload<int>(&QComboBox::currentIndexChanged), this,
&ConfigureAudio::UpdateAudioDevices); &ConfigureAudio::UpdateAudioDevices);
SetConfiguration();
const bool is_powered_on = Core::System::GetInstance().IsPoweredOn(); const bool is_powered_on = Core::System::GetInstance().IsPoweredOn();
ui->output_sink_combo_box->setEnabled(!is_powered_on); ui->output_sink_combo_box->setEnabled(!is_powered_on);
ui->audio_device_combo_box->setEnabled(!is_powered_on); ui->audio_device_combo_box->setEnabled(!is_powered_on);
@ -49,8 +47,9 @@ void ConfigureAudio::SetConfiguration() {
} }
void ConfigureAudio::SetOutputSinkFromSinkID() { void ConfigureAudio::SetOutputSinkFromSinkID() {
int new_sink_index = 0; [[maybe_unused]] const QSignalBlocker blocker(ui->output_sink_combo_box);
int new_sink_index = 0;
const QString sink_id = QString::fromStdString(Settings::values.sink_id); const QString sink_id = QString::fromStdString(Settings::values.sink_id);
for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { for (int index = 0; index < ui->output_sink_combo_box->count(); index++) {
if (ui->output_sink_combo_box->itemText(index) == sink_id) { if (ui->output_sink_combo_box->itemText(index) == sink_id) {
@ -92,6 +91,14 @@ void ConfigureAudio::ApplyConfiguration() {
static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum(); static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum();
} }
void ConfigureAudio::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureAudio::UpdateAudioDevices(int sink_index) { void ConfigureAudio::UpdateAudioDevices(int sink_index) {
ui->audio_device_combo_box->clear(); ui->audio_device_combo_box->clear();
ui->audio_device_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name)); ui->audio_device_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name));
@ -102,6 +109,16 @@ void ConfigureAudio::UpdateAudioDevices(int sink_index) {
} }
} }
void ConfigureAudio::InitializeAudioOutputSinkComboBox() {
ui->output_sink_combo_box->clear();
ui->output_sink_combo_box->addItem(QString::fromUtf8(AudioCore::auto_device_name));
for (const char* id : AudioCore::GetSinkIDs()) {
ui->output_sink_combo_box->addItem(QString::fromUtf8(id));
}
}
void ConfigureAudio::RetranslateUI() { void ConfigureAudio::RetranslateUI() {
ui->retranslateUi(this); ui->retranslateUi(this);
SetVolumeIndicatorText(ui->volume_slider->sliderPosition());
} }

View File

@ -19,9 +19,14 @@ public:
~ConfigureAudio() override; ~ConfigureAudio() override;
void ApplyConfiguration(); void ApplyConfiguration();
void RetranslateUI();
private: private:
void changeEvent(QEvent* event) override;
void InitializeAudioOutputSinkComboBox();
void RetranslateUI();
void UpdateAudioDevices(int sink_index); void UpdateAudioDevices(int sink_index);
void SetConfiguration(); void SetConfiguration();

View File

@ -51,3 +51,15 @@ void ConfigureDebug::ApplyConfiguration() {
filter.ParseFilterString(Settings::values.log_filter); filter.ParseFilterString(Settings::values.log_filter);
Log::SetGlobalFilter(filter); Log::SetGlobalFilter(filter);
} }
void ConfigureDebug::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureDebug::RetranslateUI() {
ui->retranslateUi(this);
}

View File

@ -21,6 +21,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
std::unique_ptr<Ui::ConfigureDebug> ui; std::unique_ptr<Ui::ConfigureDebug> ui;

View File

@ -4,6 +4,7 @@
#include <QHash> #include <QHash>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QSignalBlocker>
#include "core/settings.h" #include "core/settings.h"
#include "ui_configure.h" #include "ui_configure.h"
#include "yuzu/configuration/config.h" #include "yuzu/configuration/config.h"
@ -46,13 +47,38 @@ void ConfigureDialog::ApplyConfiguration() {
Settings::LogSettings(); Settings::LogSettings();
} }
void ConfigureDialog::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QDialog::changeEvent(event);
}
void ConfigureDialog::RetranslateUI() {
const int old_row = ui->selectorList->currentRow();
const int old_index = ui->tabWidget->currentIndex();
ui->retranslateUi(this);
PopulateSelectionList();
ui->selectorList->setCurrentRow(old_row);
UpdateVisibleTabs();
ui->tabWidget->setCurrentIndex(old_index);
}
void ConfigureDialog::PopulateSelectionList() { void ConfigureDialog::PopulateSelectionList() {
const std::array<std::pair<QString, QStringList>, 4> items{ const std::array<std::pair<QString, QStringList>, 4> items{
{{tr("General"), {tr("General"), tr("Web"), tr("Debug"), tr("Game List")}}, {{tr("General"), {tr("General"), tr("Web"), tr("Debug"), tr("Game List")}},
{tr("System"), {tr("System"), tr("Profiles"), tr("Audio")}}, {tr("System"), {tr("System"), tr("Profiles"), tr("Audio")}},
{tr("Graphics"), {tr("Graphics")}}, {tr("Graphics"), {tr("Graphics")}},
{tr("Controls"), {tr("Input"), tr("Hotkeys")}}}}; {tr("Controls"), {tr("Input"), tr("Hotkeys")}}},
};
[[maybe_unused]] const QSignalBlocker blocker(ui->selectorList);
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, entry.second);
@ -63,10 +89,12 @@ void ConfigureDialog::PopulateSelectionList() {
void ConfigureDialog::UpdateVisibleTabs() { void ConfigureDialog::UpdateVisibleTabs() {
const auto items = ui->selectorList->selectedItems(); const auto items = ui->selectorList->selectedItems();
if (items.isEmpty()) if (items.isEmpty()) {
return; return;
}
const std::map<QString, QWidget*> widgets = {{tr("General"), ui->generalTab}, const std::map<QString, QWidget*> widgets = {
{tr("General"), ui->generalTab},
{tr("System"), ui->systemTab}, {tr("System"), ui->systemTab},
{tr("Profiles"), ui->profileManagerTab}, {tr("Profiles"), ui->profileManagerTab},
{tr("Input"), ui->inputTab}, {tr("Input"), ui->inputTab},
@ -75,12 +103,14 @@ void ConfigureDialog::UpdateVisibleTabs() {
{tr("Audio"), ui->audioTab}, {tr("Audio"), ui->audioTab},
{tr("Debug"), ui->debugTab}, {tr("Debug"), ui->debugTab},
{tr("Web"), ui->webTab}, {tr("Web"), ui->webTab},
{tr("Game List"), ui->gameListTab}}; {tr("Game List"), ui->gameListTab},
};
[[maybe_unused]] const QSignalBlocker blocker(ui->tabWidget);
ui->tabWidget->clear(); ui->tabWidget->clear();
const QStringList tabs = items[0]->data(Qt::UserRole).toStringList(); const QStringList tabs = items[0]->data(Qt::UserRole).toStringList();
for (const auto& tab : tabs) {
for (const auto& tab : tabs)
ui->tabWidget->addTab(widgets.find(tab)->second, tab); ui->tabWidget->addTab(widgets.find(tab)->second, tab);
} }
}

View File

@ -23,6 +23,10 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
void UpdateVisibleTabs(); void UpdateVisibleTabs();
void PopulateSelectionList(); void PopulateSelectionList();

View File

@ -77,7 +77,6 @@ void ConfigureGameList::SetConfiguration() {
void ConfigureGameList::changeEvent(QEvent* event) { void ConfigureGameList::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) { if (event->type() == QEvent::LanguageChange) {
RetranslateUI(); RetranslateUI();
return;
} }
QWidget::changeEvent(event); QWidget::changeEvent(event);

View File

@ -45,3 +45,15 @@ void ConfigureGeneral::ApplyConfiguration() {
Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked();
} }
void ConfigureGeneral::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureGeneral::RetranslateUI() {
ui->retranslateUi(this);
}

View File

@ -23,6 +23,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
std::unique_ptr<Ui::ConfigureGeneral> ui; std::unique_ptr<Ui::ConfigureGeneral> ui;

View File

@ -101,6 +101,18 @@ void ConfigureGraphics::ApplyConfiguration() {
Settings::values.bg_blue = static_cast<float>(bg_color.blueF()); Settings::values.bg_blue = static_cast<float>(bg_color.blueF());
} }
void ConfigureGraphics::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureGraphics::RetranslateUI() {
ui->retranslateUi(this);
}
void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) {
bg_color = color; bg_color = color;

View File

@ -21,6 +21,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
void UpdateBackgroundColorButton(QColor color); void UpdateBackgroundColorButton(QColor color);

View File

@ -17,7 +17,6 @@ ConfigureHotkeys::ConfigureHotkeys(QWidget* parent)
model = new QStandardItemModel(this); model = new QStandardItemModel(this);
model->setColumnCount(3); model->setColumnCount(3);
model->setHorizontalHeaderLabels({tr("Action"), tr("Hotkey"), tr("Context")});
connect(ui->hotkey_list, &QTreeView::doubleClicked, this, &ConfigureHotkeys::Configure); connect(ui->hotkey_list, &QTreeView::doubleClicked, this, &ConfigureHotkeys::Configure);
ui->hotkey_list->setModel(model); ui->hotkey_list->setModel(model);
@ -27,6 +26,8 @@ ConfigureHotkeys::ConfigureHotkeys(QWidget* parent)
ui->hotkey_list->setColumnWidth(0, 200); ui->hotkey_list->setColumnWidth(0, 200);
ui->hotkey_list->resizeColumnToContents(1); ui->hotkey_list->resizeColumnToContents(1);
RetranslateUI();
} }
ConfigureHotkeys::~ConfigureHotkeys() = default; ConfigureHotkeys::~ConfigureHotkeys() = default;
@ -49,6 +50,20 @@ void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) {
ui->hotkey_list->expandAll(); ui->hotkey_list->expandAll();
} }
void ConfigureHotkeys::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureHotkeys::RetranslateUI() {
ui->retranslateUi(this);
model->setHorizontalHeaderLabels({tr("Action"), tr("Hotkey"), tr("Context")});
}
void ConfigureHotkeys::Configure(QModelIndex index) { void ConfigureHotkeys::Configure(QModelIndex index) {
if (!index.parent().isValid()) { if (!index.parent().isValid()) {
return; return;
@ -112,7 +127,3 @@ void ConfigureHotkeys::ApplyConfiguration(HotkeyRegistry& registry) {
registry.SaveHotkeys(); registry.SaveHotkeys();
} }
void ConfigureHotkeys::RetranslateUI() {
ui->retranslateUi(this);
}

View File

@ -22,7 +22,6 @@ public:
~ConfigureHotkeys() override; ~ConfigureHotkeys() override;
void ApplyConfiguration(HotkeyRegistry& registry); void ApplyConfiguration(HotkeyRegistry& registry);
void RetranslateUI();
/** /**
* Populates the hotkey list widget using data from the provided registry. * Populates the hotkey list widget using data from the provided registry.
@ -32,6 +31,9 @@ public:
void Populate(const HotkeyRegistry& registry); void Populate(const HotkeyRegistry& registry);
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void Configure(QModelIndex index); void Configure(QModelIndex index);
bool IsUsedKey(QKeySequence key_sequence) const; bool IsUsedKey(QKeySequence key_sequence) const;

View File

@ -5,6 +5,7 @@
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <QSignalBlocker>
#include <QTimer> #include <QTimer>
#include "configuration/configure_touchscreen_advanced.h" #include "configuration/configure_touchscreen_advanced.h"
@ -74,11 +75,7 @@ ConfigureInput::ConfigureInput(QWidget* parent)
ui->player5_configure, ui->player6_configure, ui->player7_configure, ui->player8_configure, ui->player5_configure, ui->player6_configure, ui->player7_configure, ui->player8_configure,
}; };
for (auto* controller_box : players_controller) { RetranslateUI();
controller_box->addItems({tr("None"), tr("Pro Controller"), tr("Dual Joycons"),
tr("Single Right Joycon"), tr("Single Left Joycon")});
}
LoadConfiguration(); LoadConfiguration();
UpdateUIEnabled(); UpdateUIEnabled();
@ -144,6 +141,31 @@ void ConfigureInput::ApplyConfiguration() {
Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked();
} }
void ConfigureInput::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QDialog::changeEvent(event);
}
void ConfigureInput::RetranslateUI() {
ui->retranslateUi(this);
RetranslateControllerComboBoxes();
}
void ConfigureInput::RetranslateControllerComboBoxes() {
for (auto* controller_box : players_controller) {
[[maybe_unused]] const QSignalBlocker blocker(controller_box);
controller_box->clear();
controller_box->addItems({tr("None"), tr("Pro Controller"), tr("Dual Joycons"),
tr("Single Right Joycon"), tr("Single Left Joycon")});
}
LoadPlayerControllerIndices();
}
void ConfigureInput::UpdateUIEnabled() { void ConfigureInput::UpdateUIEnabled() {
bool hit_disabled = false; bool hit_disabled = false;
for (auto* player : players_controller) { for (auto* player : players_controller) {
@ -175,11 +197,7 @@ void ConfigureInput::LoadConfiguration() {
Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD), Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD),
[](const auto& player) { return player.connected; }); [](const auto& player) { return player.connected; });
for (std::size_t i = 0; i < players_controller.size(); ++i) { LoadPlayerControllerIndices();
const auto connected = Settings::values.players[i].connected;
players_controller[i]->setCurrentIndex(
connected ? static_cast<u8>(Settings::values.players[i].type) + 1 : 0);
}
ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); ui->use_docked_mode->setChecked(Settings::values.use_docked_mode);
ui->handheld_connected->setChecked( ui->handheld_connected->setChecked(
@ -194,6 +212,14 @@ void ConfigureInput::LoadConfiguration() {
UpdateUIEnabled(); UpdateUIEnabled();
} }
void ConfigureInput::LoadPlayerControllerIndices() {
for (std::size_t i = 0; i < players_controller.size(); ++i) {
const auto connected = Settings::values.players[i].connected;
players_controller[i]->setCurrentIndex(
connected ? static_cast<u8>(Settings::values.players[i].type) + 1 : 0);
}
}
void ConfigureInput::RestoreDefaults() { void ConfigureInput::RestoreDefaults() {
players_controller[0]->setCurrentIndex(2); players_controller[0]->setCurrentIndex(2);

View File

@ -33,10 +33,16 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void RetranslateControllerComboBoxes();
void UpdateUIEnabled(); void UpdateUIEnabled();
/// Load configuration settings. /// Load configuration settings.
void LoadConfiguration(); void LoadConfiguration();
void LoadPlayerControllerIndices();
/// Restore all buttons to their default values. /// Restore all buttons to their default values.
void RestoreDefaults(); void RestoreDefaults();

View File

@ -373,6 +373,19 @@ void ConfigureInputPlayer::ApplyConfiguration() {
Settings::values.players[player_index].button_color_right = colors[3]; Settings::values.players[player_index].button_color_right = colors[3];
} }
void ConfigureInputPlayer::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QDialog::changeEvent(event);
}
void ConfigureInputPlayer::RetranslateUI() {
ui->retranslateUi(this);
UpdateButtonLabels();
}
void ConfigureInputPlayer::OnControllerButtonClick(int i) { void ConfigureInputPlayer::OnControllerButtonClick(int i) {
const QColor new_bg_color = QColorDialog::getColor(controller_colors[i]); const QColor new_bg_color = QColorDialog::getColor(controller_colors[i]);
if (!new_bg_color.isValid()) if (!new_bg_color.isValid())

View File

@ -41,6 +41,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void OnControllerButtonClick(int i); void OnControllerButtonClick(int i);
/// Load configuration settings. /// Load configuration settings.

View File

@ -119,6 +119,18 @@ void ConfigureInputSimple::ApplyConfiguration() {
UISettings::values.profile_index = index; UISettings::values.profile_index = index;
} }
void ConfigureInputSimple::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureInputSimple::RetranslateUI() {
ui->retranslateUi(this);
}
void ConfigureInputSimple::LoadConfiguration() { void ConfigureInputSimple::LoadConfiguration() {
const auto index = UISettings::values.profile_index; const auto index = UISettings::values.profile_index;
if (index >= static_cast<int>(INPUT_PROFILES.size()) || index < 0) { if (index >= static_cast<int>(INPUT_PROFILES.size()) || index < 0) {

View File

@ -30,6 +30,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
/// Load configuration settings. /// Load configuration settings.
void LoadConfiguration(); void LoadConfiguration();

View File

@ -140,6 +140,18 @@ void ConfigureMouseAdvanced::LoadConfiguration() {
UpdateButtonLabels(); UpdateButtonLabels();
} }
void ConfigureMouseAdvanced::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QDialog::changeEvent(event);
}
void ConfigureMouseAdvanced::RetranslateUI() {
ui->retranslateUi(this);
}
void ConfigureMouseAdvanced::RestoreDefaults() { void ConfigureMouseAdvanced::RestoreDefaults() {
for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) {
buttons_param[button_id] = Common::ParamPackage{ buttons_param[button_id] = Common::ParamPackage{

View File

@ -28,6 +28,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
/// Load configuration settings. /// Load configuration settings.
void LoadConfiguration(); void LoadConfiguration();
/// Restore all buttons to their default values. /// Restore all buttons to their default values.

View File

@ -92,6 +92,18 @@ void ConfigurePerGameGeneral::ApplyConfiguration() {
Settings::values.disabled_addons[title_id] = disabled_addons; Settings::values.disabled_addons[title_id] = disabled_addons;
} }
void ConfigurePerGameGeneral::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QDialog::changeEvent(event);
}
void ConfigurePerGameGeneral::RetranslateUI() {
ui->retranslateUi(this);
}
void ConfigurePerGameGeneral::LoadFromFile(FileSys::VirtualFile file) { void ConfigurePerGameGeneral::LoadFromFile(FileSys::VirtualFile file) {
this->file = std::move(file); this->file = std::move(file);
LoadConfiguration(); LoadConfiguration();

View File

@ -35,6 +35,9 @@ public:
void LoadFromFile(FileSys::VirtualFile file); void LoadFromFile(FileSys::VirtualFile file);
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void LoadConfiguration(); void LoadConfiguration();
std::unique_ptr<Ui::ConfigurePerGameGeneral> ui; std::unique_ptr<Ui::ConfigurePerGameGeneral> ui;

View File

@ -80,11 +80,10 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent)
profile_manager(std::make_unique<Service::Account::ProfileManager>()) { profile_manager(std::make_unique<Service::Account::ProfileManager>()) {
ui->setupUi(this); ui->setupUi(this);
layout = new QVBoxLayout;
tree_view = new QTreeView; tree_view = new QTreeView;
item_model = new QStandardItemModel(tree_view); item_model = new QStandardItemModel(tree_view);
item_model->insertColumns(0, 1);
tree_view->setModel(item_model); tree_view->setModel(item_model);
tree_view->setAlternatingRowColors(true); tree_view->setAlternatingRowColors(true);
tree_view->setSelectionMode(QHeaderView::SingleSelection); tree_view->setSelectionMode(QHeaderView::SingleSelection);
tree_view->setSelectionBehavior(QHeaderView::SelectRows); tree_view->setSelectionBehavior(QHeaderView::SelectRows);
@ -96,13 +95,11 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent)
tree_view->setIconSize({64, 64}); tree_view->setIconSize({64, 64});
tree_view->setContextMenuPolicy(Qt::NoContextMenu); tree_view->setContextMenuPolicy(Qt::NoContextMenu);
item_model->insertColumns(0, 1);
item_model->setHeaderData(0, Qt::Horizontal, tr("Users"));
// We must register all custom types with the Qt Automoc system so that we are able to use it // We must register all custom types with the Qt Automoc system so that we are able to use it
// with signals/slots. In this case, QList falls under the umbrells of custom types. // with signals/slots. In this case, QList falls under the umbrells of custom types.
qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>"); qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>");
layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(tree_view); layout->addWidget(tree_view);
@ -120,10 +117,24 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent)
ui->current_user_icon->setScene(scene); ui->current_user_icon->setScene(scene);
SetConfiguration(); SetConfiguration();
RetranslateUI();
} }
ConfigureProfileManager::~ConfigureProfileManager() = default; ConfigureProfileManager::~ConfigureProfileManager() = default;
void ConfigureProfileManager::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureProfileManager::RetranslateUI() {
ui->retranslateUi(this);
item_model->setHeaderData(0, Qt::Horizontal, tr("Users"));
}
void ConfigureProfileManager::SetConfiguration() { void ConfigureProfileManager::SetConfiguration() {
enabled = !Core::System::GetInstance().IsPoweredOn(); enabled = !Core::System::GetInstance().IsPoweredOn();
item_model->removeRows(0, item_model->rowCount()); item_model->removeRows(0, item_model->rowCount());

View File

@ -33,6 +33,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
void PopulateUserList(); void PopulateUserList();

View File

@ -40,6 +40,18 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::
ConfigureSystem::~ConfigureSystem() = default; ConfigureSystem::~ConfigureSystem() = default;
void ConfigureSystem::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureSystem::RetranslateUI() {
ui->retranslateUi(this);
}
void ConfigureSystem::SetConfiguration() { void ConfigureSystem::SetConfiguration() {
enabled = !Core::System::GetInstance().IsPoweredOn(); enabled = !Core::System::GetInstance().IsPoweredOn();

View File

@ -23,6 +23,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
void ReadSystemSettings(); void ReadSystemSettings();

View File

@ -20,6 +20,18 @@ ConfigureTouchscreenAdvanced::ConfigureTouchscreenAdvanced(QWidget* parent)
ConfigureTouchscreenAdvanced::~ConfigureTouchscreenAdvanced() = default; ConfigureTouchscreenAdvanced::~ConfigureTouchscreenAdvanced() = default;
void ConfigureTouchscreenAdvanced::changeEvent(QEvent* event) {
if (event->type() == QEvent::LanguageChange) {
RetranslateUI();
}
QDialog::changeEvent(event);
}
void ConfigureTouchscreenAdvanced::RetranslateUI() {
ui->retranslateUi(this);
}
void ConfigureTouchscreenAdvanced::ApplyConfiguration() { void ConfigureTouchscreenAdvanced::ApplyConfiguration() {
Settings::values.touchscreen.finger = ui->finger_box->value(); Settings::values.touchscreen.finger = ui->finger_box->value();
Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value(); Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value();

View File

@ -21,6 +21,9 @@ public:
void ApplyConfiguration(); void ApplyConfiguration();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
/// Load configuration settings. /// Load configuration settings.
void LoadConfiguration(); void LoadConfiguration();
/// Restore all buttons to their default values. /// Restore all buttons to their default values.

View File

@ -22,35 +22,55 @@ ConfigureWeb::ConfigureWeb(QWidget* parent)
#ifndef USE_DISCORD_PRESENCE #ifndef USE_DISCORD_PRESENCE
ui->discord_group->setVisible(false); ui->discord_group->setVisible(false);
#endif #endif
SetConfiguration(); SetConfiguration();
RetranslateUI();
} }
ConfigureWeb::~ConfigureWeb() = default; ConfigureWeb::~ConfigureWeb() = default;
void ConfigureWeb::SetConfiguration() { void ConfigureWeb::changeEvent(QEvent* event) {
ui->web_credentials_disclaimer->setWordWrap(true); if (event->type() == QEvent::LanguageChange) {
ui->telemetry_learn_more->setOpenExternalLinks(true); RetranslateUI();
}
QWidget::changeEvent(event);
}
void ConfigureWeb::RetranslateUI() {
ui->retranslateUi(this);
ui->telemetry_learn_more->setText( ui->telemetry_learn_more->setText(
tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'><span style=\"text-decoration: " tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'><span style=\"text-decoration: "
"underline; color:#039be5;\">Learn more</span></a>")); "underline; color:#039be5;\">Learn more</span></a>"));
ui->web_signup_link->setOpenExternalLinks(true);
ui->web_signup_link->setText( ui->web_signup_link->setText(
tr("<a href='https://profile.yuzu-emu.org/'><span style=\"text-decoration: underline; " tr("<a href='https://profile.yuzu-emu.org/'><span style=\"text-decoration: underline; "
"color:#039be5;\">Sign up</span></a>")); "color:#039be5;\">Sign up</span></a>"));
ui->web_token_info_link->setOpenExternalLinks(true);
ui->web_token_info_link->setText( ui->web_token_info_link->setText(
tr("<a href='https://yuzu-emu.org/wiki/yuzu-web-service/'><span style=\"text-decoration: " tr("<a href='https://yuzu-emu.org/wiki/yuzu-web-service/'><span style=\"text-decoration: "
"underline; color:#039be5;\">What is my token?</span></a>")); "underline; color:#039be5;\">What is my token?</span></a>"));
ui->label_telemetry_id->setText(
tr("Telemetry ID: 0x%1").arg(QString::number(Core::GetTelemetryId(), 16).toUpper()));
}
void ConfigureWeb::SetConfiguration() {
ui->web_credentials_disclaimer->setWordWrap(true);
ui->telemetry_learn_more->setOpenExternalLinks(true);
ui->web_signup_link->setOpenExternalLinks(true);
ui->web_token_info_link->setOpenExternalLinks(true);
ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry);
ui->edit_username->setText(QString::fromStdString(Settings::values.yuzu_username)); ui->edit_username->setText(QString::fromStdString(Settings::values.yuzu_username));
ui->edit_token->setText(QString::fromStdString(Settings::values.yuzu_token)); ui->edit_token->setText(QString::fromStdString(Settings::values.yuzu_token));
// Connect after setting the values, to avoid calling OnLoginChanged now // Connect after setting the values, to avoid calling OnLoginChanged now
connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); connect(ui->edit_token, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged);
connect(ui->edit_username, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged); connect(ui->edit_username, &QLineEdit::textChanged, this, &ConfigureWeb::OnLoginChanged);
ui->label_telemetry_id->setText(
tr("Telemetry ID: 0x%1").arg(QString::number(Core::GetTelemetryId(), 16).toUpper()));
user_verified = true; user_verified = true;
ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence); ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence);
@ -120,7 +140,3 @@ void ConfigureWeb::OnLoginVerified() {
"correctly, and that your internet connection is working.")); "correctly, and that your internet connection is working."));
} }
} }
void ConfigureWeb::RetranslateUI() {
ui->retranslateUi(this);
}

View File

@ -20,9 +20,11 @@ public:
~ConfigureWeb() override; ~ConfigureWeb() override;
void ApplyConfiguration(); void ApplyConfiguration();
void RetranslateUI();
private: private:
void changeEvent(QEvent* event) override;
void RetranslateUI();
void RefreshTelemetryID(); void RefreshTelemetryID();
void OnLoginChanged(); void OnLoginChanged();
void VerifyLogin(); void VerifyLogin();