all repos — mgba @ 851d942cdd8ceebfe08f9a1be8940d4c3a62e689

mGBA Game Boy Advance Emulator

Qt: Fix a few more UX grievances
Jeffrey Pfau jeffrey@endrift.com
Mon, 05 Jan 2015 02:06:37 -0800
commit

851d942cdd8ceebfe08f9a1be8940d4c3a62e689

parent

c90d105e3490d0b94a4dc5de182c6cf18b5616ba

M src/platform/qt/ShortcutController.cppsrc/platform/qt/ShortcutController.cpp

@@ -163,12 +163,12 @@ }

return static_cast<const ShortcutItem*>(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 {
M src/platform/qt/ShortcutController.hsrc/platform/qt/ShortcutController.h

@@ -86,7 +86,7 @@ void addAction(QMenu* menu, QAction* action, const QString& name);

void addFunctions(QMenu* menu, std::function<void ()> press, std::function<void()> 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);
M src/platform/qt/ShortcutView.cppsrc/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 @@ if (!m_controller) {

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()) {