Qt: Present game removal failure to the user

All the required information was already there,
but UI always reported success
This commit is contained in:
Silent 2020-01-25 16:19:25 +01:00 committed by Megamouse
parent e4ba096190
commit 331c1a394a
1 changed files with 18 additions and 10 deletions

View File

@ -1065,18 +1065,26 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
mb->deleteLater();
if (mb->exec() == QMessageBox::Yes)
{
if (mb->checkBox()->isChecked())
const bool remove_caches = mb->checkBox()->isChecked();
if (fs::remove_all(currGame.path))
{
RemoveShadersCache(cache_base_dir);
RemovePPUCache(cache_base_dir);
RemoveSPUCache(cache_base_dir);
RemoveCustomConfiguration(currGame.serial);
RemoveCustomPadConfiguration(currGame.serial);
if (remove_caches)
{
RemoveShadersCache(cache_base_dir);
RemovePPUCache(cache_base_dir);
RemoveSPUCache(cache_base_dir);
RemoveCustomConfiguration(currGame.serial);
RemoveCustomPadConfiguration(currGame.serial);
}
m_game_data.erase(std::remove(m_game_data.begin(), m_game_data.end(), gameinfo), m_game_data.end());
LOG_SUCCESS(GENERAL, "Removed %s %s in %s", currGame.category, currGame.name, currGame.path);
Refresh(true);
}
else
{
LOG_ERROR(GENERAL, "Failed to remove %s %s in %s (%s)", currGame.category, currGame.name, currGame.path, fs::g_tls_error);
QMessageBox::critical(this, tr("Failure!"), tr(remove_caches ? "Failed to remove %0 from drive!\nPath: %1\nCaches and custom configs have been left intact." : "Failed to remove %0 from drive!\nPath: %1").arg(name).arg(qstr(currGame.path)));
}
fs::remove_all(currGame.path);
m_game_data.erase(std::remove(m_game_data.begin(), m_game_data.end(), gameinfo), m_game_data.end());
LOG_SUCCESS(GENERAL, "Removed %s %s in %s", currGame.category, currGame.name, currGame.path);
Refresh(true);
}
});
connect(openGameFolder, &QAction::triggered, [=]()