mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
InterfacePane: Add BalloonTip to language combobox
This commit is contained in:

committed by
Admiral H. Curtiss

parent
266bbeefc8
commit
7d704ca9ca
@ -33,7 +33,7 @@ void ConfigChoice::Update(int choice)
|
||||
|
||||
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
||||
const Config::Info<std::string>& setting)
|
||||
: m_setting(setting)
|
||||
: m_setting(setting), m_text_is_data(true)
|
||||
{
|
||||
for (const auto& op : options)
|
||||
addItem(QString::fromStdString(op));
|
||||
@ -42,6 +42,17 @@ ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
||||
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()
|
||||
{
|
||||
const auto on_config_changed = [this]() {
|
||||
@ -58,11 +69,21 @@ void ConfigStringChoice::Connect()
|
||||
|
||||
void ConfigStringChoice::Update(int index)
|
||||
{
|
||||
Config::SetBaseOrCurrent(m_setting, itemText(index).toStdString());
|
||||
if (m_text_is_data)
|
||||
{
|
||||
Config::SetBaseOrCurrent(m_setting, itemText(index).toStdString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Config::SetBaseOrCurrent(m_setting, itemData(index).toString().toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
setCurrentIndex(findText(QString::fromStdString(Config::Get(m_setting))));
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
|
||||
@ -28,6 +29,8 @@ class ConfigStringChoice : public ToolTipComboBox
|
||||
public:
|
||||
ConfigStringChoice(const std::vector<std::string>& options,
|
||||
const Config::Info<std::string>& setting);
|
||||
ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
|
||||
const Config::Info<std::string>& setting);
|
||||
|
||||
private:
|
||||
void Connect();
|
||||
@ -35,4 +38,5 @@ private:
|
||||
void Load();
|
||||
|
||||
Config::Info<std::string> m_setting;
|
||||
bool m_text_is_data = false;
|
||||
};
|
||||
|
Reference in New Issue
Block a user