From 5ed700db5d31ec44b3495feb9a52acd53dbcd5c6 Mon Sep 17 00:00:00 2001 From: msuih Date: Sat, 7 Sep 2019 17:39:40 +0300 Subject: [PATCH] Add cache removal to UI --- rpcs3/Emu/System.h | 2 +- rpcs3/rpcs3qt/main_window.cpp | 16 ++++++++++++++++ rpcs3/rpcs3qt/main_window.h | 1 + rpcs3/rpcs3qt/main_window.ui | 7 +++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index cf1dd40bea..660b6a2c0a 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -345,11 +345,11 @@ public: private: static std::string GetEmuDir(); - static std::string GetHdd1Dir(); void LimitCacheSize(); public: static std::string GetHddDir(); + static std::string GetHdd1Dir(); static std::string GetSfoDirFromGamePath(const std::string& game_path, const std::string& user, const std::string& title_id = ""); static std::string GetCustomConfigDir(); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 0358eb3ebd..2776436e77 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -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)) diff --git a/rpcs3/rpcs3qt/main_window.h b/rpcs3/rpcs3qt/main_window.h index d112499e1f..d433be2aea 100644 --- a/rpcs3/rpcs3qt/main_window.h +++ b/rpcs3/rpcs3qt/main_window.h @@ -126,6 +126,7 @@ private: QAction* CreateRecentAction(const q_string_pair& entry, const uint& sc_idx); void BootRecentAction(const QAction* act); void AddRecentAction(const q_string_pair& entry); + void RemoveDiskCache(); q_pair_list m_rg_entries; QList m_recentGameActs; diff --git a/rpcs3/rpcs3qt/main_window.ui b/rpcs3/rpcs3qt/main_window.ui index f0761c3589..ba49c7b14f 100644 --- a/rpcs3/rpcs3qt/main_window.ui +++ b/rpcs3/rpcs3qt/main_window.ui @@ -176,6 +176,8 @@ + + @@ -1001,6 +1003,11 @@ Remove Custom Pad Configurations + + + Remove Disk Cache + +