mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 23:25:41 +00:00
Qt: Fix list focus restoration after system shutdown
This commit is contained in:
parent
2f5aa45e1f
commit
add46248a3
|
@ -244,10 +244,12 @@ void GameListWidget::initialize()
|
|||
connect(m_empty_ui.scanForNewGames, &QPushButton::clicked, this, [this]() { refresh(false); });
|
||||
m_ui.stack->insertWidget(2, m_empty_widget);
|
||||
|
||||
if (Host::GetBaseBoolSettingValue("UI", "GameListGridView", false))
|
||||
const bool grid_view = Host::GetBaseBoolSettingValue("UI", "GameListGridView", false);
|
||||
if (grid_view)
|
||||
m_ui.stack->setCurrentIndex(1);
|
||||
else
|
||||
m_ui.stack->setCurrentIndex(0);
|
||||
setFocusProxy(grid_view ? static_cast<QWidget*>(m_list_view) : static_cast<QWidget*>(m_table_view));
|
||||
|
||||
updateToolbar();
|
||||
resizeTableViewColumnsToFit();
|
||||
|
@ -323,7 +325,11 @@ 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);
|
||||
{
|
||||
const bool grid_view = Host::GetBaseBoolSettingValue("UI", "GameListGridView", false);
|
||||
m_ui.stack->setCurrentIndex(grid_view ? 1 : 0);
|
||||
setFocusProxy(grid_view ? static_cast<QWidget*>(m_list_view) : static_cast<QWidget*>(m_table_view));
|
||||
}
|
||||
|
||||
if (!m_model->hasTakenGameList() || time >= SHORT_REFRESH_TIME)
|
||||
emit refreshProgress(status, current, total);
|
||||
|
@ -341,7 +347,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)
|
||||
|
@ -468,6 +477,7 @@ void GameListWidget::showGameList()
|
|||
Host::SetBaseBoolSettingValue("UI", "GameListGridView", false);
|
||||
Host::CommitBaseSettingChanges();
|
||||
m_ui.stack->setCurrentIndex(0);
|
||||
setFocusProxy(m_table_view);
|
||||
resizeTableViewColumnsToFit();
|
||||
updateToolbar();
|
||||
emit layoutChange();
|
||||
|
@ -484,6 +494,7 @@ void GameListWidget::showGameGrid()
|
|||
Host::SetBaseBoolSettingValue("UI", "GameListGridView", true);
|
||||
Host::CommitBaseSettingChanges();
|
||||
m_ui.stack->setCurrentIndex(1);
|
||||
setFocusProxy(m_list_view);
|
||||
updateToolbar();
|
||||
emit layoutChange();
|
||||
}
|
||||
|
|
|
@ -2003,12 +2003,8 @@ bool MainWindow::shouldHideMainWindow() const
|
|||
|
||||
void MainWindow::switchToGameListView()
|
||||
{
|
||||
if (isShowingGameList())
|
||||
if (!isShowingGameList())
|
||||
{
|
||||
m_game_list_widget->setFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_display_created)
|
||||
{
|
||||
m_was_paused_on_surface_loss = s_system_paused;
|
||||
|
@ -2020,6 +2016,9 @@ void MainWindow::switchToGameListView()
|
|||
while (m_display_widget)
|
||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
|
||||
}
|
||||
}
|
||||
|
||||
m_game_list_widget->setFocus();
|
||||
}
|
||||
|
||||
void MainWindow::switchToEmulationView()
|
||||
|
|
Loading…
Reference in a new issue