summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2022-05-20 13:20:09 -0700
committerPokechu22 <Pokechu022@gmail.com>2022-05-21 18:11:24 -0700
commit2d50ba0ca27c42485e1cc8934cb9b65ea4f3f829 (patch)
treeb4cbe2fd00b2b00c23a75fddfb0f3705e5a24ffd /Source/Core
parent0e948f3e21993721604fb44febf591516bd7e91a (diff)
GameList: Have home/end keys move to first/last row
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/GameList/GameList.cpp24
1 files changed, 23 insertions, 1 deletions
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);