diff --git a/src/platform/qt/ShortcutController.cpp b/src/platform/qt/ShortcutController.cpp index 0bb6d5e94..d46838a24 100644 --- a/src/platform/qt/ShortcutController.cpp +++ b/src/platform/qt/ShortcutController.cpp @@ -163,12 +163,12 @@ const ShortcutController::ShortcutItem* ShortcutController::itemAt(const QModelI return static_cast(index.internalPointer()); } -const QAction* ShortcutController::actionAt(const QModelIndex& index) const { +QKeySequence ShortcutController::shortcutAt(const QModelIndex& index) const { const ShortcutItem* item = itemAt(index); if (!item) { - return nullptr; + return QKeySequence(); } - return item->action(); + return item->shortcut(); } bool ShortcutController::isMenuAt(const QModelIndex& index) const { diff --git a/src/platform/qt/ShortcutController.h b/src/platform/qt/ShortcutController.h index 53d8e1e1b..eb944158d 100644 --- a/src/platform/qt/ShortcutController.h +++ b/src/platform/qt/ShortcutController.h @@ -86,7 +86,7 @@ public: void addFunctions(QMenu* menu, std::function press, std::function release, const QKeySequence& shortcut, const QString& visibleName, const QString& name); void addMenu(QMenu* menu, QMenu* parent = nullptr); - const QAction* actionAt(const QModelIndex& index) const; + QKeySequence shortcutAt(const QModelIndex& index) const; bool isMenuAt(const QModelIndex& index) const; void updateKey(const QModelIndex& index, const QKeySequence& keySequence); diff --git a/src/platform/qt/ShortcutView.cpp b/src/platform/qt/ShortcutView.cpp index df04e9226..446e69d2a 100644 --- a/src/platform/qt/ShortcutView.cpp +++ b/src/platform/qt/ShortcutView.cpp @@ -47,16 +47,21 @@ void ShortcutView::load(const QModelIndex& index) { if (!m_controller) { return; } - const QAction* action = m_controller->actionAt(index); - if (!action || m_controller->isMenuAt(index)) { + if (m_controller->isMenuAt(index)) { return; } + QKeySequence sequence = m_controller->shortcutAt(index); + if (index.column() == 1) { + m_ui.keyboardButton->click(); + } else if (index.column() == 2) { + m_ui.gamepadButton->click(); + } if (m_ui.gamepadButton->isChecked()) { m_ui.keyEdit->setFocus(); m_ui.keyEdit->setValueButton(-1); // There are no default bindings } else { m_ui.keySequenceEdit->setFocus(); - m_ui.keySequenceEdit->setKeySequence(action->shortcut()); + m_ui.keySequenceEdit->setKeySequence(sequence); } } @@ -65,8 +70,7 @@ void ShortcutView::clear() { return; } QModelIndex index = m_ui.shortcutTable->selectionModel()->currentIndex(); - const QAction* action = m_controller->actionAt(index); - if (!action || m_controller->isMenuAt(index)) { + if (m_controller->isMenuAt(index)) { return; } if (m_ui.gamepadButton->isChecked()) {