Load/Save column visability

This commit is contained in:
georgemoralis 2023-03-10 10:53:05 +02:00
parent 29a4b249d8
commit c0b2c357ec
3 changed files with 28 additions and 1 deletions

View File

@ -82,7 +82,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> gui_settings,QWid
}
}
game_list_frame::~game_list_frame(){
SaveSettings();
}
void game_list_frame::FixNarrowColumns() const
{
@ -192,3 +192,23 @@ void game_list_frame::SortGameList() const
// Shorten the last section to remove horizontal scrollbar if possible
m_game_list->resizeColumnToContents(gui::column_count - 1);
}
void game_list_frame::LoadSettings()
{
for (int col = 0; col < m_columnActs.count(); ++col)
{
const bool vis = m_gui_settings->GetGamelistColVisibility(col);
m_columnActs[col]->setChecked(vis);
m_game_list->setColumnHidden(col, !vis);
}
FixNarrowColumns();
m_game_list->horizontalHeader()->restoreState(m_game_list->horizontalHeader()->saveState());
}
void game_list_frame::SaveSettings()
{
for (int col = 0; col < m_columnActs.count(); ++col)
{
m_gui_settings->SetGamelistColVisibility(col, m_columnActs[col]->isChecked());
}
}

View File

@ -16,6 +16,12 @@ public :
/** Fix columns with width smaller than the minimal section size */
void FixNarrowColumns() const;
/** Loads from settings. Public so that main frame can easily reset these settings if needed. */
void LoadSettings();
/** Saves settings. Public so that main frame can save this when a caching of column widths is needed for settings backup */
void SaveSettings();
/** Resizes the columns to their contents and adds a small spacing */
void ResizeColumnsToContents(int spacing = 20) const;

View File

@ -19,6 +19,7 @@ shadps4gui::shadps4gui(std::shared_ptr<gui_settings> gui_settings, QWidget* pare
//game_list->PopulateAsync();
game_list_frame* game_list2 = new game_list_frame(m_gui_settings);
ui.horizontalLayout->addWidget(game_list2);
game_list2->LoadSettings();
show();
}