Add cache removal to UI

This commit is contained in:
msuih 2019-09-07 17:39:40 +03:00 committed by Megamouse
parent 84867b0848
commit 5ed700db5d
4 changed files with 25 additions and 1 deletions

View file

@ -1186,6 +1186,8 @@ void main_window::CreateConnects()
connect(ui->batchRemoveCustomConfigurationsAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchRemoveCustomConfigurations);
connect(ui->batchRemoveCustomPadConfigurationsAct, &QAction::triggered, m_gameListFrame, &game_list_frame::BatchRemoveCustomPadConfigurations);
connect(ui->removeDiskCacheAct, &QAction::triggered, this, &main_window::RemoveDiskCache);
connect(ui->sysPauseAct, &QAction::triggered, this, &main_window::OnPlayOrPause);
connect(ui->sysStopAct, &QAction::triggered, [=]() { Emu.Stop(); });
connect(ui->sysRebootAct, &QAction::triggered, [=]() { Emu.Restart(); });
@ -1637,6 +1639,20 @@ void main_window::SetIconSizeActions(int idx)
ui->setIconSizeLargeAct->setChecked(true);
}
void main_window::RemoveDiskCache()
{
std::string cacheDir = Emulator::GetHdd1Dir() + "/cache";
if (fs::is_dir(cacheDir) && fs::remove_all(cacheDir, false))
{
QMessageBox::information(this, tr("Cache Cleared"), tr("Disk cache was cleared successfully"));
}
else
{
QMessageBox::warning(this, tr("Error"), tr("Could not remove disk cache"));
}
}
void main_window::keyPressEvent(QKeyEvent *keyEvent)
{
if (((keyEvent->modifiers() & Qt::AltModifier) && keyEvent->key() == Qt::Key_Return) || (isFullScreen() && keyEvent->key() == Qt::Key_Escape))