From b97f97159d245d7d6a898218e73633bcdc1161f6 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 12 Jun 2021 17:07:32 -0700 Subject: [PATCH] Qt: Fix having to press controller buttons twice for menu items (fixes #2143) --- CHANGES | 1 + src/platform/qt/ActionMapper.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 246bdec53..6e3e90581 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,7 @@ Other fixes: - Qt: Fix infrequent deadlock when using sync to video - Qt: Fix applying savetype-only overrides - Qt: Fix crash in sprite view for partially out-of-bounds sprites (fixes mgba.io/i/2165) + - Qt: Fix having to press controller buttons twice for menu items (fixes mgba.io/i/2143) - Util: Fix loading UPS patches that affect the last byte of the file Misc: - Core: Suspend runloop when a core crashes diff --git a/src/platform/qt/ActionMapper.cpp b/src/platform/qt/ActionMapper.cpp index bdd2065cc..a0d80a0d1 100644 --- a/src/platform/qt/ActionMapper.cpp +++ b/src/platform/qt/ActionMapper.cpp @@ -87,7 +87,13 @@ void ActionMapper::rebuildMenu(const QString& menu, QMenu* qmenu, QWidget* conte } }); QObject::connect(action, &Action::enabled, qaction, &QAction::setEnabled); - QObject::connect(action, &Action::activated, qaction, &QAction::setChecked); + QObject::connect(action, &Action::activated, [qaction, action](bool active) { + if (qaction->isCheckable()) { + qaction->setChecked(active); + } else if (active) { + action->setActive(false); + } + }); QObject::connect(action, &Action::destroyed, qaction, &QAction::deleteLater); if (shortcut) { QObject::connect(shortcut, &Shortcut::shortcutChanged, qaction, [qaction](int shortcut) {