From 2732d6c3dc112885cb5cbf61aea25d3894d6125c Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 15 Oct 2024 01:45:35 +0200 Subject: [PATCH] Qt: Make sure that table columns and their actions have the same state after restoring the layout --- rpcs3/rpcs3qt/game_list.cpp | 31 +++++++++++++++++++++---- rpcs3/rpcs3qt/game_list.h | 1 + rpcs3/rpcs3qt/game_list_frame.cpp | 8 ++----- rpcs3/rpcs3qt/trophy_manager_dialog.cpp | 11 +++++++++ 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list.cpp b/rpcs3/rpcs3qt/game_list.cpp index c60dd712a8..77f015f7cf 100644 --- a/rpcs3/rpcs3qt/game_list.cpp +++ b/rpcs3/rpcs3qt/game_list.cpp @@ -14,6 +14,30 @@ game_list::game_list() : QTableWidget(), game_list_base() }; } +void game_list::sync_header_actions(QList& actions, std::function get_visibility) +{ + ensure(get_visibility); + + bool is_dirty = false; + + for (int col = 0; col < actions.count(); ++col) + { + const bool is_hidden = !get_visibility(col); + actions[col]->setChecked(!is_hidden); + + if (isColumnHidden(col) != is_hidden) + { + setColumnHidden(col, is_hidden); + is_dirty = true; + } + } + + if (is_dirty) + { + fix_narrow_columns(); + } +} + void game_list::create_header_actions(QList& actions, std::function get_visibility, std::function set_visibility) { ensure(get_visibility); @@ -48,6 +72,7 @@ void game_list::create_header_actions(QList& actions, std::function