From e95f542e3476f6849605447cda40c3c504ea01c4 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 9 Mar 2023 13:36:51 +0200 Subject: [PATCH] initial work on new game_list --- shadPS4/gui/game_list_frame.cpp | 45 +++++++++++++++++++++++++++++++++ shadPS4/gui/game_list_frame.h | 23 +++++++++++++++++ shadPS4/shadPS4.vcxproj | 2 ++ shadPS4/shadPS4.vcxproj.filters | 6 +++++ 4 files changed, 76 insertions(+) create mode 100644 shadPS4/gui/game_list_frame.cpp create mode 100644 shadPS4/gui/game_list_frame.h diff --git a/shadPS4/gui/game_list_frame.cpp b/shadPS4/gui/game_list_frame.cpp new file mode 100644 index 00000000..57eec70d --- /dev/null +++ b/shadPS4/gui/game_list_frame.cpp @@ -0,0 +1,45 @@ +#include "game_list_frame.h" + + + +void game_list_frame::FixNarrowColumns() const +{ + qApp->processEvents(); + + // handle columns (other than the icon column) that have zero width after showing them (stuck between others) + for (int col = 1; col < m_columnActs.count(); ++col) + { + if (m_game_list->isColumnHidden(col)) + { + continue; + } + + if (m_game_list->columnWidth(col) <= m_game_list->horizontalHeader()->minimumSectionSize()) + { + m_game_list->setColumnWidth(col, m_game_list->horizontalHeader()->minimumSectionSize()); + } + } +} + +void game_list_frame::ResizeColumnsToContents(int spacing) const +{ + if (!m_game_list) + { + return; + } + + m_game_list->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); + m_game_list->horizontalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents); + + // Make non-icon columns slighty bigger for better visuals + for (int i = 1; i < m_game_list->columnCount(); i++) + { + if (m_game_list->isColumnHidden(i)) + { + continue; + } + + const int size = m_game_list->horizontalHeader()->sectionSize(i) + spacing; + m_game_list->horizontalHeader()->resizeSection(i, size); + } +} \ No newline at end of file diff --git a/shadPS4/gui/game_list_frame.h b/shadPS4/gui/game_list_frame.h new file mode 100644 index 00000000..02b1142a --- /dev/null +++ b/shadPS4/gui/game_list_frame.h @@ -0,0 +1,23 @@ +#pragma once + +#include "game_list_table.h" +#include "shadps4gui.h" + +#include + +class game_list_frame +{ +public : + /** Fix columns with width smaller than the minimal section size */ + void FixNarrowColumns() const; + + /** Resizes the columns to their contents and adds a small spacing */ + void ResizeColumnsToContents(int spacing = 20) const; + +private: + // Game List + game_list_table* m_game_list = nullptr; + QList m_columnActs; + +}; + diff --git a/shadPS4/shadPS4.vcxproj b/shadPS4/shadPS4.vcxproj index 6249c93e..817400ef 100644 --- a/shadPS4/shadPS4.vcxproj +++ b/shadPS4/shadPS4.vcxproj @@ -17,6 +17,7 @@ + @@ -41,6 +42,7 @@ + diff --git a/shadPS4/shadPS4.vcxproj.filters b/shadPS4/shadPS4.vcxproj.filters index 072d8376..8280e965 100644 --- a/shadPS4/shadPS4.vcxproj.filters +++ b/shadPS4/shadPS4.vcxproj.filters @@ -71,6 +71,9 @@ gui + + gui + @@ -119,5 +122,8 @@ gui + + gui + \ No newline at end of file