mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-17 03:15:39 +00:00
Qt: Fix autofire button selection in non-English UI
This commit is contained in:
parent
67f352339c
commit
bcd40dd860
|
@ -460,10 +460,10 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
||||||
QGridLayout* autofire_layout = new QGridLayout();
|
QGridLayout* autofire_layout = new QGridLayout();
|
||||||
autofire_layout->setContentsMargins(0, 0, 0, 0);
|
autofire_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
QStringList option_list;
|
QVector<QPair<QString, QVariant>> option_list;
|
||||||
option_list.push_back(QString());
|
option_list.push_back({});
|
||||||
for (const auto& [button_name, button_code] : buttons)
|
for (const auto& [button_name, button_code] : buttons)
|
||||||
option_list.push_back(qApp->translate(cname, button_name.c_str()));
|
option_list.push_back({qApp->translate(cname, button_name.c_str()), QString::fromStdString(button_name)});
|
||||||
|
|
||||||
for (u32 autofire_index = 0; autofire_index < QtHostInterface::NUM_CONTROLLER_AUTOFIRE_BUTTONS; autofire_index++)
|
for (u32 autofire_index = 0; autofire_index < QtHostInterface::NUM_CONTROLLER_AUTOFIRE_BUTTONS; autofire_index++)
|
||||||
{
|
{
|
||||||
|
@ -471,7 +471,8 @@ void ControllerSettingsWidget::createPortBindingSettingsUi(int index, PortSettin
|
||||||
autofire_layout->addWidget(new QLabel(tr("Auto Fire %1").arg(autofire_index + 1), collapsible), autofire_index,
|
autofire_layout->addWidget(new QLabel(tr("Auto Fire %1").arg(autofire_index + 1), collapsible), autofire_index,
|
||||||
0);
|
0);
|
||||||
QComboBox* button_cb = new QComboBox(collapsible);
|
QComboBox* button_cb = new QComboBox(collapsible);
|
||||||
button_cb->addItems(option_list);
|
for (const auto& it : option_list)
|
||||||
|
button_cb->addItem(it.first, it.second);
|
||||||
autofire_layout->addWidget(button_cb, autofire_index, 1);
|
autofire_layout->addWidget(button_cb, autofire_index, 1);
|
||||||
SettingWidgetBinder::BindWidgetToStringSetting(
|
SettingWidgetBinder::BindWidgetToStringSetting(
|
||||||
m_host_interface, button_cb, section_name,
|
m_host_interface, button_cb, section_name,
|
||||||
|
|
|
@ -71,8 +71,26 @@ struct SettingAccessor<QComboBox>
|
||||||
static float getFloatValue(const QComboBox* widget) { return static_cast<float>(widget->currentIndex()); }
|
static float getFloatValue(const QComboBox* widget) { return static_cast<float>(widget->currentIndex()); }
|
||||||
static void setFloatValue(QComboBox* widget, float value) { widget->setCurrentIndex(static_cast<int>(value)); }
|
static void setFloatValue(QComboBox* widget, float value) { widget->setCurrentIndex(static_cast<int>(value)); }
|
||||||
|
|
||||||
static QString getStringValue(const QComboBox* widget) { return widget->currentText(); }
|
static QString getStringValue(const QComboBox* widget)
|
||||||
static void setStringValue(QComboBox* widget, const QString& value) { widget->setCurrentText(value); }
|
{
|
||||||
|
const QVariant currentData(widget->currentData());
|
||||||
|
if (currentData.type() == QVariant::String)
|
||||||
|
return currentData.toString();
|
||||||
|
|
||||||
|
return widget->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setStringValue(QComboBox* widget, const QString& value)
|
||||||
|
{
|
||||||
|
const int index = widget->findData(value);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
widget->setCurrentIndex(index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget->setCurrentText(value);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
static void connectValueChanged(QComboBox* widget, F func)
|
static void connectValueChanged(QComboBox* widget, F func)
|
||||||
|
|
Loading…
Reference in a new issue