Fix UI internationalization translation issue.
This commit is contained in:
parent
12178c694a
commit
2889ce59d5
@ -45,7 +45,7 @@ private:
|
|||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
|
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
const ConfigurationShared::TranslationShared::ComboboxTranslationMap& combobox_translations;
|
||||||
std::vector<std::function<void(bool)>> apply_funcs{};
|
std::vector<std::function<void(bool)>> apply_funcs{};
|
||||||
|
|
||||||
QComboBox* accuracy_combobox;
|
QComboBox* accuracy_combobox;
|
||||||
|
@ -97,7 +97,7 @@ private:
|
|||||||
const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)> update_aspect_ratio;
|
const std::function<void(Settings::AspectRatio, Settings::ResolutionSetup)> update_aspect_ratio;
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
const ConfigurationShared::ComboboxTranslationMap& combobox_translations;
|
const ConfigurationShared::TranslationShared::ComboboxTranslationMap& combobox_translations;
|
||||||
const std::vector<std::pair<u32, QString>>& shader_mapping;
|
const std::vector<std::pair<u32, QString>>& shader_mapping;
|
||||||
|
|
||||||
QPushButton* api_restore_global_button;
|
QPushButton* api_restore_global_button;
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
#include "yuzu/uisettings.h"
|
#include "yuzu/uisettings.h"
|
||||||
|
|
||||||
namespace ConfigurationShared {
|
namespace ConfigurationShared {
|
||||||
|
std::unique_ptr<TranslationShared::TranslationMap> TranslationShared::InitializeTranslations(
|
||||||
std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
QWidget* parent) {
|
||||||
std::unique_ptr<TranslationMap> translations = std::make_unique<TranslationMap>();
|
std::unique_ptr<TranslationMap> translations = std::make_unique<TranslationMap>();
|
||||||
const auto& tr = [parent](const char* text) -> QString { return parent->tr(text); };
|
|
||||||
|
|
||||||
#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \
|
#define INSERT(SETTINGS, ID, NAME, TOOLTIP) \
|
||||||
translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{(NAME), (TOOLTIP)}})
|
translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{(NAME), (TOOLTIP)}})
|
||||||
@ -190,13 +189,10 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
|||||||
|
|
||||||
return translations;
|
return translations;
|
||||||
}
|
}
|
||||||
|
std::unique_ptr<TranslationShared::ComboboxTranslationMap> TranslationShared::ComboboxEnumeration(
|
||||||
std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
|
QWidget* parent) {
|
||||||
std::unique_ptr<ComboboxTranslationMap> translations =
|
std::unique_ptr<ComboboxTranslationMap> translations =
|
||||||
std::make_unique<ComboboxTranslationMap>();
|
std::make_unique<ComboboxTranslationMap>();
|
||||||
const auto& tr = [&](const char* text, const char* context = "") {
|
|
||||||
return parent->tr(text, context);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PAIR(ENUM, VALUE, TRANSLATION) {static_cast<u32>(Settings::ENUM::VALUE), (TRANSLATION)}
|
#define PAIR(ENUM, VALUE, TRANSLATION) {static_cast<u32>(Settings::ENUM::VALUE), (TRANSLATION)}
|
||||||
|
|
||||||
|
@ -9,19 +9,13 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <qobject.h>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace ConfigurationShared {
|
namespace ConfigurationShared {
|
||||||
using TranslationMap = std::map<u32, std::pair<QString, QString>>;
|
|
||||||
using ComboboxTranslations = std::vector<std::pair<u32, QString>>;
|
|
||||||
using ComboboxTranslationMap = std::map<u32, ComboboxTranslations>;
|
|
||||||
|
|
||||||
std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent);
|
|
||||||
|
|
||||||
std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent);
|
|
||||||
|
|
||||||
static const std::map<Settings::AntiAliasing, QString> anti_aliasing_texts_map = {
|
static const std::map<Settings::AntiAliasing, QString> anti_aliasing_texts_map = {
|
||||||
{Settings::AntiAliasing::None, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "None"))},
|
{Settings::AntiAliasing::None, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "None"))},
|
||||||
@ -66,3 +60,16 @@ static const std::map<Settings::ShaderBackend, QString> shader_backend_texts_map
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ConfigurationShared
|
} // namespace ConfigurationShared
|
||||||
|
namespace ConfigurationShared {
|
||||||
|
class TranslationShared : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
using TranslationMap = std::map<u32, std::pair<QString, QString>>;
|
||||||
|
using ComboboxTranslations = std::vector<std::pair<u32, QString>>;
|
||||||
|
using ComboboxTranslationMap = std::map<u32, ComboboxTranslations>;
|
||||||
|
static std::unique_ptr<TranslationShared::TranslationMap> InitializeTranslations(
|
||||||
|
QWidget* parent);
|
||||||
|
static std::unique_ptr<TranslationShared::ComboboxTranslationMap> ComboboxEnumeration(
|
||||||
|
QWidget* parent);
|
||||||
|
};
|
||||||
|
} // namespace ConfigurationShared
|
@ -132,7 +132,7 @@ QWidget* Widget::CreateCombobox(std::function<std::string()>& serializer,
|
|||||||
combobox = new QComboBox(this);
|
combobox = new QComboBox(this);
|
||||||
combobox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
combobox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
const ComboboxTranslations* enumeration{nullptr};
|
const TranslationShared::ComboboxTranslations* enumeration{nullptr};
|
||||||
if (combobox_enumerations.contains(type)) {
|
if (combobox_enumerations.contains(type)) {
|
||||||
enumeration = &combobox_enumerations.at(type);
|
enumeration = &combobox_enumerations.at(type);
|
||||||
for (const auto& [id, name] : *enumeration) {
|
for (const auto& [id, name] : *enumeration) {
|
||||||
@ -182,7 +182,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
|
|||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
group->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
group->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
const ComboboxTranslations* enumeration{nullptr};
|
const TranslationShared::ComboboxTranslations* enumeration{nullptr};
|
||||||
if (combobox_enumerations.contains(type)) {
|
if (combobox_enumerations.contains(type)) {
|
||||||
enumeration = &combobox_enumerations.at(type);
|
enumeration = &combobox_enumerations.at(type);
|
||||||
for (const auto& [id, name] : *enumeration) {
|
for (const auto& [id, name] : *enumeration) {
|
||||||
@ -710,8 +710,10 @@ bool Widget::Valid() const {
|
|||||||
|
|
||||||
Widget::~Widget() = default;
|
Widget::~Widget() = default;
|
||||||
|
|
||||||
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
|
Widget::Widget(Settings::BasicSetting* setting_,
|
||||||
const ComboboxTranslationMap& combobox_translations_, QWidget* parent_,
|
const TranslationShared::TranslationMap& translations_,
|
||||||
|
const TranslationShared::ComboboxTranslationMap& combobox_translations_,
|
||||||
|
QWidget* parent_,
|
||||||
bool runtime_lock_, std::vector<std::function<void(bool)>>& apply_funcs_,
|
bool runtime_lock_, std::vector<std::function<void(bool)>>& apply_funcs_,
|
||||||
RequestType request, bool managed, float multiplier,
|
RequestType request, bool managed, float multiplier,
|
||||||
Settings::BasicSetting* other_setting, const QString& suffix)
|
Settings::BasicSetting* other_setting, const QString& suffix)
|
||||||
@ -765,8 +767,9 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
|
|||||||
}
|
}
|
||||||
|
|
||||||
Builder::Builder(QWidget* parent_, bool runtime_lock_)
|
Builder::Builder(QWidget* parent_, bool runtime_lock_)
|
||||||
: translations{InitializeTranslations(parent_)},
|
: translations{TranslationShared::InitializeTranslations(parent_)},
|
||||||
combobox_translations{ComboboxEnumeration(parent_)}, parent{parent_}, runtime_lock{
|
combobox_translations{TranslationShared::ComboboxEnumeration(parent_)}, parent{parent_},
|
||||||
|
runtime_lock{
|
||||||
runtime_lock_} {}
|
runtime_lock_} {}
|
||||||
|
|
||||||
Builder::~Builder() = default;
|
Builder::~Builder() = default;
|
||||||
@ -795,7 +798,7 @@ Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
|||||||
return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, suffix);
|
return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ComboboxTranslationMap& Builder::ComboboxTranslations() const {
|
const TranslationShared::ComboboxTranslationMap& Builder::ComboboxTranslations() const {
|
||||||
return *combobox_translations;
|
return *combobox_translations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,10 @@ public:
|
|||||||
* @param other_setting Second setting to modify, to replace the label with a checkbox
|
* @param other_setting Second setting to modify, to replace the label with a checkbox
|
||||||
* @param suffix Set to specify formats for Slider feedback labels or SpinBox
|
* @param suffix Set to specify formats for Slider feedback labels or SpinBox
|
||||||
*/
|
*/
|
||||||
explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations,
|
explicit Widget(Settings::BasicSetting* setting,
|
||||||
const ComboboxTranslationMap& combobox_translations, QWidget* parent,
|
const TranslationShared::TranslationMap& translations,
|
||||||
|
const TranslationShared::ComboboxTranslationMap& combobox_translations,
|
||||||
|
QWidget* parent,
|
||||||
bool runtime_lock, std::vector<std::function<void(bool)>>& apply_funcs_,
|
bool runtime_lock, std::vector<std::function<void(bool)>>& apply_funcs_,
|
||||||
RequestType request = RequestType::Default, bool managed = true,
|
RequestType request = RequestType::Default, bool managed = true,
|
||||||
float multiplier = default_multiplier,
|
float multiplier = default_multiplier,
|
||||||
@ -138,8 +140,8 @@ private:
|
|||||||
const std::function<void()>& touch);
|
const std::function<void()>& touch);
|
||||||
|
|
||||||
QWidget* parent;
|
QWidget* parent;
|
||||||
const TranslationMap& translations;
|
const TranslationShared::TranslationMap& translations;
|
||||||
const ComboboxTranslationMap& combobox_enumerations;
|
const TranslationShared::ComboboxTranslationMap& combobox_enumerations;
|
||||||
Settings::BasicSetting& setting;
|
Settings::BasicSetting& setting;
|
||||||
std::vector<std::function<void(bool)>>& apply_funcs;
|
std::vector<std::function<void(bool)>>& apply_funcs;
|
||||||
|
|
||||||
@ -165,11 +167,11 @@ public:
|
|||||||
RequestType request = RequestType::Default,
|
RequestType request = RequestType::Default,
|
||||||
const QString& suffix = default_suffix) const;
|
const QString& suffix = default_suffix) const;
|
||||||
|
|
||||||
const ComboboxTranslationMap& ComboboxTranslations() const;
|
const TranslationShared::ComboboxTranslationMap& ComboboxTranslations() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<TranslationMap> translations;
|
std::unique_ptr<TranslationShared::TranslationMap> translations;
|
||||||
std::unique_ptr<ComboboxTranslationMap> combobox_translations;
|
std::unique_ptr<TranslationShared::ComboboxTranslationMap> combobox_translations;
|
||||||
|
|
||||||
QWidget* parent;
|
QWidget* parent;
|
||||||
const bool runtime_lock;
|
const bool runtime_lock;
|
||||||
|
Loading…
Reference in New Issue
Block a user