mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 23:11:25 +12:00
Qt: fix localization in change_microphone_type
Don't rely on localized text at all. Use the setting's index and formatted string instead
This commit is contained in:
parent
ec4e8eda04
commit
171367fe88
2 changed files with 66 additions and 50 deletions
|
@ -227,10 +227,10 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
|
||||||
{
|
{
|
||||||
const QStringList settings = GetSettingOptions(type);
|
const QStringList settings = GetSettingOptions(type);
|
||||||
|
|
||||||
for (const QString& setting : settings)
|
for (int i = 0; i < settings.count(); i++)
|
||||||
{
|
{
|
||||||
const QString localized_setting = GetLocalizedSetting(setting, type, combobox->count());
|
const QString localized_setting = GetLocalizedSetting(settings[i], type, combobox->count());
|
||||||
combobox->addItem(localized_setting, QVariant(setting));
|
combobox->addItem(localized_setting, QVariant({settings[i], i}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sorted)
|
if (sorted)
|
||||||
|
@ -240,7 +240,27 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string selected = GetSetting(type);
|
const std::string selected = GetSetting(type);
|
||||||
const int index = combobox->findData(qstr(selected));
|
const QString selected_q = qstr(selected);
|
||||||
|
int index = -1;
|
||||||
|
|
||||||
|
if (is_ranged)
|
||||||
|
{
|
||||||
|
index = combobox->findData(selected_q);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < combobox->count(); i++)
|
||||||
|
{
|
||||||
|
const QVariantList var_list = combobox->itemData(i).toList();
|
||||||
|
ASSERT(var_list.size() == 2 && var_list[0].canConvert<QString>());
|
||||||
|
|
||||||
|
if (selected_q == var_list[0].toString())
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
|
@ -255,8 +275,17 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(combobox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=, this](int index)
|
connect(combobox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=, this](int index)
|
||||||
|
{
|
||||||
|
if (is_ranged)
|
||||||
{
|
{
|
||||||
SetSetting(type, sstr(combobox->itemData(index)));
|
SetSetting(type, sstr(combobox->itemData(index)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QVariantList var_list = combobox->itemData(index).toList();
|
||||||
|
ASSERT(var_list.size() == 2 && var_list[0].canConvert<QString>());
|
||||||
|
SetSetting(type, sstr(var_list[0]));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -631,7 +631,9 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
||||||
|
|
||||||
auto enable_buffering = [this, enable_buffering_options](int index)
|
auto enable_buffering = [this, enable_buffering_options](int index)
|
||||||
{
|
{
|
||||||
const auto text = ui->audioOutBox->currentData().toString();
|
const QVariantList var_list = ui->audioOutBox->itemData(index).toList();
|
||||||
|
ASSERT(var_list.size() == 2 && var_list[0].canConvert<QString>());
|
||||||
|
const QString text = var_list[0].toString();
|
||||||
const bool enabled = text == "XAudio2" || text == "OpenAL" || text == "FAudio";
|
const bool enabled = text == "XAudio2" || text == "OpenAL" || text == "FAudio";
|
||||||
ui->enableBuffering->setEnabled(enabled);
|
ui->enableBuffering->setEnabled(enabled);
|
||||||
enable_buffering_options(enabled && ui->enableBuffering->isChecked());
|
enable_buffering_options(enabled && ui->enableBuffering->isChecked());
|
||||||
|
@ -639,54 +641,39 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
||||||
|
|
||||||
const QString mic_none = m_emu_settings->m_microphone_creator.get_none();
|
const QString mic_none = m_emu_settings->m_microphone_creator.get_none();
|
||||||
|
|
||||||
auto change_microphone_type = [=, this](QString text)
|
auto change_microphone_type = [mic_none, this](int index)
|
||||||
{
|
{
|
||||||
std::string s_standard, s_singstar, s_realsingstar, s_rocksmith;
|
if (index < 0)
|
||||||
|
|
||||||
auto enable_mics_combo = [=, this](u32 max)
|
|
||||||
{
|
{
|
||||||
ui->microphone1Box->setEnabled(true);
|
|
||||||
|
|
||||||
if (max == 1 || ui->microphone1Box->currentText() == mic_none)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ui->microphone2Box->setEnabled(true);
|
|
||||||
|
|
||||||
if (max > 2 && ui->microphone2Box->currentText() != mic_none)
|
|
||||||
{
|
|
||||||
ui->microphone3Box->setEnabled(true);
|
|
||||||
if (ui->microphone3Box->currentText() != mic_none)
|
|
||||||
{
|
|
||||||
ui->microphone4Box->setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ui->microphone1Box->setEnabled(false);
|
|
||||||
ui->microphone2Box->setEnabled(false);
|
|
||||||
ui->microphone3Box->setEnabled(false);
|
|
||||||
ui->microphone4Box->setEnabled(false);
|
|
||||||
|
|
||||||
fmt_class_string<microphone_handler>::format(s_standard, static_cast<u64>(microphone_handler::standard));
|
|
||||||
fmt_class_string<microphone_handler>::format(s_singstar, static_cast<u64>(microphone_handler::singstar));
|
|
||||||
fmt_class_string<microphone_handler>::format(s_realsingstar, static_cast<u64>(microphone_handler::real_singstar));
|
|
||||||
fmt_class_string<microphone_handler>::format(s_rocksmith, static_cast<u64>(microphone_handler::rocksmith));
|
|
||||||
|
|
||||||
if (text == s_standard.c_str())
|
|
||||||
{
|
|
||||||
enable_mics_combo(4);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (text == s_singstar.c_str())
|
|
||||||
|
const QVariantList var_list = ui->microphoneBox->itemData(index).toList();
|
||||||
|
ASSERT(var_list.size() == 2 && var_list[1].canConvert<int>());
|
||||||
|
const int handler_id = var_list[1].toInt();
|
||||||
|
int max = 0;
|
||||||
|
|
||||||
|
switch (static_cast<microphone_handler>(handler_id))
|
||||||
{
|
{
|
||||||
enable_mics_combo(2);
|
case microphone_handler::standard:
|
||||||
return;
|
max = 4;
|
||||||
}
|
break;
|
||||||
if (text == s_realsingstar.c_str() || text == s_rocksmith.c_str())
|
case microphone_handler::singstar:
|
||||||
{
|
max = 2;
|
||||||
enable_mics_combo(1);
|
break;
|
||||||
return;
|
case microphone_handler::real_singstar:
|
||||||
|
case microphone_handler::rocksmith:
|
||||||
|
max = 1;
|
||||||
|
break;
|
||||||
|
case microphone_handler::null:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->microphone1Box->setEnabled(max > 0);
|
||||||
|
ui->microphone2Box->setEnabled(max > 1 && ui->microphone1Box->currentText() != mic_none);
|
||||||
|
ui->microphone3Box->setEnabled(max > 2 && ui->microphone2Box->currentText() != mic_none);
|
||||||
|
ui->microphone4Box->setEnabled(ui->microphone3Box->isEnabled() && ui->microphone3Box->currentText() != mic_none);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto propagate_used_devices = [=, this]()
|
auto propagate_used_devices = [=, this]()
|
||||||
|
@ -706,7 +693,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
||||||
mics_combo[index]->setCurrentText(cur_item);
|
mics_combo[index]->setCurrentText(cur_item);
|
||||||
mics_combo[index]->blockSignals(false);
|
mics_combo[index]->blockSignals(false);
|
||||||
}
|
}
|
||||||
change_microphone_type(ui->microphoneBox->currentText());
|
change_microphone_type(ui->microphoneBox->currentIndex());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto change_microphone_device = [=, this](u32 next_index, QString text)
|
auto change_microphone_device = [=, this](u32 next_index, QString text)
|
||||||
|
@ -761,7 +748,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
||||||
|
|
||||||
m_emu_settings->EnhanceComboBox(ui->microphoneBox, emu_settings_type::MicrophoneType);
|
m_emu_settings->EnhanceComboBox(ui->microphoneBox, emu_settings_type::MicrophoneType);
|
||||||
SubscribeTooltip(ui->microphoneBox, tooltips.settings.microphone);
|
SubscribeTooltip(ui->microphoneBox, tooltips.settings.microphone);
|
||||||
connect(ui->microphoneBox, &QComboBox::currentTextChanged, change_microphone_type);
|
connect(ui->microphoneBox, QOverload<int>::of(&QComboBox::currentIndexChanged), change_microphone_type);
|
||||||
propagate_used_devices(); // Enables/Disables comboboxes and checks values from config for sanity
|
propagate_used_devices(); // Enables/Disables comboboxes and checks values from config for sanity
|
||||||
|
|
||||||
// Checkboxes
|
// Checkboxes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue