From e187597dec18e859544cbf399509ba3e9487ae3a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 28 Jul 2020 19:32:07 +1000 Subject: [PATCH] Qt: Make settings main help text translatable --- src/duckstation-qt/settingsdialog.cpp | 77 ++++++++++++++++----------- src/duckstation-qt/settingsdialog.h | 7 ++- 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/duckstation-qt/settingsdialog.cpp b/src/duckstation-qt/settingsdialog.cpp index fa749b867..9c131d279 100644 --- a/src/duckstation-qt/settingsdialog.cpp +++ b/src/duckstation-qt/settingsdialog.cpp @@ -13,39 +13,11 @@ static constexpr char DEFAULT_SETTING_HELP_TEXT[] = ""; -static constexpr std::array(SettingsDialog::Category::Count)> s_category_help_text = { - {"General Settings
These options control how the emulator looks and behaves.

Mouse over " - "an option for additional information.", - "Console Settings
These options determine the configuration of the simulated " - "console.

Mouse over an option for additional information.", - "Game List Settings
The list above shows the directories which will be searched by DuckStation " - "to populate the game list. Search directories can be added, removed, and switched to recursive/non-recursive. " - "Additionally, the redump.org database can be downloaded or updated to provide titles for discs, as the discs " - "themselves do not provide title information.", - "Hotkey Settings
Binding a hotkey allows you to trigger events such as a resetting or taking " - "screenshots at the press of a key/controller button. Hotkey titles are self-explanatory. Clicking a binding will " - "start a countdown, in which case you should press the key or controller button/axis you wish to bind. If no button " - "is pressed and the timer lapses, the binding will be unchanged. To clear a binding, right-click the button. To " - "bind multiple buttons, hold Shift and click the button.", - "Controller Settings
This page lets you choose the type of controller you wish to simulate for " - "the console, and rebind the keys or host game controller buttons to your choosing. Clicking a binding will start a " - "countdown, in which case you should press the key or controller button/axis you wish to bind. (For rumble, press " - "any button/axis on the controller you wish to send rumble to.) If no button is pressed and the timer lapses, " - "the binding will be unchanged. To clear a binding, right-click the button. To bind multiple buttons, hold Shift " - "and click the button.", - "Memory Card Settings
This page lets you control what mode the memory card emulation will " - "function in, and where the images for these cards will be stored on disk.", - "GPU Settings
These options control the simulation of the GPU in the console. Various " - "enhancements are available, mouse over each for additional information.", - "Audio Settings
These options control the audio output of the console. Mouse over an option for " - "additional information.", - "Advanced Settings
These options control logging and internal behavior of the emulator. Mouse " - "over an option for additional information."}}; - SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent /* = nullptr */) : QDialog(parent), m_host_interface(host_interface) { m_ui.setupUi(this); + setCategoryHelpTexts(); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -71,12 +43,53 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent m_ui.settingsCategory->setCurrentRow(0); m_ui.settingsContainer->setCurrentIndex(0); - m_ui.helpText->setText(tr(s_category_help_text[0])); + m_ui.helpText->setText(m_category_help_text[0]); connect(m_ui.settingsCategory, &QListWidget::currentRowChanged, this, &SettingsDialog::onCategoryCurrentRowChanged); } SettingsDialog::~SettingsDialog() = default; +void SettingsDialog::setCategoryHelpTexts() +{ + m_category_help_text[static_cast(Category::GeneralSettings)] = tr( + "General Settings
These options control how the emulator looks and behaves.

Mouse over " + "an option for additional information."); + m_category_help_text[static_cast(Category::ConsoleSettings)] = + tr("Console Settings
These options determine the configuration of the simulated " + "console.

Mouse over an option for additional information."); + m_category_help_text[static_cast(Category::GameListSettings)] = + tr("Game List Settings
The list above shows the directories which will be searched by " + "DuckStation " + "to populate the game list. Search directories can be added, removed, and switched to recursive/non-recursive. " + "Additionally, the redump.org database can be downloaded or updated to provide titles for discs, as the discs " + "themselves do not provide title information."); + m_category_help_text[static_cast(Category::HotkeySettings)] = tr( + "Hotkey Settings
Binding a hotkey allows you to trigger events such as a resetting or taking " + "screenshots at the press of a key/controller button. Hotkey titles are self-explanatory. Clicking a binding will " + "start a countdown, in which case you should press the key or controller button/axis you wish to bind. If no " + "button is pressed and the timer lapses, the binding will be unchanged. To clear a binding, right-click the " + "button. To bind multiple buttons, hold Shift and click the button."); + m_category_help_text[static_cast(Category::ControllerSettings)] = tr( + "Controller Settings
This page lets you choose the type of controller you wish to simulate for " + "the console, and rebind the keys or host game controller buttons to your choosing. Clicking a binding will start " + "a countdown, in which case you should press the key or controller button/axis you wish to bind. (For rumble, " + "press any button/axis on the controller you wish to send rumble to.) If no button is pressed and the timer " + "lapses, the binding will be unchanged. To clear a binding, right-click the button. To bind multiple buttons, hold " + "Shift and click the button."); + m_category_help_text[static_cast(Category::MemoryCardSettings)] = + tr("Memory Card Settings
This page lets you control what mode the memory card emulation will " + "function in, and where the images for these cards will be stored on disk."); + m_category_help_text[static_cast(Category::GPUSettings)] = + tr("GPU Settings
These options control the simulation of the GPU in the console. Various " + "enhancements are available, mouse over each for additional information."); + m_category_help_text[static_cast(Category::AudioSettings)] = + tr("Audio Settings
These options control the audio output of the console. Mouse over an option " + "for additional information."); + m_category_help_text[static_cast(Category::AdvancedSettings)] = tr( + "Advanced Settings
These options control logging and internal behavior of the emulator. Mouse " + "over an option for additional information."); +} + void SettingsDialog::setCategory(Category category) { if (category >= Category::Count) @@ -89,7 +102,7 @@ void SettingsDialog::onCategoryCurrentRowChanged(int row) { Q_ASSERT(row < static_cast(Category::Count)); m_ui.settingsContainer->setCurrentIndex(row); - m_ui.helpText->setText(tr(s_category_help_text[row])); + m_ui.helpText->setText(m_category_help_text[row]); } void SettingsDialog::registerWidgetHelp(QObject* object, const char* title, const char* recommended_value, @@ -126,7 +139,7 @@ bool SettingsDialog::eventFilter(QObject* object, QEvent* event) if (m_current_help_widget) { m_current_help_widget = nullptr; - m_ui.helpText->setText(tr(s_category_help_text[m_ui.settingsCategory->currentRow()])); + m_ui.helpText->setText(m_category_help_text[m_ui.settingsCategory->currentRow()]); } } diff --git a/src/duckstation-qt/settingsdialog.h b/src/duckstation-qt/settingsdialog.h index 4315e6b84..80ad0b16b 100644 --- a/src/duckstation-qt/settingsdialog.h +++ b/src/duckstation-qt/settingsdialog.h @@ -1,8 +1,9 @@ #pragma once - #include "ui_settingsdialog.h" #include +#include #include +#include class QtHostInterface; @@ -58,6 +59,8 @@ private Q_SLOTS: void onCategoryCurrentRowChanged(int row); private: + void setCategoryHelpTexts(); + Ui::SettingsDialog m_ui; QtHostInterface* m_host_interface; @@ -72,6 +75,8 @@ private: AudioSettingsWidget* m_audio_settings = nullptr; AdvancedSettingsWidget* m_advanced_settings = nullptr; + std::array(Category::Count)> m_category_help_text; + QObject* m_current_help_widget = nullptr; QMap m_widget_help_text_map; };