diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 9309e43662..7fae4bf360 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -183,8 +183,7 @@ void game_list_frame::LoadSettings() if (!m_gameList->horizontalHeader()->restoreState(state) && m_gameList->rowCount()) { // If no settings exist, resize to contents. - m_gameList->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); - m_gameList->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); + ResizeColumnsToContents(); } for (int col = 0; col < m_columnActs.count(); ++col) @@ -226,6 +225,29 @@ void game_list_frame::FixNarrowColumns() } } +void game_list_frame::ResizeColumnsToContents(int spacing) +{ + if (!m_gameList) + { + return; + } + + m_gameList->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); + m_gameList->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); + + // Make non-icon columns slighty bigger for better visuals + for (int i = 1; i < m_gameList->columnCount(); i++) + { + if (m_gameList->isColumnHidden(i)) + { + continue; + } + + int size = m_gameList->horizontalHeader()->sectionSize(i) + spacing; + m_gameList->horizontalHeader()->resizeSection(i, size); + } +} + void game_list_frame::OnColClicked(int col) { if (col == 0) return; // Don't "sort" icons. @@ -418,10 +440,17 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter) if (m_isListLayout) { int scroll_position = m_gameList->verticalScrollBar()->value(); + int rows = m_gameList->rowCount(); int row = PopulateGameList(); m_gameList->selectRow(row); SortGameList(); + // Resize columns if the game list was empty before + if (!rows) + { + ResizeColumnsToContents(); + } + if (scrollAfter) { m_gameList->scrollTo(m_gameList->currentIndex(), QAbstractItemView::PositionAtCenter); diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index cfd9d198e1..fa4dedf94c 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -183,6 +183,9 @@ public: /** Fix columns with width smaller than the minimal section size */ void FixNarrowColumns(); + /** Resizes the columns to their contents and adds a small spacing */ + void ResizeColumnsToContents(int spacing = 20); + /** Refresh the gamelist with/without loading game data from files. Public so that main frame can refresh after vfs or install */ void Refresh(const bool fromDrive = false, const bool scrollAfter = true);