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.
This commit is contained in:
deanff 2024-08-25 01:30:34 +09:30 committed by GitHub
parent 517fba3686
commit 1131db784f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -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();
}