diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-09-21 21:36:09 +0200 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-09-21 21:36:09 +0200 |
| commit | d9a8e67598b88d13b09d3e43c8f40418dea1f2a5 (patch) | |
| tree | 4a80483a343d2016f20033a95a66edf71d24d076 /src/organizercore.cpp | |
| parent | 7563e4a517c93aeb65955985887dd0fbdbe224c7 (diff) | |
Add IPluginInstaller onInstallationStart and onInstallationEnd callbacks.
Diffstat (limited to 'src/organizercore.cpp')
| -rw-r--r-- | src/organizercore.cpp | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 815c80c2..37ec4b22 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -713,6 +713,7 @@ QString OrganizerCore::pluginDataPath() const } MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, + ModInfo::Ptr currentMod, const QString &initModName) { if (m_CurrentProfile == nullptr) { @@ -733,7 +734,9 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, } m_CurrentProfile->writeModlistNow(); m_InstallationManager.setModsDirectory(m_Settings.paths().mods()); - if (m_InstallationManager.install(fileName, modName, hasIniTweaks) == IPluginInstaller::RESULT_SUCCESS) { + m_InstallationManager.notifyInstallationStart(fileName, currentMod); + auto result = m_InstallationManager.install(fileName, modName, hasIniTweaks); + if (result == IPluginInstaller::RESULT_SUCCESS) { MessageDialog::showMessage(tr("Installation successful"), qApp->activeWindow()); refreshModList(); @@ -758,18 +761,22 @@ MOBase::IModInterface *OrganizerCore::installMod(const QString &fileName, } m_ModInstalled(modName); m_DownloadManager.markInstalled(fileName); + m_InstallationManager.notifyInstallationEnd(result, modInfo); emit modInstalled(modName); return modInfo.data(); } else { reportError(tr("mod not found: %1").arg(qUtf8Printable(modName))); } - } else if (m_InstallationManager.wasCancelled()) { - QMessageBox::information(qApp->activeWindow(), tr("Extraction cancelled"), - tr("The installation was cancelled while extracting files. " - "If this was prior to a FOMOD setup, this warning may be ignored. " - "However, if this was during installation, the mod will likely be missing files."), - QMessageBox::Ok); - refreshModList(); + } else { + m_InstallationManager.notifyInstallationEnd(result, nullptr); + if (m_InstallationManager.wasCancelled()) { + QMessageBox::information(qApp->activeWindow(), tr("Extraction cancelled"), + tr("The installation was cancelled while extracting files. " + "If this was prior to a FOMOD setup, this warning may be ignored. " + "However, if this was during installation, the mod will likely be missing files."), + QMessageBox::Ok); + refreshModList(); + } } return nullptr; } @@ -788,6 +795,7 @@ void OrganizerCore::installDownload(int index) QString gameName = m_DownloadManager.getGameName(index); int modID = m_DownloadManager.getModID(index); int fileID = m_DownloadManager.getFileInfo(index)->fileID; + ModInfo::Ptr currentMod = nullptr; GuessedValue<QString> modName; // see if there already are mods with the specified mod id @@ -798,6 +806,7 @@ void OrganizerCore::installDownload(int index) if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_BACKUP) == flags.end()) { modName.update((*iter)->name(), GUESS_PRESET); + currentMod = *iter; (*iter)->saveMeta(); } } @@ -807,7 +816,9 @@ void OrganizerCore::installDownload(int index) bool hasIniTweaks = false; m_InstallationManager.setModsDirectory(m_Settings.paths().mods()); - if (m_InstallationManager.install(fileName, modName, hasIniTweaks) == IPluginInstaller::RESULT_SUCCESS) { + m_InstallationManager.notifyInstallationStart(fileName, currentMod); + auto result = m_InstallationManager.install(fileName, modName, hasIniTweaks); + if (result == IPluginInstaller::RESULT_SUCCESS) { MessageDialog::showMessage(tr("Installation successful"), qApp->activeWindow()); refreshModList(); @@ -828,19 +839,23 @@ void OrganizerCore::installDownload(int index) } m_ModInstalled(modName); + m_InstallationManager.notifyInstallationEnd(IPluginInstaller::RESULT_SUCCESS, modInfo); } else { reportError(tr("mod not found: %1").arg(qUtf8Printable(modName))); } m_DownloadManager.markInstalled(index); - emit modInstalled(modName); - } else if (m_InstallationManager.wasCancelled()) { - QMessageBox::information(qApp->activeWindow(), tr("Extraction cancelled"), - tr("The installation was cancelled while extracting files. " - "If this was prior to a FOMOD setup, this warning may be ignored. " - "However, if this was during installation, the mod will likely be missing files."), - QMessageBox::Ok); - refreshModList(); + } + else { + m_InstallationManager.notifyInstallationEnd(result, nullptr); + if (m_InstallationManager.wasCancelled()) { + QMessageBox::information(qApp->activeWindow(), tr("Extraction cancelled"), + tr("The installation was cancelled while extracting files. " + "If this was prior to a FOMOD setup, this warning may be ignored. " + "However, if this was during installation, the mod will likely be missing files."), + QMessageBox::Ok); + refreshModList(); + } } } catch (const std::exception &e) { reportError(e.what()); |
