main: Split removal cases into their individual functions and address feedback
This commit is contained in:
		
							parent
							
								
									85e1facfe6
								
							
						
					
					
						commit
						ef02370816
					
				@ -1396,19 +1396,18 @@ static bool RomFSRawCopy(QProgressDialog& dialog, const FileSys::VirtualDir& src
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type) {
 | 
					void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type) {
 | 
				
			||||||
    QString entry_type;
 | 
					    const QString entry_type = [this, type] {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        switch (type) {
 | 
					        switch (type) {
 | 
				
			||||||
        case InstalledEntryType::Game:
 | 
					        case InstalledEntryType::Game:
 | 
				
			||||||
        entry_type = tr("Contents");
 | 
					            return tr("Contents");
 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
        case InstalledEntryType::Update:
 | 
					        case InstalledEntryType::Update:
 | 
				
			||||||
        entry_type = tr("Update");
 | 
					            return tr("Update");
 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
        case InstalledEntryType::AddOnContent:
 | 
					        case InstalledEntryType::AddOnContent:
 | 
				
			||||||
        entry_type = tr("DLC");
 | 
					            return tr("DLC");
 | 
				
			||||||
        break;
 | 
					        default:
 | 
				
			||||||
 | 
					            return QString{};
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (QMessageBox::question(
 | 
					    if (QMessageBox::question(
 | 
				
			||||||
            this, tr("Remove Entry"), tr("Remove Installed Game %1?").arg(entry_type),
 | 
					            this, tr("Remove Entry"), tr("Remove Installed Game %1?").arg(entry_type),
 | 
				
			||||||
@ -1416,11 +1415,28 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool res;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    switch (type) {
 | 
					    switch (type) {
 | 
				
			||||||
    case InstalledEntryType::Game:
 | 
					    case InstalledEntryType::Game:
 | 
				
			||||||
        res = Core::System::GetInstance()
 | 
					        RemoveBaseContent(program_id, entry_type);
 | 
				
			||||||
 | 
					        [[fallthrough]];
 | 
				
			||||||
 | 
					    case InstalledEntryType::Update:
 | 
				
			||||||
 | 
					        RemoveUpdateContent(program_id, entry_type);
 | 
				
			||||||
 | 
					        if (type == InstalledEntryType::Game) {
 | 
				
			||||||
 | 
					            [[fallthrough]];
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    case InstalledEntryType::AddOnContent:
 | 
				
			||||||
 | 
					        RemoveAddOnContent(program_id, entry_type);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    game_list->PopulateAsync(UISettings::values.game_dirs);
 | 
				
			||||||
 | 
					    FileUtil::DeleteDirRecursively(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP +
 | 
				
			||||||
 | 
					                                   "game_list");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) {
 | 
				
			||||||
 | 
					    const auto res = Core::System::GetInstance()
 | 
				
			||||||
                         .GetFileSystemController()
 | 
					                         .GetFileSystemController()
 | 
				
			||||||
                         .GetUserNANDContents()
 | 
					                         .GetUserNANDContents()
 | 
				
			||||||
                         ->RemoveExistingEntry(program_id);
 | 
					                         ->RemoveExistingEntry(program_id);
 | 
				
			||||||
@ -1433,9 +1449,10 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT
 | 
				
			|||||||
            this, tr("Error Removing %1").arg(entry_type),
 | 
					            this, tr("Error Removing %1").arg(entry_type),
 | 
				
			||||||
            tr("The base game is not installed in the NAND and cannot be removed."));
 | 
					            tr("The base game is not installed in the NAND and cannot be removed."));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        [[fallthrough]];
 | 
					}
 | 
				
			||||||
    case InstalledEntryType::Update:
 | 
					
 | 
				
			||||||
        res = Core::System::GetInstance()
 | 
					void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type) {
 | 
				
			||||||
 | 
					    const auto res = Core::System::GetInstance()
 | 
				
			||||||
                         .GetFileSystemController()
 | 
					                         .GetFileSystemController()
 | 
				
			||||||
                         .GetUserNANDContents()
 | 
					                         .GetUserNANDContents()
 | 
				
			||||||
                         ->RemoveExistingEntry(program_id | 0x800);
 | 
					                         ->RemoveExistingEntry(program_id | 0x800);
 | 
				
			||||||
@ -1447,20 +1464,16 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT
 | 
				
			|||||||
        QMessageBox::warning(this, tr("Error Removing %1").arg(entry_type),
 | 
					        QMessageBox::warning(this, tr("Error Removing %1").arg(entry_type),
 | 
				
			||||||
                             tr("There is no update installed for this title."));
 | 
					                             tr("There is no update installed for this title."));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (type == InstalledEntryType::Game) {
 | 
					void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type) {
 | 
				
			||||||
            [[fallthrough]];
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    case InstalledEntryType::AddOnContent:
 | 
					 | 
				
			||||||
    u32 count{};
 | 
					    u32 count{};
 | 
				
			||||||
    const auto dlc_entries = Core::System::GetInstance().GetContentProvider().ListEntriesFilter(
 | 
					    const auto dlc_entries = Core::System::GetInstance().GetContentProvider().ListEntriesFilter(
 | 
				
			||||||
        FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
 | 
					        FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const auto& entry : dlc_entries) {
 | 
					    for (const auto& entry : dlc_entries) {
 | 
				
			||||||
        if ((entry.title_id & DLC_BASE_TITLE_ID_MASK) == program_id) {
 | 
					        if ((entry.title_id & DLC_BASE_TITLE_ID_MASK) == program_id) {
 | 
				
			||||||
                res = Core::System::GetInstance()
 | 
					            const auto res = Core::System::GetInstance()
 | 
				
			||||||
                                 .GetFileSystemController()
 | 
					                                 .GetFileSystemController()
 | 
				
			||||||
                                 .GetUserNANDContents()
 | 
					                                 .GetUserNANDContents()
 | 
				
			||||||
                                 ->RemoveExistingEntry(entry.title_id);
 | 
					                                 ->RemoveExistingEntry(entry.title_id);
 | 
				
			||||||
@ -1473,29 +1486,24 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT
 | 
				
			|||||||
    if (count == 0) {
 | 
					    if (count == 0) {
 | 
				
			||||||
        QMessageBox::warning(this, tr("Error Removing %1").arg(entry_type),
 | 
					        QMessageBox::warning(this, tr("Error Removing %1").arg(entry_type),
 | 
				
			||||||
                             tr("There are no DLC installed for this title."));
 | 
					                             tr("There are no DLC installed for this title."));
 | 
				
			||||||
            break;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QMessageBox::information(this, tr("Successfully Removed"),
 | 
					    QMessageBox::information(this, tr("Successfully Removed"),
 | 
				
			||||||
                             tr("Successfully removed %1 installed DLC.").arg(count));
 | 
					                             tr("Successfully removed %1 installed DLC.").arg(count));
 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    game_list->PopulateAsync(UISettings::values.game_dirs);
 | 
					 | 
				
			||||||
    FileUtil::DeleteDirRecursively(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP +
 | 
					 | 
				
			||||||
                                   "game_list");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target) {
 | 
					void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target) {
 | 
				
			||||||
    QString question;
 | 
					    const QString question = [this, target] {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        switch (target) {
 | 
					        switch (target) {
 | 
				
			||||||
        case GameListRemoveTarget::ShaderCache:
 | 
					        case GameListRemoveTarget::ShaderCache:
 | 
				
			||||||
        question = tr("Delete Transferable Shader Cache?");
 | 
					            return tr("Delete Transferable Shader Cache?");
 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
        case GameListRemoveTarget::CustomConfiguration:
 | 
					        case GameListRemoveTarget::CustomConfiguration:
 | 
				
			||||||
        question = tr("Remove Custom Game Configuration?");
 | 
					            return tr("Remove Custom Game Configuration?");
 | 
				
			||||||
        break;
 | 
					        default:
 | 
				
			||||||
 | 
					            return QString{};
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (QMessageBox::question(this, tr("Remove File"), question, QMessageBox::Yes | QMessageBox::No,
 | 
					    if (QMessageBox::question(this, tr("Remove File"), question, QMessageBox::Yes | QMessageBox::No,
 | 
				
			||||||
                              QMessageBox::No) != QMessageBox::Yes) {
 | 
					                              QMessageBox::No) != QMessageBox::Yes) {
 | 
				
			||||||
@ -1503,12 +1511,20 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (target) {
 | 
					    switch (target) {
 | 
				
			||||||
    case GameListRemoveTarget::ShaderCache: {
 | 
					    case GameListRemoveTarget::ShaderCache:
 | 
				
			||||||
 | 
					        RemoveTransferableShaderCache(program_id);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case GameListRemoveTarget::CustomConfiguration:
 | 
				
			||||||
 | 
					        RemoveCustomConfiguration(program_id);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void GMainWindow::RemoveTransferableShaderCache(u64 program_id) {
 | 
				
			||||||
    const QString shader_dir =
 | 
					    const QString shader_dir =
 | 
				
			||||||
        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir));
 | 
					        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir));
 | 
				
			||||||
    const QString transferable_shader_cache_folder_path =
 | 
					    const QString transferable_shader_cache_folder_path =
 | 
				
			||||||
            shader_dir + QStringLiteral("opengl") + QDir::separator() +
 | 
					        shader_dir + QStringLiteral("opengl") + QDir::separator() + QStringLiteral("transferable");
 | 
				
			||||||
            QStringLiteral("transferable");
 | 
					 | 
				
			||||||
    const QString transferable_shader_cache_file_path =
 | 
					    const QString transferable_shader_cache_file_path =
 | 
				
			||||||
        transferable_shader_cache_folder_path + QDir::separator() +
 | 
					        transferable_shader_cache_folder_path + QDir::separator() +
 | 
				
			||||||
        QString::fromStdString(fmt::format("{:016X}.bin", program_id));
 | 
					        QString::fromStdString(fmt::format("{:016X}.bin", program_id));
 | 
				
			||||||
@ -1516,7 +1532,7 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
 | 
				
			|||||||
    if (!QFile::exists(transferable_shader_cache_file_path)) {
 | 
					    if (!QFile::exists(transferable_shader_cache_file_path)) {
 | 
				
			||||||
        QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"),
 | 
					        QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"),
 | 
				
			||||||
                             tr("A shader cache for this title does not exist."));
 | 
					                             tr("A shader cache for this title does not exist."));
 | 
				
			||||||
            break;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (QFile::remove(transferable_shader_cache_file_path)) {
 | 
					    if (QFile::remove(transferable_shader_cache_file_path)) {
 | 
				
			||||||
@ -1526,9 +1542,9 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
 | 
				
			|||||||
        QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"),
 | 
					        QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"),
 | 
				
			||||||
                             tr("Failed to remove the transferable shader cache."));
 | 
					                             tr("Failed to remove the transferable shader cache."));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        break;
 | 
					}
 | 
				
			||||||
    }
 | 
					
 | 
				
			||||||
    case GameListRemoveTarget::CustomConfiguration: {
 | 
					void GMainWindow::RemoveCustomConfiguration(u64 program_id) {
 | 
				
			||||||
    const QString config_dir =
 | 
					    const QString config_dir =
 | 
				
			||||||
        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir));
 | 
					        QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir));
 | 
				
			||||||
    const QString custom_config_file_path =
 | 
					    const QString custom_config_file_path =
 | 
				
			||||||
@ -1537,7 +1553,7 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
 | 
				
			|||||||
    if (!QFile::exists(custom_config_file_path)) {
 | 
					    if (!QFile::exists(custom_config_file_path)) {
 | 
				
			||||||
        QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
 | 
					        QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
 | 
				
			||||||
                             tr("A custom configuration for this title does not exist."));
 | 
					                             tr("A custom configuration for this title does not exist."));
 | 
				
			||||||
            break;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (QFile::remove(custom_config_file_path)) {
 | 
					    if (QFile::remove(custom_config_file_path)) {
 | 
				
			||||||
@ -1547,9 +1563,6 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
 | 
				
			|||||||
        QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
 | 
					        QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
 | 
				
			||||||
                             tr("Failed to remove the custom game configuration."));
 | 
					                             tr("Failed to remove the custom game configuration."));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path) {
 | 
					void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path) {
 | 
				
			||||||
 | 
				
			|||||||
@ -233,6 +233,11 @@ private slots:
 | 
				
			|||||||
    void OnLanguageChanged(const QString& locale);
 | 
					    void OnLanguageChanged(const QString& locale);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
					    void RemoveBaseContent(u64 program_id, const QString& entry_type);
 | 
				
			||||||
 | 
					    void RemoveUpdateContent(u64 program_id, const QString& entry_type);
 | 
				
			||||||
 | 
					    void RemoveAddOnContent(u64 program_id, const QString& entry_type);
 | 
				
			||||||
 | 
					    void RemoveTransferableShaderCache(u64 program_id);
 | 
				
			||||||
 | 
					    void RemoveCustomConfiguration(u64 program_id);
 | 
				
			||||||
    std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
 | 
					    std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
 | 
				
			||||||
    InstallResult InstallNSPXCI(const QString& filename);
 | 
					    InstallResult InstallNSPXCI(const QString& filename);
 | 
				
			||||||
    InstallResult InstallNCA(const QString& filename);
 | 
					    InstallResult InstallNCA(const QString& filename);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user