From d9a8e67598b88d13b09d3e43c8f40418dea1f2a5 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Mon, 21 Sep 2020 21:36:09 +0200 Subject: Add IPluginInstaller onInstallationStart and onInstallationEnd callbacks. --- src/mainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b597af37..7759b057 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2319,7 +2319,7 @@ void MainWindow::installMod(QString fileName) if (fileName.isEmpty()) { return; } else { - m_OrganizerCore.installMod(fileName, QString()); + m_OrganizerCore.installMod(fileName, nullptr, QString()); } } catch (const std::exception &e) { reportError(e.what()); @@ -2808,7 +2808,7 @@ void MainWindow::reinstallMod_clicked() fullInstallationFile = m_OrganizerCore.downloadManager()->getOutputDirectory() + "/" + installationFile; } if (QFile::exists(fullInstallationFile)) { - m_OrganizerCore.installMod(fullInstallationFile, modInfo->name()); + m_OrganizerCore.installMod(fullInstallationFile, modInfo, modInfo->name()); } else { QMessageBox::information(this, tr("Failed"), tr("Installation file no longer exists")); } -- cgit v1.3.1 From 8980153a2cba833cf8817e15e814bc7b6c2d2230 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Tue, 22 Sep 2020 22:03:16 +0200 Subject: Add 'reinstallation' parameter to onInstallationStart(). --- src/installationmanager.cpp | 4 ++-- src/installationmanager.h | 6 ++++-- src/mainwindow.cpp | 4 ++-- src/organizercore.cpp | 5 +++-- src/organizercore.h | 2 +- src/organizerproxy.cpp | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index b60c8704..f50a4157 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -869,10 +869,10 @@ QStringList InstallationManager::getSupportedExtensions() const return QStringList(std::begin(m_SupportedExtensions), std::end(m_SupportedExtensions)); } -void InstallationManager::notifyInstallationStart(QString const& archive, ModInfo::Ptr currentMod) +void InstallationManager::notifyInstallationStart(QString const& archive, bool reinstallation, ModInfo::Ptr currentMod) { for (auto* installer : m_Installers) { - installer->onInstallationStart(archive, currentMod.get()); + installer->onInstallationStart(archive, reinstallation, currentMod.get()); } } diff --git a/src/installationmanager.h b/src/installationmanager.h index 4e4f4346..149295a6 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -68,9 +68,11 @@ public: * @brief Notify all installer plugins that an installation is about to start. * * @param archive Path to the archive that is going to be installed. - * @param currentMod The mod being re-installed, or a null pointer for new installation. + * @param reinstallation True if this is a reinstallation, false otherwise. + * @param currentMod The installed mod corresponding to the archive being installed, or a null + * if there is no such mod. */ - void notifyInstallationStart(QString const& archive, ModInfo::Ptr currentMod); + void notifyInstallationStart(QString const& archive, bool reinstallation, ModInfo::Ptr currentMod); /** * @brief notify all installer plugins that an installation has ended. diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7759b057..24f00f48 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2319,7 +2319,7 @@ void MainWindow::installMod(QString fileName) if (fileName.isEmpty()) { return; } else { - m_OrganizerCore.installMod(fileName, nullptr, QString()); + m_OrganizerCore.installMod(fileName, false, nullptr, QString()); } } catch (const std::exception &e) { reportError(e.what()); @@ -2808,7 +2808,7 @@ void MainWindow::reinstallMod_clicked() fullInstallationFile = m_OrganizerCore.downloadManager()->getOutputDirectory() + "/" + installationFile; } if (QFile::exists(fullInstallationFile)) { - m_OrganizerCore.installMod(fullInstallationFile, modInfo, modInfo->name()); + m_OrganizerCore.installMod(fullInstallationFile, true, modInfo, modInfo->name()); } else { QMessageBox::information(this, tr("Failed"), tr("Installation file no longer exists")); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 37ec4b22..d33b4e39 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -713,6 +713,7 @@ QString OrganizerCore::pluginDataPath() const } MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, + bool reinstallation, ModInfo::Ptr currentMod, const QString &initModName) { @@ -734,7 +735,7 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, } m_CurrentProfile->writeModlistNow(); m_InstallationManager.setModsDirectory(m_Settings.paths().mods()); - m_InstallationManager.notifyInstallationStart(fileName, currentMod); + m_InstallationManager.notifyInstallationStart(fileName, reinstallation, currentMod); auto result = m_InstallationManager.install(fileName, modName, hasIniTweaks); if (result == IPluginInstaller::RESULT_SUCCESS) { MessageDialog::showMessage(tr("Installation successful"), @@ -816,7 +817,7 @@ void OrganizerCore::installDownload(int index) bool hasIniTweaks = false; m_InstallationManager.setModsDirectory(m_Settings.paths().mods()); - m_InstallationManager.notifyInstallationStart(fileName, currentMod); + m_InstallationManager.notifyInstallationStart(fileName, false, currentMod); auto result = m_InstallationManager.install(fileName, modName, hasIniTweaks); if (result == IPluginInstaller::RESULT_SUCCESS) { MessageDialog::showMessage(tr("Installation successful"), diff --git a/src/organizercore.h b/src/organizercore.h index 15acebdb..813bf084 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -309,7 +309,7 @@ public: QVariant persistent(const QString &pluginName, const QString &key, const QVariant &def) const; void setPersistent(const QString &pluginName, const QString &key, const QVariant &value, bool sync); QString pluginDataPath() const; - virtual MOBase::IModInterface *installMod(const QString &fileName, ModInfo::Ptr currentMod, const QString &initModName); + virtual MOBase::IModInterface *installMod(const QString &fileName, bool reinstallation, ModInfo::Ptr currentMod, const QString &initModName); QString resolvePath(const QString &fileName) const; QStringList listDirectories(const QString &directoryName) const; QStringList findFiles(const QString &path, const std::function &filter) const; diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 8e2b8a35..a5047b43 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -208,7 +208,7 @@ void OrganizerProxy::refreshModList(bool saveChanges) IModInterface *OrganizerProxy::installMod(const QString &fileName, const QString &nameSuggestion) { - return m_Proxied->installMod(fileName, nullptr, nameSuggestion); + return m_Proxied->installMod(fileName, false, nullptr, nameSuggestion); } QString OrganizerProxy::resolvePath(const QString &fileName) const -- cgit v1.3.1