From 553f67d7e39cd80b3923070006be595c7e4029a8 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 10 Sep 2017 23:31:51 +0200 Subject: [PATCH] Qt: improve gamelist refresh, fix some more scroll issues despite earlier efforts with modelindex and so on the annoying scroll jump still surfaced sometimes, so we only scrollTo index on selected occasions from now on. Furthermore we don't need to refresh the gamelist if no custom config has been applied, so this will only be needed on accept from now on --- rpcs3/rpcs3qt/game_list_frame.cpp | 41 +++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index cac23136d4..6f2ddcb9e8 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -24,6 +24,7 @@ #include #include #include +#include static const std::string m_class_name = "GameViewer"; inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); } @@ -473,6 +474,7 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter) if (m_isListLayout) { + int scroll_position = m_gameList->verticalScrollBar()->value(); FilterData(); int row = PopulateGameList(); m_gameList->selectRow(row); @@ -482,6 +484,10 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter) { m_gameList->scrollTo(m_gameList->currentIndex(), QAbstractItemView::PositionAtCenter); } + else + { + m_gameList->verticalScrollBar()->setValue(std::min(m_gameList->verticalScrollBar()->maximum(), scroll_position)); + } } else { @@ -494,6 +500,7 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter) m_games_per_row = 0; } + int scroll_position = m_xgrid->verticalScrollBar()->value(); PopulateGameGrid(m_games_per_row, m_Icon_Size, m_Icon_Color); connect(m_xgrid, &QTableWidget::doubleClicked, this, &game_list_frame::doubleClickedSlot); connect(m_xgrid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu); @@ -504,6 +511,10 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter) { m_xgrid->scrollTo(m_xgrid->currentIndex()); } + else + { + m_xgrid->verticalScrollBar()->setValue(std::min(m_xgrid->verticalScrollBar()->maximum(), scroll_position)); + } } } @@ -649,8 +660,12 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row) }); connect(configure, &QAction::triggered, [=] { - settings_dialog (xgui_settings, m_Render_Creator, 0, this, &currGame).exec(); - Refresh(true, false); + settings_dialog dlg(xgui_settings, m_Render_Creator, 0, this, &currGame); + connect(&dlg, &QDialog::accepted, [this] + { + Refresh(true, false); + }); + dlg.exec(); }); connect(removeGame, &QAction::triggered, [=] { @@ -661,11 +676,23 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row) Refresh(); } }); - - connect(removeConfig, &QAction::triggered, [=]() {RemoveCustomConfiguration(row); Refresh(true, false); }); - connect(deleteShadersCache, &QAction::triggered, [=]() { DeleteShadersCache(row); }); - connect(openGameFolder, &QAction::triggered, [=]() {open_dir(currGame.path); }); - connect(openConfig, &QAction::triggered, [=]() {open_dir(fs::get_config_dir() + "data/" + currGame.serial); }); + connect(removeConfig, &QAction::triggered, [=]() + { + RemoveCustomConfiguration(row); + Refresh(true, false); + }); + connect(deleteShadersCache, &QAction::triggered, [=]() + { + DeleteShadersCache(row); + }); + connect(openGameFolder, &QAction::triggered, [=]() + { + open_dir(currGame.path); + }); + connect(openConfig, &QAction::triggered, [=]() + { + open_dir(fs::get_config_dir() + "data/" + currGame.serial); + }); connect(checkCompat, &QAction::triggered, [=] { QString link = "https://rpcs3.net/compatibility?g=" + qstr(currGame.serial);