Qt: Simplify Rebind All behavior

This commit is contained in:
Albert Liu 2020-06-14 16:06:29 -07:00
parent fc0560087f
commit fd4e41bc7d

View file

@ -124,7 +124,7 @@ void ControllerSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* u
QPushButton* clear_all_button = new QPushButton(tr("Clear All"), ui->widget); QPushButton* clear_all_button = new QPushButton(tr("Clear All"), ui->widget);
clear_all_button->connect(clear_all_button, &QPushButton::clicked, [this, index]() { clear_all_button->connect(clear_all_button, &QPushButton::clicked, [this, index]() {
if (QMessageBox::question(this, tr("Clear Bindings"), if (QMessageBox::question(this, tr("Clear Bindings"),
tr("Are you sure you want to clear all bound controls? This cannot be reversed.")) != tr("Are you sure you want to clear all bound controls? This can not be reversed.")) !=
QMessageBox::Yes) QMessageBox::Yes)
{ {
return; return;
@ -140,16 +140,20 @@ void ControllerSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* u
QPushButton* rebind_all_button = new QPushButton(tr("Rebind All"), ui->widget); QPushButton* rebind_all_button = new QPushButton(tr("Rebind All"), ui->widget);
rebind_all_button->connect(rebind_all_button, &QPushButton::clicked, [this, index]() { rebind_all_button->connect(rebind_all_button, &QPushButton::clicked, [this, index]() {
if (QMessageBox::question(this, tr("Clear Bindings"), tr("Do you want to clear all currently-bound controls?")) == if (QMessageBox::question(this, tr("Rebind All"),
tr("Are you sure you want to rebind all controls? All currently-bound controls will be "
"irreversibly cleared. Rebinding will begin after confirmation.")) !=
QMessageBox::Yes) QMessageBox::Yes)
{ {
return;
}
InputBindingWidget* widget = m_port_ui[index].first_button; InputBindingWidget* widget = m_port_ui[index].first_button;
while (widget) while (widget)
{ {
widget->clearBinding(); widget->clearBinding();
widget = widget->getNextWidget(); widget = widget->getNextWidget();
} }
}
if (m_port_ui[index].first_button) if (m_port_ui[index].first_button)
m_port_ui[index].first_button->beginRebindAll(); m_port_ui[index].first_button->beginRebindAll();