mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 17:58:37 +12:00
Qt: resize game list columns by default with slight spacing
This commit is contained in:
parent
f1670a9ea0
commit
40d2341ef1
2 changed files with 34 additions and 2 deletions
|
@ -183,8 +183,7 @@ void game_list_frame::LoadSettings()
|
||||||
if (!m_gameList->horizontalHeader()->restoreState(state) && m_gameList->rowCount())
|
if (!m_gameList->horizontalHeader()->restoreState(state) && m_gameList->rowCount())
|
||||||
{
|
{
|
||||||
// If no settings exist, resize to contents.
|
// If no settings exist, resize to contents.
|
||||||
m_gameList->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
|
ResizeColumnsToContents();
|
||||||
m_gameList->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int col = 0; col < m_columnActs.count(); ++col)
|
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)
|
void game_list_frame::OnColClicked(int col)
|
||||||
{
|
{
|
||||||
if (col == 0) return; // Don't "sort" icons.
|
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)
|
if (m_isListLayout)
|
||||||
{
|
{
|
||||||
int scroll_position = m_gameList->verticalScrollBar()->value();
|
int scroll_position = m_gameList->verticalScrollBar()->value();
|
||||||
|
int rows = m_gameList->rowCount();
|
||||||
int row = PopulateGameList();
|
int row = PopulateGameList();
|
||||||
m_gameList->selectRow(row);
|
m_gameList->selectRow(row);
|
||||||
SortGameList();
|
SortGameList();
|
||||||
|
|
||||||
|
// Resize columns if the game list was empty before
|
||||||
|
if (!rows)
|
||||||
|
{
|
||||||
|
ResizeColumnsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
if (scrollAfter)
|
if (scrollAfter)
|
||||||
{
|
{
|
||||||
m_gameList->scrollTo(m_gameList->currentIndex(), QAbstractItemView::PositionAtCenter);
|
m_gameList->scrollTo(m_gameList->currentIndex(), QAbstractItemView::PositionAtCenter);
|
||||||
|
|
|
@ -183,6 +183,9 @@ public:
|
||||||
/** Fix columns with width smaller than the minimal section size */
|
/** Fix columns with width smaller than the minimal section size */
|
||||||
void FixNarrowColumns();
|
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 */
|
/** 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);
|
void Refresh(const bool fromDrive = false, const bool scrollAfter = true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue