diff options
| author | Al12rs <gabriel.cortesi@outlook.com> | 2018-09-07 22:04:03 +0200 |
|---|---|---|
| committer | Al12rs <gabriel.cortesi@outlook.com> | 2018-09-07 22:04:03 +0200 |
| commit | 67fb7e56d3a080844927d4d41764da1e9bb39795 (patch) | |
| tree | 8e17731d26b06e0753092f343a7911d8e5475c0c | |
| parent | 979206228d6bcfd71fb22c6a9b8dd4f54f7b5a75 (diff) | |
Add option to create a Mod backup from the modlist context menu.
| -rw-r--r-- | src/installationmanager.h | 4 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 12 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/installationmanager.h b/src/installationmanager.h index e17aee17..e66184d3 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -147,6 +147,8 @@ public: */
virtual bool testOverwrite(MOBase::GuessedValue<QString> &modName, bool *merge = nullptr) const;
+ QString generateBackupName(const QString &directoryName) const;
+
private:
void queryPassword(QString *password);
@@ -171,7 +173,7 @@ private: bool doInstall(MOBase::GuessedValue<QString> &modName, QString gameName,
int modID, const QString &version, const QString &newestVersion, int categoryID, const QString &repository);
- QString generateBackupName(const QString &directoryName) const;
+ //QString generateBackupName(const QString &directoryName) const;
bool ensureValidModName(MOBase::GuessedValue<QString> &name) const;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 28d561b9..57988663 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2409,6 +2409,16 @@ void MainWindow::reinstallMod_clicked() }
}
+void MainWindow::backupMod_clicked()
+{
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(m_ContextRow);
+ QString backupDirectory = m_OrganizerCore.installationManager()->generateBackupName(modInfo->absolutePath());
+ if (!copyDir(modInfo->absolutePath(), backupDirectory, false)) {
+ QMessageBox::information(this, tr("Failed"),
+ tr("Failed to create backup."));
+ }
+ m_OrganizerCore.refreshModList();
+}
void MainWindow::resumeDownload(int downloadIndex)
{
@@ -3626,6 +3636,8 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) menu->addAction(tr("Rename Mod..."), this, SLOT(renameMod_clicked()));
menu->addAction(tr("Reinstall Mod"), this, SLOT(reinstallMod_clicked()));
menu->addAction(tr("Remove Mod..."), this, SLOT(removeMod_clicked()));
+ menu->addAction(tr("Create Backup"), this, SLOT(backupMod_clicked()));
+
menu->addSeparator();
diff --git a/src/mainwindow.h b/src/mainwindow.h index b3d179e8..0bf3d3c8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -407,6 +407,7 @@ private slots: void restoreBackup_clicked();
void renameMod_clicked();
void removeMod_clicked();
+ void backupMod_clicked();
void reinstallMod_clicked();
void endorse_clicked();
void dontendorse_clicked();
|
