From 95951c31f8afc6b993449086e825cbdc5c4b3e9d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 19 May 2018 22:21:58 +0200 Subject: [PATCH] Qt: Fix obnoxious glitch where game list columns ended up with 0 width Qt can be messy at times --- rpcs3/rpcs3qt/game_list_frame.cpp | 31 +++++++++++++++++++++++++------ rpcs3/rpcs3qt/game_list_frame.h | 3 +++ rpcs3/rpcs3qt/main_window.cpp | 3 +++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 2c3720793..8e404da76 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -165,8 +165,7 @@ game_list_frame::game_list_frame(std::shared_ptr guiSettings, std: if (checked) // handle hidden columns that have zero width after showing them (stuck between others) { - if (m_gameList->columnWidth(col) <= m_gameList->horizontalHeader()->minimumSectionSize()) - m_gameList->setColumnWidth(col, m_gameList->horizontalHeader()->minimumSectionSize()); + FixNarrowColumns(); } }); } @@ -192,12 +191,10 @@ void game_list_frame::LoadSettings() bool vis = xgui_settings->GetGamelistColVisibility(col); m_columnActs[col]->setChecked(vis); m_gameList->setColumnHidden(col, !vis); - - // handle columns that have zero width after showing them (stuck between others) - if (vis && m_gameList->columnWidth(col) <= m_gameList->horizontalHeader()->minimumSectionSize()) - m_gameList->setColumnWidth(col, m_gameList->horizontalHeader()->minimumSectionSize()); } + FixNarrowColumns(); + m_gameList->horizontalHeader()->restoreState(m_gameList->horizontalHeader()->saveState()); m_colSortOrder = xgui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder; @@ -214,6 +211,28 @@ game_list_frame::~game_list_frame() SaveSettings(); } +void game_list_frame::FixNarrowColumns() +{ + if (!isVisible()) // don't use isHidden here + { + // Handle Qt glitch. If we call columnWidth when the table is not shown yet then some columns will have 0 width + return; + } + + 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) + { + const bool visible = !m_gameList->isColumnHidden(col); + + if (visible && m_gameList->columnWidth(col) <= m_gameList->horizontalHeader()->minimumSectionSize()) + { + m_gameList->setColumnWidth(col, m_gameList->horizontalHeader()->minimumSectionSize()); + } + } +} + void game_list_frame::OnColClicked(int col) { if (col == 0) return; // Don't "sort" icons. diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index 1b027c218..cfd9d198e 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -180,6 +180,9 @@ public: explicit game_list_frame(std::shared_ptr guiSettings, std::shared_ptr emuSettings, QWidget *parent = nullptr); ~game_list_frame(); + /** Fix columns with width smaller than the minimal section size */ + void FixNarrowColumns(); + /** 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); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 9aea5ebc8..f344ecd6e 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -186,6 +186,9 @@ void main_window::Init() connect(m_thumb_restart, &QWinThumbnailToolButton::clicked, [=]() { Emu.Restart(); }); connect(m_thumb_playPause, &QWinThumbnailToolButton::clicked, this, &main_window::OnPlayOrPause); #endif + + // Fix possible hidden game list columns. The game list has to be visible already. Use this after show() + m_gameListFrame->FixNarrowColumns(); } // returns appIcon