diff options
author | Lioncash <mathew1800@gmail.com> | 2019-06-05 18:39:46 -0400 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-06-05 21:57:21 -0400 |
commit | c09ff382a41cfc631efa9392bdb3143bd4c713a5 (patch) | |
tree | a1755331546012b9c1e5711d78372bc4dda1bce7 /src/yuzu/configuration/configure_web.cpp | |
parent | 8d7a012297ea884f0309ed2207eeb5e6c8d6a495 (diff) |
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/yuzu/configuration/configure_web.cpp')
-rw-r--r-- | src/yuzu/configuration/configure_web.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
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) #ifndef USE_DISCORD_PRESENCE ui->discord_group->setVisible(false); #endif + SetConfiguration(); + RetranslateUI(); } ConfigureWeb::~ConfigureWeb() = default; -void ConfigureWeb::SetConfiguration() { - ui->web_credentials_disclaimer->setWordWrap(true); - ui->telemetry_learn_more->setOpenExternalLinks(true); +void ConfigureWeb::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void ConfigureWeb::RetranslateUI() { + ui->retranslateUi(this); + ui->telemetry_learn_more->setText( tr("<a href='https://yuzu-emu.org/help/feature/telemetry/'><span style=\"text-decoration: " "underline; color:#039be5;\">Learn more</span></a>")); - ui->web_signup_link->setOpenExternalLinks(true); ui->web_signup_link->setText( tr("<a href='https://profile.yuzu-emu.org/'><span style=\"text-decoration: underline; " "color:#039be5;\">Sign up</span></a>")); - ui->web_token_info_link->setOpenExternalLinks(true); + ui->web_token_info_link->setText( tr("<a href='https://yuzu-emu.org/wiki/yuzu-web-service/'><span style=\"text-decoration: " "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->edit_username->setText(QString::fromStdString(Settings::values.yuzu_username)); ui->edit_token->setText(QString::fromStdString(Settings::values.yuzu_token)); + // Connect after setting the values, to avoid calling OnLoginChanged now connect(ui->edit_token, &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; ui->toggle_discordrpc->setChecked(UISettings::values.enable_discord_presence); @@ -120,7 +140,3 @@ void ConfigureWeb::OnLoginVerified() { "correctly, and that your internet connection is working.")); } } - -void ConfigureWeb::RetranslateUI() { - ui->retranslateUi(this); -} |