From 583298211d9a10e0549a2bd716d50571d2958b8b Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 14 Mar 2023 10:10:44 +0200 Subject: [PATCH] some more work on game_list repainter --- shadPS4/gui/game_list_frame.cpp | 33 ++++++++++++++++++++++++++++----- shadPS4/gui/game_list_frame.h | 1 + 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/shadPS4/gui/game_list_frame.cpp b/shadPS4/gui/game_list_frame.cpp index 409a5441..1344fb44 100644 --- a/shadPS4/gui/game_list_frame.cpp +++ b/shadPS4/gui/game_list_frame.cpp @@ -110,13 +110,14 @@ game_list_frame::game_list_frame(std::shared_ptr gui_settings, QWi }); connect(m_game_list->horizontalHeader(), &QHeaderView::sectionClicked, this, &game_list_frame::OnHeaderColumnClicked); connect(&m_repaint_watcher, &QFutureWatcher::resultReadyAt, this, [this](int index) + { + if (!m_is_list_layout) return; + if (game_list_item* item = m_repaint_watcher.resultAt(index)) { - if (!m_is_list_layout) return; - if (game_list_item* item = m_repaint_watcher.resultAt(index)) - { item->call_icon_func(); - } - }); + } + }); + connect(&m_repaint_watcher, &QFutureWatcher::finished, this, &game_list_frame::OnRepaintFinished); Refresh();//TODO remove when watchers added } @@ -279,6 +280,28 @@ void game_list_frame::LoadSettings() m_game_list->horizontalHeader()->restoreState(m_game_list->horizontalHeader()->saveState()); } + +void game_list_frame::OnRepaintFinished() +{ + if (m_is_list_layout) + { + // Fixate vertical header and row height + m_game_list->verticalHeader()->setMinimumSectionSize(m_icon_size.height()); + m_game_list->verticalHeader()->setMaximumSectionSize(m_icon_size.height()); + + // Resize the icon column + m_game_list->resizeColumnToContents(gui::column_icon); + + // Shorten the last section to remove horizontal scrollbar if possible + m_game_list->resizeColumnToContents(gui::column_count - 1); + } + else + { + // The game grid needs to be recreated from scratch + //TODO !! + } +} + void game_list_frame::SaveSettings() { for (int col = 0; col < m_columnActs.count(); ++col) diff --git a/shadPS4/gui/game_list_frame.h b/shadPS4/gui/game_list_frame.h index 16af942c..e5b399b8 100644 --- a/shadPS4/gui/game_list_frame.h +++ b/shadPS4/gui/game_list_frame.h @@ -38,6 +38,7 @@ public : private Q_SLOTS: void OnHeaderColumnClicked(int col); + void OnRepaintFinished(); private: QPixmap PaintedPixmap(const QPixmap& icon) const; void SortGameList() const;