From 1131db784f3199dc9df78782e41caf66f0c91533 Mon Sep 17 00:00:00 2001 From: deanff <31579938+deanff@users.noreply.github.com> Date: Sun, 25 Aug 2024 01:30:34 +0930 Subject: [PATCH] Qt: Set focus to Game Library for improved keyboard navigation (#11719) Improved keyboard navigation. Users can navigate the Library and play/exit games with just the arrow keys and Enter/Esc. --- pcsx2-qt/GameList/GameListWidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pcsx2-qt/GameList/GameListWidget.cpp b/pcsx2-qt/GameList/GameListWidget.cpp index c447dee16c..81a465f1a2 100644 --- a/pcsx2-qt/GameList/GameListWidget.cpp +++ b/pcsx2-qt/GameList/GameListWidget.cpp @@ -241,6 +241,8 @@ void GameListWidget::initialize() else m_ui.stack->setCurrentIndex(0); + setFocusProxy(m_ui.stack->currentWidget()); + updateToolbar(); resizeTableViewColumnsToFit(); } @@ -294,7 +296,10 @@ void GameListWidget::onRefreshProgress(const QString& status, int current, int t { // switch away from the placeholder while we scan, in case we find anything if (m_ui.stack->currentIndex() == 2) + { m_ui.stack->setCurrentIndex(Host::GetBaseBoolSettingValue("UI", "GameListGridView", false) ? 1 : 0); + setFocusProxy(m_ui.stack->currentWidget()); + } m_model->refresh(); emit refreshProgress(status, current, total); @@ -312,7 +317,10 @@ void GameListWidget::onRefreshComplete() // if we still had no games, switch to the helper widget if (m_model->rowCount() == 0) + { m_ui.stack->setCurrentIndex(2); + setFocusProxy(nullptr); + } } void GameListWidget::onSelectionModelCurrentChanged(const QModelIndex& current, const QModelIndex& previous) @@ -436,6 +444,7 @@ void GameListWidget::showGameList() Host::SetBaseBoolSettingValue("UI", "GameListGridView", false); Host::CommitBaseSettingChanges(); m_ui.stack->setCurrentIndex(0); + setFocusProxy(m_ui.stack->currentWidget()); resizeTableViewColumnsToFit(); updateToolbar(); emit layoutChange(); @@ -453,6 +462,7 @@ void GameListWidget::showGameGrid() Host::SetBaseBoolSettingValue("UI", "GameListGridView", true); Host::CommitBaseSettingChanges(); m_ui.stack->setCurrentIndex(1); + setFocusProxy(m_ui.stack->currentWidget()); updateToolbar(); emit layoutChange(); }