Qt: Fix "Install WAD" being enabled while emulation is running

This commit is contained in:
spycrab 2017-07-07 08:16:28 +02:00
parent c941cd6aa9
commit adf2cd4252
3 changed files with 22 additions and 3 deletions

View file

@ -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();
}

View file

@ -42,6 +42,8 @@ private slots:
signals:
void GameSelected();
void EmulationStarted();
void EmulationStopped();
private:
void MakeTableView();

View file

@ -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()