initial work on new game_list

This commit is contained in:
georgemoralis 2023-03-09 13:36:51 +02:00
parent e2181f1ed9
commit e95f542e34
4 changed files with 76 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -0,0 +1,23 @@
#pragma once
#include "game_list_table.h"
#include "shadps4gui.h"
#include <QHeaderView>
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<QAction*> m_columnActs;
};

View File

@ -17,6 +17,7 @@
<ClCompile Include="emulator\Loader.cpp" />
<ClCompile Include="gui\custom_table_widget_item.cpp" />
<ClCompile Include="gui\GameListViewer.cpp" />
<ClCompile Include="gui\game_list_frame.cpp" />
<ClCompile Include="gui\game_list_grid.cpp" />
<ClCompile Include="gui\game_list_grid_delegate.cpp" />
<ClCompile Include="gui\game_list_table.cpp" />
@ -41,6 +42,7 @@
<ClInclude Include="emulator\Loader.h" />
<ClInclude Include="gui\custom_table_widget_item.h" />
<QtMoc Include="gui\game_list_grid.h" />
<ClInclude Include="gui\game_list_frame.h" />
<ClInclude Include="gui\game_list_grid_delegate.h" />
<ClInclude Include="gui\game_list_table.h" />
<ClInclude Include="gui\gui_settings.h" />

View File

@ -71,6 +71,9 @@
<ClCompile Include="gui\game_list_grid.cpp">
<Filter>gui</Filter>
</ClCompile>
<ClCompile Include="gui\game_list_frame.cpp">
<Filter>gui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtUic Include="gui\shadps4gui.ui">
@ -119,5 +122,8 @@
<ClInclude Include="gui\game_list_grid_delegate.h">
<Filter>gui</Filter>
</ClInclude>
<ClInclude Include="gui\game_list_frame.h">
<Filter>gui</Filter>
</ClInclude>
</ItemGroup>
</Project>