diff options
| author | AL <26797547+Al12rs@users.noreply.github.com> | 2020-08-26 02:15:37 +0200 |
|---|---|---|
| committer | AL <26797547+Al12rs@users.noreply.github.com> | 2020-08-26 02:15:37 +0200 |
| commit | c23ee0b1dcd0cdcc15a881a2a6f45d2675e1c0a9 (patch) | |
| tree | df193332286238c22cb28a061c05e69d7b04992a /src | |
| parent | 6f232d566e9a7b67eae0cef4aaa46938072b3c20 (diff) | |
Mark downloads of replaced mods as uninstalled
Diffstat (limited to 'src')
| -rw-r--r-- | src/installationmanager.cpp | 8 | ||||
| -rw-r--r-- | src/installationmanager.h | 7 | ||||
| -rw-r--r-- | src/organizercore.cpp | 2 |
3 files changed, 15 insertions, 2 deletions
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<QString> &modName, bool *merge) const +bool InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *merge) { QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName); @@ -406,6 +406,12 @@ bool InstallationManager::testOverwrite(GuessedValue<QString> &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<QString> &modName, bool *merge = nullptr) const; + virtual bool testOverwrite(MOBase::GuessedValue<QString> &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, |
