Allow unbinding pad buttons by right clicking (#13283)

This commit is contained in:
Anton Kourganov 2023-01-24 00:00:08 +03:00 committed by GitHub
parent a700e3b39e
commit 52b67b46fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -998,6 +998,23 @@ bool pad_settings_dialog::eventFilter(QObject* object, QEvent* event)
{
case QEvent::MouseButtonRelease:
{
// On right click clear binding if we are not remapping pad button
if (m_button_id == button_ids::id_pad_begin)
{
QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
if (const auto button = qobject_cast<QPushButton*>(object); button && mouse_event->button() == Qt::RightButton)
{
if (const int button_id = m_pad_buttons->id(button); m_cfg_entries.contains(button_id))
{
m_cfg_entries[button_id].key.clear();
m_cfg_entries[button_id].text.clear();
UpdateLabels();
return true;
}
}
}
// Disabled buttons should not absorb mouseclicks
event->ignore();
break;