InterfacePane: Add BalloonTip to language combobox
This commit is contained in:
parent
266bbeefc8
commit
7d704ca9ca
|
@ -33,7 +33,7 @@ void ConfigChoice::Update(int choice)
|
||||||
|
|
||||||
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
||||||
const Config::Info<std::string>& setting)
|
const Config::Info<std::string>& setting)
|
||||||
: m_setting(setting)
|
: m_setting(setting), m_text_is_data(true)
|
||||||
{
|
{
|
||||||
for (const auto& op : options)
|
for (const auto& op : options)
|
||||||
addItem(QString::fromStdString(op));
|
addItem(QString::fromStdString(op));
|
||||||
|
@ -42,6 +42,17 @@ ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigStringChoice::ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
|
||||||
|
const Config::Info<std::string>& setting)
|
||||||
|
: m_setting(setting), m_text_is_data(false)
|
||||||
|
{
|
||||||
|
for (const auto& [option_text, option_data] : options)
|
||||||
|
addItem(option_text, option_data);
|
||||||
|
|
||||||
|
Connect();
|
||||||
|
Load();
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigStringChoice::Connect()
|
void ConfigStringChoice::Connect()
|
||||||
{
|
{
|
||||||
const auto on_config_changed = [this]() {
|
const auto on_config_changed = [this]() {
|
||||||
|
@ -57,12 +68,22 @@ void ConfigStringChoice::Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigStringChoice::Update(int index)
|
void ConfigStringChoice::Update(int index)
|
||||||
|
{
|
||||||
|
if (m_text_is_data)
|
||||||
{
|
{
|
||||||
Config::SetBaseOrCurrent(m_setting, itemText(index).toStdString());
|
Config::SetBaseOrCurrent(m_setting, itemText(index).toStdString());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Config::SetBaseOrCurrent(m_setting, itemData(index).toString().toStdString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigStringChoice::Load()
|
void ConfigStringChoice::Load()
|
||||||
{
|
{
|
||||||
|
const QString setting_value = QString::fromStdString(Config::Get(m_setting));
|
||||||
|
|
||||||
|
const int index = m_text_is_data ? findText(setting_value) : findData(setting_value);
|
||||||
const QSignalBlocker blocker(this);
|
const QSignalBlocker blocker(this);
|
||||||
setCurrentIndex(findText(QString::fromStdString(Config::Get(m_setting))));
|
setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
|
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
|
||||||
|
@ -28,6 +29,8 @@ class ConfigStringChoice : public ToolTipComboBox
|
||||||
public:
|
public:
|
||||||
ConfigStringChoice(const std::vector<std::string>& options,
|
ConfigStringChoice(const std::vector<std::string>& options,
|
||||||
const Config::Info<std::string>& setting);
|
const Config::Info<std::string>& setting);
|
||||||
|
ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
|
||||||
|
const Config::Info<std::string>& setting);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Connect();
|
void Connect();
|
||||||
|
@ -35,4 +38,5 @@ private:
|
||||||
void Load();
|
void Load();
|
||||||
|
|
||||||
Config::Info<std::string> m_setting;
|
Config::Info<std::string> m_setting;
|
||||||
|
bool m_text_is_data = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,48 +32,49 @@
|
||||||
|
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
|
|
||||||
static QComboBox* MakeLanguageComboBox()
|
static ConfigStringChoice* MakeLanguageComboBox()
|
||||||
{
|
{
|
||||||
static const struct
|
using QPair = std::pair<QString, QString>;
|
||||||
{
|
std::vector<QPair> languages = {
|
||||||
const QString name;
|
QPair{QObject::tr("<System Language>"), QString{}},
|
||||||
const char* id;
|
QPair{QStringLiteral(u"Bahasa Melayu"), QStringLiteral("ms")}, // Malay
|
||||||
} languages[] = {
|
QPair{QStringLiteral(u"Catal\u00E0"), QStringLiteral("ca")}, // Catalan
|
||||||
{QStringLiteral(u"Bahasa Melayu"), "ms"}, // Malay
|
QPair{QStringLiteral(u"\u010Ce\u0161tina"), QStringLiteral("cs")}, // Czech
|
||||||
{QStringLiteral(u"Catal\u00E0"), "ca"}, // Catalan
|
QPair{QStringLiteral(u"Dansk"), QStringLiteral("da")}, // Danish
|
||||||
{QStringLiteral(u"\u010Ce\u0161tina"), "cs"}, // Czech
|
QPair{QStringLiteral(u"Deutsch"), QStringLiteral("de")}, // German
|
||||||
{QStringLiteral(u"Dansk"), "da"}, // Danish
|
QPair{QStringLiteral(u"English"), QStringLiteral("en")}, // English
|
||||||
{QStringLiteral(u"Deutsch"), "de"}, // German
|
QPair{QStringLiteral(u"Espa\u00F1ol"), QStringLiteral("es")}, // Spanish
|
||||||
{QStringLiteral(u"English"), "en"}, // English
|
QPair{QStringLiteral(u"Fran\u00E7ais"), QStringLiteral("fr")}, // French
|
||||||
{QStringLiteral(u"Espa\u00F1ol"), "es"}, // Spanish
|
QPair{QStringLiteral(u"Hrvatski"), QStringLiteral("hr")}, // Croatian
|
||||||
{QStringLiteral(u"Fran\u00E7ais"), "fr"}, // French
|
QPair{QStringLiteral(u"Italiano"), QStringLiteral("it")}, // Italian
|
||||||
{QStringLiteral(u"Hrvatski"), "hr"}, // Croatian
|
QPair{QStringLiteral(u"Magyar"), QStringLiteral("hu")}, // Hungarian
|
||||||
{QStringLiteral(u"Italiano"), "it"}, // Italian
|
QPair{QStringLiteral(u"Nederlands"), QStringLiteral("nl")}, // Dutch
|
||||||
{QStringLiteral(u"Magyar"), "hu"}, // Hungarian
|
QPair{QStringLiteral(u"Norsk bokm\u00E5l"), QStringLiteral("nb")}, // Norwegian
|
||||||
{QStringLiteral(u"Nederlands"), "nl"}, // Dutch
|
QPair{QStringLiteral(u"Polski"), QStringLiteral("pl")}, // Polish
|
||||||
{QStringLiteral(u"Norsk bokm\u00E5l"), "nb"}, // Norwegian
|
QPair{QStringLiteral(u"Portugu\u00EAs"), QStringLiteral("pt")}, // Portuguese
|
||||||
{QStringLiteral(u"Polski"), "pl"}, // Polish
|
QPair{QStringLiteral(u"Portugu\u00EAs (Brasil)"),
|
||||||
{QStringLiteral(u"Portugu\u00EAs"), "pt"}, // Portuguese
|
QStringLiteral("pt_BR")}, // Portuguese (Brazil)
|
||||||
{QStringLiteral(u"Portugu\u00EAs (Brasil)"), "pt_BR"}, // Portuguese (Brazil)
|
QPair{QStringLiteral(u"Rom\u00E2n\u0103"), QStringLiteral("ro")}, // Romanian
|
||||||
{QStringLiteral(u"Rom\u00E2n\u0103"), "ro"}, // Romanian
|
QPair{QStringLiteral(u"Srpski"), QStringLiteral("sr")}, // Serbian
|
||||||
{QStringLiteral(u"Srpski"), "sr"}, // Serbian
|
QPair{QStringLiteral(u"Suomi"), QStringLiteral("fi")}, // Finnish
|
||||||
{QStringLiteral(u"Suomi"), "fi"}, // Finnish
|
QPair{QStringLiteral(u"Svenska"), QStringLiteral("sv")}, // Swedish
|
||||||
{QStringLiteral(u"Svenska"), "sv"}, // Swedish
|
QPair{QStringLiteral(u"T\u00FCrk\u00E7e"), QStringLiteral("tr")}, // Turkish
|
||||||
{QStringLiteral(u"T\u00FCrk\u00E7e"), "tr"}, // Turkish
|
QPair{QStringLiteral(u"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"),
|
||||||
{QStringLiteral(u"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"), "el"}, // Greek
|
QStringLiteral("el")}, // Greek
|
||||||
{QStringLiteral(u"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"), "ru"}, // Russian
|
QPair{QStringLiteral(u"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"),
|
||||||
{QStringLiteral(u"\u0627\u0644\u0639\u0631\u0628\u064A\u0629"), "ar"}, // Arabic
|
QStringLiteral("ru")}, // Russian
|
||||||
{QStringLiteral(u"\u0641\u0627\u0631\u0633\u06CC"), "fa"}, // Farsi
|
QPair{QStringLiteral(u"\u0627\u0644\u0639\u0631\u0628\u064A\u0629"),
|
||||||
{QStringLiteral(u"\uD55C\uAD6D\uC5B4"), "ko"}, // Korean
|
QStringLiteral("ar")}, // Arabic
|
||||||
{QStringLiteral(u"\u65E5\u672C\u8A9E"), "ja"}, // Japanese
|
QPair{QStringLiteral(u"\u0641\u0627\u0631\u0633\u06CC"), QStringLiteral("fa")}, // Farsi
|
||||||
{QStringLiteral(u"\u7B80\u4F53\u4E2D\u6587"), "zh_CN"}, // Simplified Chinese
|
QPair{QStringLiteral(u"\uD55C\uAD6D\uC5B4"), QStringLiteral("ko")}, // Korean
|
||||||
{QStringLiteral(u"\u7E41\u9AD4\u4E2D\u6587"), "zh_TW"}, // Traditional Chinese
|
QPair{QStringLiteral(u"\u65E5\u672C\u8A9E"), QStringLiteral("ja")}, // Japanese
|
||||||
|
QPair{QStringLiteral(u"\u7B80\u4F53\u4E2D\u6587"),
|
||||||
|
QStringLiteral("zh_CN")}, // Simplified Chinese
|
||||||
|
QPair{QStringLiteral(u"\u7E41\u9AD4\u4E2D\u6587"),
|
||||||
|
QStringLiteral("zh_TW")}, // Traditional Chinese
|
||||||
};
|
};
|
||||||
|
|
||||||
auto* combobox = new QComboBox();
|
auto* const combobox = new ConfigStringChoice(languages, Config::MAIN_INTERFACE_LANGUAGE);
|
||||||
combobox->addItem(QObject::tr("<System Language>"), QString{});
|
|
||||||
for (const auto& lang : languages)
|
|
||||||
combobox->addItem(lang.name, QString::fromLatin1(lang.id));
|
|
||||||
|
|
||||||
// The default, QComboBox::AdjustToContentsOnFirstShow, causes a noticeable pause when opening the
|
// The default, QComboBox::AdjustToContentsOnFirstShow, causes a noticeable pause when opening the
|
||||||
// SettingWindow for the first time. The culprit seems to be non-Latin graphemes in the above
|
// SettingWindow for the first time. The culprit seems to be non-Latin graphemes in the above
|
||||||
|
@ -233,7 +234,8 @@ void InterfacePane::ConnectLayout()
|
||||||
[this](int index) { Settings::Instance().TriggerThemeChanged(); });
|
[this](int index) { Settings::Instance().TriggerThemeChanged(); });
|
||||||
connect(m_combobox_userstyle, &QComboBox::currentIndexChanged, this,
|
connect(m_combobox_userstyle, &QComboBox::currentIndexChanged, this,
|
||||||
&InterfacePane::OnSaveConfig);
|
&InterfacePane::OnSaveConfig);
|
||||||
connect(m_combobox_language, &QComboBox::currentIndexChanged, this, &InterfacePane::OnSaveConfig);
|
connect(m_combobox_language, &QComboBox::currentIndexChanged, this,
|
||||||
|
[this]() { OnLanguageChanged(); });
|
||||||
connect(m_checkbox_top_window, &QCheckBox::toggled, &Settings::Instance(),
|
connect(m_checkbox_top_window, &QCheckBox::toggled, &Settings::Instance(),
|
||||||
&Settings::KeepWindowOnTopChanged);
|
&Settings::KeepWindowOnTopChanged);
|
||||||
connect(m_checkbox_confirm_on_stop, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig);
|
connect(m_checkbox_confirm_on_stop, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig);
|
||||||
|
@ -270,10 +272,6 @@ void InterfacePane::LoadConfig()
|
||||||
}
|
}
|
||||||
#endif // USE_RETRO_ACHIEVEMENTS
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
SignalBlocking(m_combobox_language)
|
|
||||||
->setCurrentIndex(m_combobox_language->findData(
|
|
||||||
QString::fromStdString(Config::Get(Config::MAIN_INTERFACE_LANGUAGE))));
|
|
||||||
|
|
||||||
const Settings::StyleType style_type = Settings::Instance().GetStyleType();
|
const Settings::StyleType style_type = Settings::Instance().GetStyleType();
|
||||||
const QString userstyle = Settings::Instance().GetUserStyleName();
|
const QString userstyle = Settings::Instance().GetUserStyleName();
|
||||||
const int index = style_type == Settings::StyleType::User ?
|
const int index = style_type == Settings::StyleType::User ?
|
||||||
|
@ -326,15 +324,6 @@ void InterfacePane::OnSaveConfig()
|
||||||
Config::SetBase(Config::MAIN_SHOW_ACTIVE_TITLE, m_checkbox_show_active_title->isChecked());
|
Config::SetBase(Config::MAIN_SHOW_ACTIVE_TITLE, m_checkbox_show_active_title->isChecked());
|
||||||
Config::SetBase(Config::MAIN_PAUSE_ON_FOCUS_LOST, m_checkbox_pause_on_focus_lost->isChecked());
|
Config::SetBase(Config::MAIN_PAUSE_ON_FOCUS_LOST, m_checkbox_pause_on_focus_lost->isChecked());
|
||||||
|
|
||||||
auto new_language = m_combobox_language->currentData().toString().toStdString();
|
|
||||||
if (new_language != Config::Get(Config::MAIN_INTERFACE_LANGUAGE))
|
|
||||||
{
|
|
||||||
Config::SetBase(Config::MAIN_INTERFACE_LANGUAGE, new_language);
|
|
||||||
ModalMessageBox::information(
|
|
||||||
this, tr("Restart Required"),
|
|
||||||
tr("You must restart Dolphin in order for the change to take effect."));
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool use_covers = m_checkbox_use_covers->isChecked();
|
const bool use_covers = m_checkbox_use_covers->isChecked();
|
||||||
|
|
||||||
if (use_covers != Config::Get(Config::MAIN_USE_GAME_COVERS))
|
if (use_covers != Config::Get(Config::MAIN_USE_GAME_COVERS))
|
||||||
|
@ -364,6 +353,13 @@ void InterfacePane::OnCursorVisibleAlways()
|
||||||
Settings::Instance().SetCursorVisibility(Config::ShowCursor::Constantly);
|
Settings::Instance().SetCursorVisibility(Config::ShowCursor::Constantly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterfacePane::OnLanguageChanged()
|
||||||
|
{
|
||||||
|
ModalMessageBox::information(
|
||||||
|
this, tr("Restart Required"),
|
||||||
|
tr("You must restart Dolphin in order for the change to take effect."));
|
||||||
|
}
|
||||||
|
|
||||||
void InterfacePane::AddDescriptions()
|
void InterfacePane::AddDescriptions()
|
||||||
{
|
{
|
||||||
static constexpr char TR_TITLE_DATABASE_DESCRIPTION[] = QT_TR_NOOP(
|
static constexpr char TR_TITLE_DATABASE_DESCRIPTION[] = QT_TR_NOOP(
|
||||||
|
@ -375,6 +371,10 @@ void InterfacePane::AddDescriptions()
|
||||||
static constexpr char TR_TOP_WINDOW_DESCRIPTION[] =
|
static constexpr char TR_TOP_WINDOW_DESCRIPTION[] =
|
||||||
QT_TR_NOOP("Forces the render window to stay on top of other windows and applications."
|
QT_TR_NOOP("Forces the render window to stay on top of other windows and applications."
|
||||||
"<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
|
"<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
|
||||||
|
static constexpr char TR_LANGUAGE_DESCRIPTION[] = QT_TR_NOOP(
|
||||||
|
"Sets the language displayed by Dolphin's User Interface."
|
||||||
|
"<br><br>Changes to this setting only take effect once Dolphin is restarted."
|
||||||
|
"<br><br><dolphin_emphasis>If unsure, select <System Language>.</dolphin_emphasis>");
|
||||||
|
|
||||||
m_checkbox_use_builtin_title_database->SetDescription(tr(TR_TITLE_DATABASE_DESCRIPTION));
|
m_checkbox_use_builtin_title_database->SetDescription(tr(TR_TITLE_DATABASE_DESCRIPTION));
|
||||||
|
|
||||||
|
@ -382,4 +382,7 @@ void InterfacePane::AddDescriptions()
|
||||||
m_combobox_theme->SetDescription(tr(TR_THEME_DESCRIPTION));
|
m_combobox_theme->SetDescription(tr(TR_THEME_DESCRIPTION));
|
||||||
|
|
||||||
m_checkbox_top_window->SetDescription(tr(TR_TOP_WINDOW_DESCRIPTION));
|
m_checkbox_top_window->SetDescription(tr(TR_TOP_WINDOW_DESCRIPTION));
|
||||||
|
|
||||||
|
m_combobox_language->SetTitle(tr("Language"));
|
||||||
|
m_combobox_language->SetDescription(tr(TR_LANGUAGE_DESCRIPTION));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,10 @@ private:
|
||||||
void OnCursorVisibleMovement();
|
void OnCursorVisibleMovement();
|
||||||
void OnCursorVisibleNever();
|
void OnCursorVisibleNever();
|
||||||
void OnCursorVisibleAlways();
|
void OnCursorVisibleAlways();
|
||||||
|
void OnLanguageChanged();
|
||||||
|
|
||||||
QVBoxLayout* m_main_layout;
|
QVBoxLayout* m_main_layout;
|
||||||
QComboBox* m_combobox_language;
|
ConfigStringChoice* m_combobox_language;
|
||||||
|
|
||||||
ConfigStringChoice* m_combobox_theme;
|
ConfigStringChoice* m_combobox_theme;
|
||||||
QComboBox* m_combobox_userstyle;
|
QComboBox* m_combobox_userstyle;
|
||||||
|
|
Loading…
Reference in New Issue