From c23ee0b1dcd0cdcc15a881a2a6f45d2675e1c0a9 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Wed, 26 Aug 2020 02:15:37 +0200 Subject: Mark downloads of replaced mods as uninstalled --- src/installationmanager.cpp | 8 +++++++- src/installationmanager.h | 7 ++++++- src/organizercore.cpp | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index b9f35af8..801b2a67 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -369,7 +369,7 @@ QString InstallationManager::generateBackupName(const QString &directoryName) co } -bool InstallationManager::testOverwrite(GuessedValue &modName, bool *merge) const +bool InstallationManager::testOverwrite(GuessedValue &modName, bool *merge) { QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName); @@ -406,6 +406,12 @@ bool InstallationManager::testOverwrite(GuessedValue &modName, bool *me targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory) + "/" + modName; } } else if (overwriteDialog.action() == QueryOverwriteDialog::ACT_REPLACE) { + unsigned int idx = ModInfo::getIndex(modName); + if (idx != UINT_MAX) { + auto modInfo = ModInfo::getByIndex(idx); + // mark the old install file as uninstalled + emit modReplaced(modInfo->getInstallationFile()); + } // save original settings like categories. Because it makes sense QString metaFilename = targetDirectory + "/meta.ini"; QFile settingsFile(metaFilename); diff --git a/src/installationmanager.h b/src/installationmanager.h index 695f2ed6..b3a7362f 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -185,7 +185,7 @@ public: * @param merge if this value is not null, the value will be set to whether the use chose to merge or replace * @return true if we can proceed with the installation, false if the user canceled or in case of an unrecoverable error */ - virtual bool testOverwrite(MOBase::GuessedValue &modName, bool *merge = nullptr) const; + virtual bool testOverwrite(MOBase::GuessedValue &modName, bool *merge = nullptr); QString generateBackupName(const QString &directoryName) const; @@ -225,6 +225,11 @@ signals: */ void progressUpdate(); + /** + * @brief An existing mod has been replaced with a newly installed one. + */ + void modReplaced(const QString fileName); + private: struct ByPriority { diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 1e2a0aa1..d144c185 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -247,6 +247,8 @@ void OrganizerCore::setUserInterface(IUserInterface* ui) SLOT(modRenamed(QString, QString))); connect(&m_ModList, SIGNAL(modUninstalled(QString)), w, SLOT(modRemoved(QString))); + connect(&m_InstallationManager, SIGNAL(modReplaced(QString)), w, + SLOT(modRemoved(QString))); connect(&m_ModList, SIGNAL(removeSelectedMods()), w, SLOT(removeMod_clicked())); connect(&m_ModList, SIGNAL(clearOverwrite()), w, -- cgit v1.3.1