From adf2cd4252482e5d77f43f171cc40f01832ec062 Mon Sep 17 00:00:00 2001 From: spycrab Date: Fri, 7 Jul 2017 08:16:28 +0200 Subject: [PATCH] Qt: Fix "Install WAD" being enabled while emulation is running --- Source/Core/DolphinQt2/GameList/GameList.cpp | 21 +++++++++++++++++--- Source/Core/DolphinQt2/GameList/GameList.h | 2 ++ Source/Core/DolphinQt2/MainWindow.cpp | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt2/GameList/GameList.cpp b/Source/Core/DolphinQt2/GameList/GameList.cpp index d3e7dfcac4..daadb38f02 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.cpp +++ b/Source/Core/DolphinQt2/GameList/GameList.cpp @@ -18,6 +18,7 @@ #include "Common/FileUtil.h" #include "Core/ConfigManager.h" +#include "Core/Core.h" #include "DiscIO/Blob.h" #include "DiscIO/Enums.h" @@ -154,10 +155,24 @@ void GameList::ShowContextMenu(const QPoint&) } if (platform == DiscIO::Platform::WII_WAD) { - menu->addAction(tr("Install to the NAND"), this, SLOT(InstallWAD())); + QAction* wad_install_action = new QAction(tr("Install to the NAND"), menu); + QAction* wad_uninstall_action = new QAction(tr("Uninstall from the NAND"), menu); - if (GameFile(game).IsInstalled()) - menu->addAction(tr("Uninstall from the NAND"), this, SLOT(UninstallWAD())); + connect(wad_install_action, &QAction::triggered, this, &GameList::InstallWAD); + connect(wad_uninstall_action, &QAction::triggered, this, &GameList::UninstallWAD); + + for (QAction* a : {wad_install_action, wad_uninstall_action}) + { + connect(this, &GameList::EmulationStarted, a, [a] { a->setEnabled(false); }); + a->setEnabled(!Core::IsRunning()); + menu->addAction(a); + } + + connect(this, &GameList::EmulationStopped, wad_install_action, + [wad_install_action] { wad_install_action->setEnabled(true); }); + connect(this, &GameList::EmulationStopped, wad_uninstall_action, [wad_uninstall_action, game] { + wad_uninstall_action->setEnabled(GameFile(game).IsInstalled()); + }); menu->addSeparator(); } diff --git a/Source/Core/DolphinQt2/GameList/GameList.h b/Source/Core/DolphinQt2/GameList/GameList.h index ae4e6edf74..da0b352358 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.h +++ b/Source/Core/DolphinQt2/GameList/GameList.h @@ -42,6 +42,8 @@ private slots: signals: void GameSelected(); + void EmulationStarted(); + void EmulationStopped(); private: void MakeTableView(); diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 59eff4da6d..a4137af20e 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -249,6 +249,8 @@ void MainWindow::ConnectToolBar() void MainWindow::ConnectGameList() { connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play); + connect(this, &MainWindow::EmulationStarted, m_game_list, &GameList::EmulationStarted); + connect(this, &MainWindow::EmulationStopped, m_game_list, &GameList::EmulationStopped); } void MainWindow::ConnectRenderWidget()