From e623c13400a3cc43e564c0e00b85a21aeefe84dd Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Tue, 26 Dec 2017 23:15:21 +0200 Subject: Add clear overwrite option --- src/mainwindow.cpp | 26 ++++++++++++++++++++++++++ src/mainwindow.h | 1 + 2 files changed, 27 insertions(+) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 263a2984..8871075f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2636,6 +2636,31 @@ void MainWindow::createModFromOverwrite() m_OrganizerCore.refreshModList(); } +void MainWindow::clearOverwrite() +{ + unsigned int overwriteIndex = ModInfo::findMod([](ModInfo::Ptr mod) -> bool { + std::vector flags = mod->getFlags(); + return std::find(flags.begin(), flags.end(), ModInfo::FLAG_OVERWRITE) + != flags.end(); + }); + + ModInfo::Ptr modInfo = ModInfo::getByIndex(overwriteIndex); + if (modInfo) + { + QDir overwriteDir(modInfo->absolutePath()); + if (QMessageBox::question(this, tr("Are you sure?"), + tr("About to recursively delete:\n") + overwriteDir.absolutePath(), + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) + { + QStringList delList; + for (auto f : overwriteDir.entryList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot)) + delList.push_back(overwriteDir.absoluteFilePath(f)); + shellDelete(delList, true); + updateProblemsButton(); + } + } +} + void MainWindow::cancelModListEditor() { ui->modList->setEnabled(false); @@ -3074,6 +3099,7 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) if (QDir(info->absolutePath()).count() > 2) { menu->addAction(tr("Sync to Mods..."), &m_OrganizerCore, SLOT(syncOverwrite())); menu->addAction(tr("Create Mod..."), this, SLOT(createModFromOverwrite())); + menu->addAction(tr("Clear Overwrite..."), this, SLOT(clearOverwrite())); } } else if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_BACKUP) != flags.end()) { menu->addAction(tr("Restore Backup"), this, SLOT(restoreBackup_clicked())); diff --git a/src/mainwindow.h b/src/mainwindow.h index a4ded688..c9ba170c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -425,6 +425,7 @@ private slots: BSA::EErrorCode extractBSA(BSA::Archive &archive, BSA::Folder::Ptr folder, const QString &destination, QProgressDialog &extractProgress); void createModFromOverwrite(); + void clearOverwrite(); void procError(QProcess::ProcessError error); void procFinished(int exitCode, QProcess::ExitStatus exitStatus); -- cgit v1.3.1