diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2020-11-18 10:01:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-18 10:01:27 +0100 |
| commit | ddba54382aab3cb5548485d14c85e2611272f3cb (patch) | |
| tree | e3b1aa7f86c3d6852f2f749e40ff61971c0961b3 /src/installationmanager.cpp | |
| parent | 06686403382a98d23685232d404dfe5837ffb8a1 (diff) | |
| parent | 61554d3df7be909acf6609b4b7465b03d7f16081 (diff) | |
Merge pull request #1292 from Holt59/iplugin-isactive-refactoring
IPlugin::isActive refactoring
Diffstat (limited to 'src/installationmanager.cpp')
| -rw-r--r-- | src/installationmanager.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
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<std::shared_ptr<const } -QString InstallationManager::createFile(std::shared_ptr<const MOBase::FileTreeEntry> entry) +QString InstallationManager::createFile(std::shared_ptr<const MOBase::FileTreeEntry> 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<const MOBase::FileTreeEn return QDir::toNativeSeparators(absPath); } -void InstallationManager::cleanCreatedFiles(std::shared_ptr<const MOBase::IFileTree> fileTree) +void InstallationManager::cleanCreatedFiles(std::shared_ptr<const MOBase::IFileTree> 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<QSt if (QFile::exists(destPath)) { QFile::remove(destPath); } - + QDir dir = QFileInfo(destPath).absoluteDir(); if (!dir.exists()) { dir.mkpath("."); } - + QFile::copy(p.second, destPath); } @@ -691,7 +697,7 @@ IPluginInstaller::EInstallResult InstallationManager::install(const QString &fil } ON_BLOCK_EXIT(std::bind(&InstallationManager::postInstallCleanup, this)); - std::shared_ptr<IFileTree> filesTree = + std::shared_ptr<IFileTree> 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()); } } |
