Add Delete LLVM Cache option

This commit is contained in:
Nekotekina 2017-10-31 23:41:09 +03:00
parent db5c2500c2
commit 0b788f5b43

View File

@ -632,6 +632,7 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
QAction* removeGame = myMenu.addAction(tr("&Remove"));
QAction* removeConfig = myMenu.addAction(tr("&Remove Custom Configuration"));
QAction* deleteShadersCache = myMenu.addAction(tr("&Delete Shaders Cache"));
QAction* deleteLLVMCache = myMenu.addAction(tr("&Delete LLVM Cache"));
myMenu.addSeparator();
QAction* openGameFolder = myMenu.addAction(tr("&Open Install Folder"));
QAction* openConfig = myMenu.addAction(tr("&Open Config Folder"));
@ -672,6 +673,31 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
{
DeleteShadersCache(row);
});
connect(deleteLLVMCache, &QAction::triggered, [=]()
{
if (QMessageBox::question(this, tr("Confirm Delete"), tr("Delete LLVM cache?")) == QMessageBox::Yes)
{
const std::string config_base_dir = fs::get_config_dir() + "data/" + m_game_data[row].info.serial;
for (auto&& subdir : fs::dir{config_base_dir})
{
if (!subdir.is_directory || subdir.name == "." || subdir.name == "..")
{
continue;
}
for (auto&& entry : fs::dir{config_base_dir + "/" + subdir.name})
{
if (entry.name.size() >= 4 && entry.name.compare(entry.name.size() - 4, 4, ".obj", 4) == 0)
{
fs::remove_file(config_base_dir + "/" + subdir.name + "/" + entry.name);
}
}
}
}
});
connect(openGameFolder, &QAction::triggered, [=]()
{
open_dir(currGame.path);