From 2d50ba0ca27c42485e1cc8934cb9b65ea4f3f829 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 20 May 2022 13:20:09 -0700 Subject: [PATCH] GameList: Have home/end keys move to first/last row --- Source/Core/DolphinQt/GameList/GameList.cpp | 24 ++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 5583497435..78c8f7c3d3 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -70,6 +70,28 @@ #include "UICommon/GameFile.h" +namespace +{ +class GameListTableView : public QTableView +{ +public: + explicit GameListTableView(QWidget* parent = nullptr) : QTableView(parent) {} + +protected: + QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override + { + // QTableView::moveCursor handles home by moving to the first column and end by moving to the + // last column, unless control is held in which case it ALSO moves to the first/last row. + // Columns are irrelevant for the game list, so treat the home/end press as if control were + // held. + if (cursorAction == CursorAction::MoveHome || cursorAction == CursorAction::MoveEnd) + return QTableView::moveCursor(cursorAction, modifiers | Qt::ControlModifier); + else + return QTableView::moveCursor(cursorAction, modifiers); + } +}; +} // namespace + GameList::GameList(QWidget* parent) : QStackedWidget(parent), m_model(this) { m_list_proxy = new ListProxyModel(this); @@ -129,7 +151,7 @@ void GameList::PurgeCache() void GameList::MakeListView() { - m_list = new QTableView(this); + m_list = new GameListTableView(this); m_list->setModel(m_list_proxy); m_list->setTabKeyNavigation(false);