**Refresh** and **Purge Game List Cache** now correctly enabled/disabled as notified by GameListRefreshRequested and GameListRefreshCompleted.

This commit is contained in:
Christian Aguilera 2020-09-27 02:40:56 +02:00
parent bada677c5a
commit 4ca92464c0
3 changed files with 13 additions and 6 deletions

View File

@ -156,6 +156,7 @@ void GameTracker::StartInternal()
m_cache.Save(); m_cache.Save();
QueueOnObject(this, [] { Settings::Instance().NotifyMetadataRefreshComplete(); }); QueueOnObject(this, [] { Settings::Instance().NotifyMetadataRefreshComplete(); });
QueueOnObject(this, [] { Settings::Instance().NotifyRefreshGameListComplete(); });
} }
bool GameTracker::AddPath(const QString& dir) bool GameTracker::AddPath(const QString& dir)
@ -347,5 +348,5 @@ void GameTracker::LoadGame(const QString& path)
void GameTracker::PurgeCache() void GameTracker::PurgeCache()
{ {
m_load_thread.EmplaceItem(Command{CommandType::PurgeCache, {}}); m_load_thread.EmplaceItem(Command{CommandType::PurgeCache, {}});
RefreshAll(); Settings::Instance().RefreshGameList();
} }

View File

@ -506,7 +506,13 @@ void MenuBar::AddViewMenu()
AddShowRegionsMenu(view_menu); AddShowRegionsMenu(view_menu);
view_menu->addSeparator(); view_menu->addSeparator();
QAction* const purge_action =
view_menu->addAction(tr("Purge Game List Cache"), this, &MenuBar::PurgeGameListCache); 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->addSeparator();
view_menu->addAction(tr("Search"), this, &MenuBar::ShowSearch, QKeySequence::Find); view_menu->addAction(tr("Search"), this, &MenuBar::ShowSearch, QKeySequence::Find);
} }

View File

@ -46,6 +46,8 @@ ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
connect(&Settings::Instance(), &Settings::WidgetLockChanged, this, connect(&Settings::Instance(), &Settings::WidgetLockChanged, this,
[this](bool locked) { setMovable(!locked); }); [this](bool locked) { setMovable(!locked); });
connect(&Settings::Instance(), &Settings::GameListRefreshRequested, this,
[this] { m_refresh_action->setEnabled(false); });
connect(&Settings::Instance(), &Settings::GameListRefreshCompleted, this, connect(&Settings::Instance(), &Settings::GameListRefreshCompleted, this,
[this] { m_refresh_action->setEnabled(true); }); [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_set_pc_action = addAction(tr("Set PC"), this, &ToolBar::SetPCPressed);
m_open_action = addAction(tr("Open"), this, &ToolBar::OpenPressed); m_open_action = addAction(tr("Open"), this, &ToolBar::OpenPressed);
m_refresh_action = addAction(tr("Refresh"), [this] { m_refresh_action = addAction(tr("Refresh"), [this] { emit RefreshPressed(); });
m_refresh_action->setEnabled(false); m_refresh_action->setEnabled(false);
emit RefreshPressed();
});
addSeparator(); addSeparator();