From 7dd36ff8294c875667b5b3f560f9ea5b1702883c Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 7 Mar 2020 02:01:28 +0100 Subject: [PATCH] Qt: Fix CurrentSelectionIconPath for game grid Fixes deselection issue when booting a game in the game grid --- rpcs3/rpcs3qt/game_list_frame.cpp | 34 ++++++++++++++++++++++--------- rpcs3/rpcs3qt/game_list_frame.h | 3 +-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 511dbb838b..79f1582b6a 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -789,8 +789,7 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter) if (m_isListLayout) { const int scroll_position = m_gameList->verticalScrollBar()->value(); - const int row = PopulateGameList(); - m_gameList->selectRow(row); + PopulateGameList(); SortGameList(); if (scrollAfter) @@ -1950,9 +1949,9 @@ bool game_list_frame::eventFilter(QObject *object, QEvent *event) /** Cleans and readds entries to table widget in UI. */ -int game_list_frame::PopulateGameList() +void game_list_frame::PopulateGameList() { - int result = -1; + int selected_row = -1; std::string selected_item = CurrentSelectionIconPath(); @@ -2073,15 +2072,14 @@ int game_list_frame::PopulateGameList() if (selected_item == game->info.icon_path) { - result = row; + selected_row = row; } row++; } m_gameList->setRowCount(row); - - return result; + m_gameList->selectRow(selected_row); } void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, const QColor& image_color) @@ -2150,7 +2148,7 @@ void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, con if (selected_item == app->info.icon_path) { - m_xgrid->setCurrentItem(m_xgrid->item(r, c)); + m_xgrid->setCurrentCell(r, c); } if (++c >= maxCols) @@ -2193,9 +2191,25 @@ std::string game_list_frame::CurrentSelectionIconPath() { std::string selection; - if (m_gameList->selectedItems().count()) + QTableWidgetItem* item = nullptr; + + if (m_oldLayoutIsList) + { + if (!m_gameList->selectedItems().isEmpty()) + { + item = m_gameList->item(m_gameList->currentRow(), 0); + } + } + else + { + if (!m_xgrid->selectedItems().isEmpty()) + { + item = m_xgrid->currentItem(); + } + } + + if (item) { - QTableWidgetItem* item = m_oldLayoutIsList ? m_gameList->item(m_gameList->currentRow(), 0) : m_xgrid->currentItem(); QVariant var = item->data(gui::game_role); if (var.canConvert()) diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index 5706e84aaa..1eb34f91a2 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -97,11 +97,10 @@ private: QPixmap PaintedPixmap(const QPixmap& icon, bool paint_config_icon = false, bool paint_pad_config_icon = false, const QColor& color = QColor()); QColor getGridCompatibilityColor(const QString& string); void ShowCustomConfigIcon(game_info game); + void PopulateGameList(); void PopulateGameGrid(int maxCols, const QSize& image_size, const QColor& image_color); bool IsEntryVisible(const game_info& game); void SortGameList(); - - int PopulateGameList(); bool SearchMatchesApp(const QString& name, const QString& serial) const; bool RemoveCustomConfiguration(const std::string& title_id, game_info game = nullptr, bool is_interactive = false);