From 4ca92464c055e74580ebcdd39c4c7a9f5d239a95 Mon Sep 17 00:00:00 2001 From: Christian Aguilera Date: Sun, 27 Sep 2020 02:40:56 +0200 Subject: [PATCH] **Refresh** and **Purge Game List Cache** now correctly enabled/disabled as notified by GameListRefreshRequested and GameListRefreshCompleted. --- Source/Core/DolphinQt/GameList/GameTracker.cpp | 3 ++- Source/Core/DolphinQt/MenuBar.cpp | 8 +++++++- Source/Core/DolphinQt/ToolBar.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinQt/GameList/GameTracker.cpp b/Source/Core/DolphinQt/GameList/GameTracker.cpp index 4d8a5d25d7..5d8e5d20a2 100644 --- a/Source/Core/DolphinQt/GameList/GameTracker.cpp +++ b/Source/Core/DolphinQt/GameList/GameTracker.cpp @@ -156,6 +156,7 @@ void GameTracker::StartInternal() m_cache.Save(); QueueOnObject(this, [] { Settings::Instance().NotifyMetadataRefreshComplete(); }); + QueueOnObject(this, [] { Settings::Instance().NotifyRefreshGameListComplete(); }); } bool GameTracker::AddPath(const QString& dir) @@ -347,5 +348,5 @@ void GameTracker::LoadGame(const QString& path) void GameTracker::PurgeCache() { m_load_thread.EmplaceItem(Command{CommandType::PurgeCache, {}}); - RefreshAll(); + Settings::Instance().RefreshGameList(); } diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 5c9f91544b..680e6c86cb 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -506,7 +506,13 @@ void MenuBar::AddViewMenu() AddShowRegionsMenu(view_menu); view_menu->addSeparator(); - view_menu->addAction(tr("Purge Game List Cache"), this, &MenuBar::PurgeGameListCache); + QAction* const purge_action = + view_menu->addAction(tr("Purge Game List Cache"), this, &MenuBar::PurgeGameListCache); + purge_action->setEnabled(false); + connect(&Settings::Instance(), &Settings::GameListRefreshRequested, purge_action, + [purge_action] { purge_action->setEnabled(false); }); + connect(&Settings::Instance(), &Settings::GameListRefreshCompleted, purge_action, + [purge_action] { purge_action->setEnabled(true); }); view_menu->addSeparator(); view_menu->addAction(tr("Search"), this, &MenuBar::ShowSearch, QKeySequence::Find); } diff --git a/Source/Core/DolphinQt/ToolBar.cpp b/Source/Core/DolphinQt/ToolBar.cpp index bdcbc0a4bb..5205bff5a1 100644 --- a/Source/Core/DolphinQt/ToolBar.cpp +++ b/Source/Core/DolphinQt/ToolBar.cpp @@ -46,6 +46,8 @@ ToolBar::ToolBar(QWidget* parent) : QToolBar(parent) connect(&Settings::Instance(), &Settings::WidgetLockChanged, this, [this](bool locked) { setMovable(!locked); }); + connect(&Settings::Instance(), &Settings::GameListRefreshRequested, this, + [this] { m_refresh_action->setEnabled(false); }); connect(&Settings::Instance(), &Settings::GameListRefreshCompleted, this, [this] { m_refresh_action->setEnabled(true); }); @@ -112,10 +114,8 @@ void ToolBar::MakeActions() m_set_pc_action = addAction(tr("Set PC"), this, &ToolBar::SetPCPressed); m_open_action = addAction(tr("Open"), this, &ToolBar::OpenPressed); - m_refresh_action = addAction(tr("Refresh"), [this] { - m_refresh_action->setEnabled(false); - emit RefreshPressed(); - }); + m_refresh_action = addAction(tr("Refresh"), [this] { emit RefreshPressed(); }); + m_refresh_action->setEnabled(false); addSeparator();