From 74ec078976fbd64433142e6974f30cc113047c00 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Tue, 10 Nov 2020 21:38:58 +0100 Subject: Replace usage of IPlugin::isActive(). --- src/installationmanager.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/installationmanager.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index e9773a95..06909994 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -78,7 +78,8 @@ static T resolveFunction(QLibrary &lib, const char *name) } InstallationManager::InstallationManager() - : m_ParentWidget(nullptr), + : + m_ParentWidget(nullptr), m_SupportedExtensions({"zip", "rar", "7z", "fomod", "001"}), m_IsRunning(false) { m_ArchiveHandler = CreateArchive(); @@ -106,7 +107,7 @@ InstallationManager::InstallationManager() // Connect the query password slot - This is the only way I found to be able to query user // from a separate thread. We use a BlockingQueuedConnection so that calling passwordRequested() // will block until the end of the slot. - connect(this, &InstallationManager::passwordRequested, + connect(this, &InstallationManager::passwordRequested, this, &InstallationManager::queryPassword, Qt::BlockingQueuedConnection); } @@ -122,6 +123,11 @@ void InstallationManager::setParentWidget(QWidget *widget) } } +void InstallationManager::setPluginContainer(const PluginContainer* pluginContainer) +{ + m_PluginContainer = pluginContainer; +} + void InstallationManager::queryPassword() { m_Password = QInputDialog::getText(m_ParentWidget, tr("Password required"), tr("Password"), QLineEdit::Password); @@ -284,7 +290,7 @@ QStringList InstallationManager::extractFiles(std::vector entry) +QString InstallationManager::createFile(std::shared_ptr entry) { // Use QTemporaryFile to create the temporary file with the given template: QTemporaryFile tempFile(QDir::cleanPath(QDir::tempPath() + QDir::separator() + "mo2-install")); @@ -308,11 +314,11 @@ QString InstallationManager::createFile(std::shared_ptr fileTree) +void InstallationManager::cleanCreatedFiles(std::shared_ptr fileTree) { // We simply have to check if all the entries have fileTree as a parent: for (auto it = std::begin(m_CreatedFiles); it != std::end(m_CreatedFiles); ) { - + // Find the parent - Could this be in FileTreeEntry? bool found = false; { @@ -495,12 +501,12 @@ IPluginInstaller::EInstallResult InstallationManager::doInstall(GuessedValue filesTree = + std::shared_ptr filesTree = archiveOpen ? ArchiveFileTree::makeTree(*m_ArchiveHandler) : nullptr; IPluginInstaller::EInstallResult installResult = IPluginInstaller::RESULT_NOTATTEMPTED; @@ -701,7 +707,7 @@ IPluginInstaller::EInstallResult InstallationManager::install(const QString &fil for (IPluginInstaller *installer : m_Installers) { // don't use inactive installers (installer can't be null here but vc static code analysis thinks it could) - if ((installer == nullptr) || !installer->isActive()) { + if ((installer == nullptr) || !m_PluginContainer->isEnabled(installer)) { continue; } @@ -731,7 +737,7 @@ IPluginInstaller::EInstallResult InstallationManager::install(const QString &fil if (p == nullptr) { throw IncompatibilityException(tr("Invalid file tree returned by plugin.")); } - + // Detach the file tree (this ensure the parent is null and call to path() // stops at this root): p->detach(); @@ -786,7 +792,7 @@ IPluginInstaller::EInstallResult InstallationManager::install(const QString &fil case IPluginInstaller::RESULT_SUCCESSCANCEL: { if (filesTree != nullptr) { auto iniTweakEntry = filesTree->find("INI Tweaks", FileTreeEntry::DIRECTORY); - hasIniTweaks = iniTweakEntry != nullptr + hasIniTweaks = iniTweakEntry != nullptr && !iniTweakEntry->astree()->empty(); } return IPluginInstaller::RESULT_SUCCESS; @@ -860,7 +866,7 @@ QStringList InstallationManager::getSupportedExtensions() const void InstallationManager::notifyInstallationStart(QString const& archive, bool reinstallation, ModInfo::Ptr currentMod) { for (auto* installer : m_Installers) { - if (installer->isActive()) { + if (m_PluginContainer->isEnabled(installer)) { installer->onInstallationStart(archive, reinstallation, currentMod.get()); } } @@ -871,7 +877,7 @@ void InstallationManager::notifyInstallationEnd( ModInfo::Ptr newMod) { for (auto* installer : m_Installers) { - if (installer->isActive()) { + if (m_PluginContainer->isEnabled(installer)) { installer->onInstallationEnd(result, newMod.get()); } } -- cgit v1.3.1