diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-01 21:05:24 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-01 21:07:54 +0100 |
| commit | ad17210d7a6527d50786fbe60758e74e3c62abcb (patch) | |
| tree | 90dd5d382def005e41699ccbb652df0db393727a /src/installationmanager.cpp | |
| parent | 1ec3ab2b8a845f75495b4cacbeb17c86ea137a01 (diff) | |
Compute supported extensions dynamically in installation and download manager.
Diffstat (limited to 'src/installationmanager.cpp')
| -rw-r--r-- | src/installationmanager.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 06909994..078f7088 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -80,7 +80,6 @@ static T resolveFunction(QLibrary &lib, const char *name) InstallationManager::InstallationManager() : m_ParentWidget(nullptr), - m_SupportedExtensions({"zip", "rar", "7z", "fomod", "001"}), m_IsRunning(false) { m_ArchiveHandler = CreateArchive(); if (!m_ArchiveHandler->isValid()) { @@ -606,7 +605,7 @@ IPluginInstaller::EInstallResult InstallationManager::install(const QString &fil ON_BLOCK_EXIT([this]() { m_IsRunning = false; }); QFileInfo fileInfo(fileName); - if (m_SupportedExtensions.find(fileInfo.suffix()) == m_SupportedExtensions.end()) { + if (!getSupportedExtensions().contains(fileInfo.suffix(), Qt::CaseInsensitive)) { reportError(tr("File format \"%1\" not supported").arg(fileInfo.suffix())); return IPluginInstaller::RESULT_FAILED; } @@ -851,16 +850,20 @@ void InstallationManager::registerInstaller(IPluginInstaller *installer) { m_Installers.push_back(installer); installer->setInstallationManager(this); - IPluginInstallerCustom *installerCustom = dynamic_cast<IPluginInstallerCustom*>(installer); - if (installerCustom != nullptr) { - std::set<QString> extensions = installerCustom->supportedExtensions(); - m_SupportedExtensions.insert(extensions.begin(), extensions.end()); - } } QStringList InstallationManager::getSupportedExtensions() const { - return QStringList(std::begin(m_SupportedExtensions), std::end(m_SupportedExtensions)); + std::set<QString, CaseInsensitive> supportedExtensions({ "zip", "rar", "7z", "fomod", "001" }); + for (auto* installer : m_PluginContainer->plugins<IPluginInstaller>()) { + if (m_PluginContainer->isEnabled(installer)) { + if (auto* installerCustom = dynamic_cast<IPluginInstallerCustom*>(installer)) { + std::set<QString> extensions = installerCustom->supportedExtensions(); + supportedExtensions.insert(extensions.begin(), extensions.end()); + } + } + } + return QStringList(supportedExtensions.begin(), supportedExtensions.end()); } void InstallationManager::notifyInstallationStart(QString const& archive, bool reinstallation, ModInfo::Ptr currentMod) |
