From 149328dcb2ff716f56937bd9ca705ad79c5d1f81 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sun, 11 Oct 2020 21:15:12 +0200 Subject: Switch from Qt signals to boost::signals for DownloadManager. --- src/downloadmanager.cpp | 31 +++++++++++++++++++++++++++++-- src/downloadmanager.h | 21 +++++++++++++++++---- 2 files changed, 46 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 3e6010db..5db0cbdf 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -694,6 +694,7 @@ void DownloadManager::removeFile(int index, bool deleteFile) if(!download->m_Hidden) metaSettings.setValue("removed", true); } + m_DownloadRemoved(index); endDisableDirWatcher(); } @@ -1453,13 +1454,19 @@ void DownloadManager::setState(DownloadManager::DownloadInfo *info, DownloadMana } info->m_State = state; switch (state) { - case STATE_PAUSED: + case STATE_PAUSED: { + info->m_Reply->abort(); + info->m_Output.close(); + m_DownloadPaused(row); + } break; case STATE_ERROR: { info->m_Reply->abort(); info->m_Output.close(); + m_DownloadFailed(row); } break; case STATE_CANCELED: { info->m_Reply->abort(); + m_DownloadFailed(row); } break; case STATE_FETCHINGMODINFO: { m_RequestIDs.insert(m_NexusInterface->requestDescription(info->m_FileInfo->gameName, info->m_FileInfo->modID, this, info->m_DownloadID, QString())); @@ -1473,7 +1480,7 @@ void DownloadManager::setState(DownloadManager::DownloadInfo *info, DownloadMana } break; case STATE_READY: { createMetaFile(info); - emit downloadComplete(row); + m_DownloadComplete(row); } break; default: /* NOP */ break; } @@ -1792,6 +1799,26 @@ QString DownloadManager::downloadPath(int id) return getFilePath(id); } +bool DownloadManager::onDownloadComplete(const std::function& callback) +{ + return m_DownloadComplete.connect(callback).connected(); +} + +bool DownloadManager::onDownloadPaused(const std::function& callback) +{ + return m_DownloadPaused.connect(callback).connected(); +} + +bool DownloadManager::onDownloadFailed(const std::function& callback) +{ + return m_DownloadFailed.connect(callback).connected(); +} + +bool DownloadManager::onDownloadRemoved(const std::function& callback) +{ + return m_DownloadRemoved.connect(callback).connected(); +} + int DownloadManager::indexByName(const QString &fileName) const { for (int i = 0; i < m_ActiveDownloads.size(); ++i) { diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 90def927..8a0d8eed 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -37,6 +37,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include namespace MOBase { class IPluginGame; } @@ -126,6 +127,8 @@ private: DownloadInfo() : m_TotalSize(0), m_ReQueried(false), m_Hidden(false), m_SpeedDiff(std::tuple(0,0,0,0,0)), m_HasData(false) {} }; + using SignalDownloadCallback = boost::signals2::signal; + public: /** @@ -367,11 +370,16 @@ public: */ void refreshList(); - virtual int startDownloadURLs(const QStringList &urls); +public: // IDownloadManager interface: - virtual int startDownloadNexusFile(int modID, int fileID); + int startDownloadURLs(const QStringList &urls) override; + int startDownloadNexusFile(int modID, int fileID) override; + QString downloadPath(int id) override; - virtual QString downloadPath(int id); + bool onDownloadComplete(const std::function& callback) override; + bool onDownloadPaused(const std::function& callback) override; + bool onDownloadFailed(const std::function& callback) override; + bool onDownloadRemoved(const std::function& callback) override; /** * @brief retrieve a download index from the filename @@ -383,7 +391,7 @@ public: void pauseAll(); -signals: +Q_SIGNALS: void aboutToUpdate(); @@ -556,6 +564,11 @@ private: QFileSystemWatcher m_DirWatcher; + SignalDownloadCallback m_DownloadComplete; + SignalDownloadCallback m_DownloadPaused; + SignalDownloadCallback m_DownloadFailed; + SignalDownloadCallback m_DownloadRemoved; + //The dirWatcher is actually triggering off normal Mo operations such as deleting downloads or editing .meta files //so it needs to be disabled during operations that are known to cause the creation or deletion of files in the Downloads folder. //Notably using QSettings to edit a file creates a temporarily .lock file that causes the Watcher to trigger multiple listRefreshes freezing the ui. -- cgit v1.3.1 From 0363b73adb75714c94a7a7cea2840a9c40ee006e Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sun, 11 Oct 2020 21:16:29 +0200 Subject: Do not call installer callbacks for non-active plugins. --- src/installationmanager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index a755b0cb..86d9ca1b 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -872,7 +872,9 @@ QStringList InstallationManager::getSupportedExtensions() const void InstallationManager::notifyInstallationStart(QString const& archive, bool reinstallation, ModInfo::Ptr currentMod) { for (auto* installer : m_Installers) { - installer->onInstallationStart(archive, reinstallation, currentMod.get()); + if (installer->isActive()) { + installer->onInstallationStart(archive, reinstallation, currentMod.get()); + } } } @@ -881,6 +883,8 @@ void InstallationManager::notifyInstallationEnd( ModInfo::Ptr newMod) { for (auto* installer : m_Installers) { - installer->onInstallationEnd(result, newMod.get()); + if (installer->isActive()) { + installer->onInstallationEnd(result, newMod.get()); + } } } -- cgit v1.3.1 From 3932371cd12ae7ec0812fbb2db3315448e18f1a8 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sun, 11 Oct 2020 21:17:34 +0200 Subject: Use proxy for ModList, PluginList and DownloadManager. Do not use registered callbacks when plugin is inactive. --- src/CMakeLists.txt | 9 ++++- src/downloadmanagerproxy.cpp | 44 ++++++++++++++++++++++++ src/downloadmanagerproxy.h | 31 +++++++++++++++++ src/modlistproxy.cpp | 53 +++++++++++++++++++++++++++++ src/modlistproxy.h | 32 +++++++++++++++++ src/organizerproxy.cpp | 81 ++++++++++++++++++++++++-------------------- src/organizerproxy.h | 18 ++++++++-- src/plugincontainer.cpp | 2 +- src/pluginlistproxy.cpp | 73 +++++++++++++++++++++++++++++++++++++++ src/pluginlistproxy.h | 36 ++++++++++++++++++++ src/proxyutils.h | 26 ++++++++++++++ 11 files changed, 365 insertions(+), 40 deletions(-) create mode 100644 src/downloadmanagerproxy.cpp create mode 100644 src/downloadmanagerproxy.h create mode 100644 src/modlistproxy.cpp create mode 100644 src/modlistproxy.h create mode 100644 src/pluginlistproxy.cpp create mode 100644 src/pluginlistproxy.h create mode 100644 src/proxyutils.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1f54cbc..beb34ce4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,6 @@ add_filter(NAME src/core GROUPS nexusinterface nxmaccessmanager organizercore - organizerproxy apiuseraccount processrunner qdirfiletree @@ -147,6 +146,14 @@ add_filter(NAME src/profiles GROUPS profilesdialog ) +add_filter(NAME src/proxies GROUPS + downloadmanagerproxy + modlistproxy + organizerproxy + pluginlistproxy + proxyutils +) + add_filter(NAME src/register GROUPS shared/directoryentry shared/fileentry diff --git a/src/downloadmanagerproxy.cpp b/src/downloadmanagerproxy.cpp new file mode 100644 index 00000000..4a5c9b6b --- /dev/null +++ b/src/downloadmanagerproxy.cpp @@ -0,0 +1,44 @@ +#include "downloadmanagerproxy.h" + +#include "proxyutils.h" +#include "organizerproxy.h" + +using namespace MOBase; + +DownloadManagerProxy::DownloadManagerProxy(OrganizerProxy* oproxy, IDownloadManager* downloadManager) : + m_OrganizerProxy(oproxy), m_Proxied(downloadManager) { } + +int DownloadManagerProxy::startDownloadURLs(const QStringList& urls) +{ + return m_Proxied->startDownloadURLs(urls); +} + +int DownloadManagerProxy::startDownloadNexusFile(int modID, int fileID) +{ + return m_Proxied->startDownloadNexusFile(modID, fileID); +} + +QString DownloadManagerProxy::downloadPath(int id) +{ + return m_Proxied->downloadPath(id); +} + +bool DownloadManagerProxy::onDownloadComplete(const std::function& callback) +{ + return m_Proxied->onDownloadComplete(MOShared::callIfPluginActive(m_OrganizerProxy, callback)); +} + +bool DownloadManagerProxy::onDownloadPaused(const std::function& callback) +{ + return m_Proxied->onDownloadPaused(MOShared::callIfPluginActive(m_OrganizerProxy, callback)); +} + +bool DownloadManagerProxy::onDownloadFailed(const std::function& callback) +{ + return m_Proxied->onDownloadFailed(MOShared::callIfPluginActive(m_OrganizerProxy, callback)); +} + +bool DownloadManagerProxy::onDownloadRemoved(const std::function& callback) +{ + return m_Proxied->onDownloadRemoved(MOShared::callIfPluginActive(m_OrganizerProxy, callback)); +} diff --git a/src/downloadmanagerproxy.h b/src/downloadmanagerproxy.h new file mode 100644 index 00000000..f41b60c6 --- /dev/null +++ b/src/downloadmanagerproxy.h @@ -0,0 +1,31 @@ +#ifndef DOWNLOADMANAGERPROXY_H +#define DOWNLOADMANAGERPROXY_H + +#include + +class OrganizerProxy; + +class DownloadManagerProxy : public MOBase::IDownloadManager +{ + +public: + + DownloadManagerProxy(OrganizerProxy* oproxy, IDownloadManager* downloadManager); + virtual ~DownloadManagerProxy() { } + + int startDownloadURLs(const QStringList& urls) override; + int startDownloadNexusFile(int modID, int fileID) override; + QString downloadPath(int id) override; + + bool onDownloadComplete(const std::function& callback) override; + bool onDownloadPaused(const std::function& callback) override; + bool onDownloadFailed(const std::function& callback) override; + bool onDownloadRemoved(const std::function& callback) override; + +private: + + OrganizerProxy* m_OrganizerProxy; + IDownloadManager* m_Proxied; +}; + +#endif // ORGANIZERPROXY_H diff --git a/src/modlistproxy.cpp b/src/modlistproxy.cpp new file mode 100644 index 00000000..7ec00c49 --- /dev/null +++ b/src/modlistproxy.cpp @@ -0,0 +1,53 @@ +#include "modlistproxy.h" +#include "organizerproxy.h" +#include "proxyutils.h" + +using namespace MOBase; + +ModListProxy::ModListProxy(OrganizerProxy* oproxy, IModList* modlist) : + m_OrganizerProxy(oproxy), m_Proxied(modlist) { } + +QString ModListProxy::displayName(const QString& internalName) const +{ + return m_Proxied->displayName(internalName); +} + +QStringList ModListProxy::allMods() const +{ + return m_Proxied->allMods(); +} + +IModList::ModStates ModListProxy::state(const QString& name) const +{ + return m_Proxied->state(name); +} + +bool ModListProxy::setActive(const QString& name, bool active) +{ + return m_Proxied->setActive(name, active); +} + +int ModListProxy::setActive(const QStringList& names, bool active) +{ + return m_Proxied->setActive(names, active); +} + +int ModListProxy::priority(const QString& name) const +{ + return m_Proxied->priority(name); +} + +bool ModListProxy::setPriority(const QString& name, int newPriority) +{ + return m_Proxied->setPriority(name, newPriority); +} + +bool ModListProxy::onModStateChanged(const std::function&)>& func) +{ + return m_Proxied->onModStateChanged(MOShared::callIfPluginActive(m_OrganizerProxy, func)); +} + +bool ModListProxy::onModMoved(const std::function& func) +{ + return m_Proxied->onModMoved(MOShared::callIfPluginActive(m_OrganizerProxy, func)); +} diff --git a/src/modlistproxy.h b/src/modlistproxy.h new file mode 100644 index 00000000..13399e0a --- /dev/null +++ b/src/modlistproxy.h @@ -0,0 +1,32 @@ +#ifndef MODLISTPROXY_H +#define MODLISTPROXY_H + +#include + +class OrganizerProxy; + +class ModListProxy : public MOBase::IModList +{ + +public: + + ModListProxy(OrganizerProxy* oproxy, IModList* modlist); + virtual ~ModListProxy() { } + + QString displayName(const QString& internalName) const override; + QStringList allMods() const override; + ModStates state(const QString& name) const override; + bool setActive(const QString& name, bool active) override; + int setActive(const QStringList& names, bool active) override; + int priority(const QString& name) const override; + bool setPriority(const QString& name, int newPriority) override; + bool onModStateChanged(const std::function&)>& func) override; + bool onModMoved(const std::function& func) override; + +private: + + OrganizerProxy* m_OrganizerProxy; + IModList* m_Proxied; +}; + +#endif // ORGANIZERPROXY_H diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index a5047b43..05011e80 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -5,6 +5,10 @@ #include "plugincontainer.h" #include "settings.h" #include "glob_matching.h" +#include "downloadmanagerproxy.h" +#include "modlistproxy.h" +#include "pluginlistproxy.h" +#include "proxyutils.h" #include #include @@ -13,16 +17,19 @@ using namespace MOBase; using namespace MOShared; -OrganizerProxy::OrganizerProxy(OrganizerCore *organizer, PluginContainer *pluginContainer, const QString &pluginName) +OrganizerProxy::OrganizerProxy(OrganizerCore* organizer, PluginContainer* pluginContainer, MOBase::IPlugin* plugin) : m_Proxied(organizer) , m_PluginContainer(pluginContainer) - , m_PluginName(pluginName) + , m_Plugin(plugin) + , m_DownloadManagerProxy(std::make_unique(this, organizer->downloadManager())) + , m_ModListProxy(std::make_unique(this, organizer->modList())) + , m_PluginListProxy(std::make_unique(this, organizer->pluginList())) { } IModRepositoryBridge *OrganizerProxy::createNexusBridge() const { - return new NexusBridge(m_PluginContainer, m_PluginName); + return new NexusBridge(m_PluginContainer, m_Plugin->name()); } QString OrganizerProxy::profileName() const @@ -171,36 +178,6 @@ bool OrganizerProxy::waitForApplication(HANDLE handle, LPDWORD exitCode) const } } -bool OrganizerProxy::onAboutToRun(const std::function &func) -{ - return m_Proxied->onAboutToRun(func); -} - -bool OrganizerProxy::onFinishedRun(const std::function &func) -{ - return m_Proxied->onFinishedRun(func); -} - -bool OrganizerProxy::onModInstalled(const std::function &func) -{ - return m_Proxied->onModInstalled(func); -} - -bool OrganizerProxy::onUserInterfaceInitialized(std::function const& func) -{ - return m_Proxied->onUserInterfaceInitialized(func); -} - -bool OrganizerProxy::onProfileChanged(std::function const& func) -{ - return m_Proxied->onProfileChanged(func); -} - -bool OrganizerProxy::onPluginSettingChanged(std::function const& func) -{ - return m_Proxied->onPluginSettingChanged(func); -} - void OrganizerProxy::refreshModList(bool saveChanges) { m_Proxied->refreshModList(saveChanges); @@ -254,17 +231,17 @@ QList OrganizerProxy::findFileInfos(const QString MOBase::IDownloadManager *OrganizerProxy::downloadManager() const { - return m_Proxied->downloadManager(); + return m_DownloadManagerProxy.get(); } MOBase::IPluginList *OrganizerProxy::pluginList() const { - return m_Proxied->pluginList(); + return m_PluginListProxy.get(); } MOBase::IModList *OrganizerProxy::modList() const { - return m_Proxied->modList(); + return m_ModListProxy.get(); } MOBase::IProfile *OrganizerProxy::profile() const @@ -281,3 +258,35 @@ QStringList OrganizerProxy::modsSortedByProfilePriority() const { return m_Proxied->modsSortedByProfilePriority(); } + +// CALLBACKS + +bool OrganizerProxy::onAboutToRun(const std::function& func) +{ + return m_Proxied->onAboutToRun(MOShared::callIfPluginActive(this, func, true)); +} + +bool OrganizerProxy::onFinishedRun(const std::function& func) +{ + return m_Proxied->onFinishedRun(MOShared::callIfPluginActive(this, func)); +} + +bool OrganizerProxy::onModInstalled(const std::function& func) +{ + return m_Proxied->onModInstalled(MOShared::callIfPluginActive(this, func)); +} + +bool OrganizerProxy::onUserInterfaceInitialized(std::function const& func) +{ + return m_Proxied->onUserInterfaceInitialized(MOShared::callIfPluginActive(this, func)); +} + +bool OrganizerProxy::onProfileChanged(std::function const& func) +{ + return m_Proxied->onProfileChanged(MOShared::callIfPluginActive(this, func)); +} + +bool OrganizerProxy::onPluginSettingChanged(std::function const& func) +{ + return m_Proxied->onPluginSettingChanged(MOShared::callIfPluginActive(this, func)); +} diff --git a/src/organizerproxy.h b/src/organizerproxy.h index 8950217d..cc059aa9 100644 --- a/src/organizerproxy.h +++ b/src/organizerproxy.h @@ -1,18 +1,28 @@ #ifndef ORGANIZERPROXY_H #define ORGANIZERPROXY_H +#include +#include #include class OrganizerCore; class PluginContainer; +class DownloadManagerProxy; +class ModListProxy; +class PluginListProxy; class OrganizerProxy : public MOBase::IOrganizer { public: - OrganizerProxy(OrganizerCore *organizer, PluginContainer *pluginContainer, const QString &pluginName); + OrganizerProxy(OrganizerCore *organizer, PluginContainer *pluginContainer, MOBase::IPlugin *plugin); + + /** + * @return the plugin corresponding to this proxy. + */ + MOBase::IPlugin* plugin() const { return m_Plugin; } virtual MOBase::IModRepositoryBridge *createNexusBridge() const; virtual QString profileName() const; @@ -65,7 +75,11 @@ private: OrganizerCore *m_Proxied; PluginContainer *m_PluginContainer; - QString m_PluginName; + MOBase::IPlugin *m_Plugin; + + std::unique_ptr m_DownloadManagerProxy; + std::unique_ptr m_ModListProxy; + std::unique_ptr m_PluginListProxy; }; diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index 60acc63c..4771359d 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -173,7 +173,7 @@ bool PluginContainer::verifyPlugin(IPlugin *plugin) { if (plugin == nullptr) { return false; - } else if (!plugin->init(new OrganizerProxy(m_Organizer, this, plugin->name()))) { + } else if (!plugin->init(new OrganizerProxy(m_Organizer, this, plugin))) { log::warn("plugin failed to initialize"); return false; } diff --git a/src/pluginlistproxy.cpp b/src/pluginlistproxy.cpp new file mode 100644 index 00000000..1f8dc2b4 --- /dev/null +++ b/src/pluginlistproxy.cpp @@ -0,0 +1,73 @@ +#include "pluginlistproxy.h" +#include "organizerproxy.h" +#include "proxyutils.h" + +using namespace MOBase; + +PluginListProxy::PluginListProxy(OrganizerProxy* oproxy, IPluginList* pluginlist) : + m_OrganizerProxy(oproxy), m_Proxied(pluginlist) { } + +QStringList PluginListProxy::pluginNames() const +{ + return m_Proxied->pluginNames(); +} + +IPluginList::PluginStates PluginListProxy::state(const QString& name) const +{ + return m_Proxied->state(name); +} + +void PluginListProxy::setState(const QString& name, PluginStates state) +{ + return m_Proxied->setState(name, state); +} + +int PluginListProxy::priority(const QString& name) const +{ + return m_Proxied->priority(name); +} + +bool PluginListProxy::setPriority(const QString& name, int newPriority) +{ + return m_Proxied->setPriority(name, newPriority); +} + +int PluginListProxy::loadOrder(const QString& name) const +{ + return m_Proxied->loadOrder(name); +} + +void PluginListProxy::setLoadOrder(const QStringList& pluginList) +{ + return m_Proxied->setLoadOrder(pluginList); +} + +bool PluginListProxy::isMaster(const QString& name) const +{ + return m_Proxied->isMaster(name); +} + +QStringList PluginListProxy::masters(const QString& name) const +{ + return m_Proxied->masters(name); +} + +QString PluginListProxy::origin(const QString& name) const +{ + return m_Proxied->origin(name); +} + +bool PluginListProxy::onRefreshed(const std::function& callback) +{ + return m_Proxied->onRefreshed(MOShared::callIfPluginActive(m_OrganizerProxy, callback)); +} + +bool PluginListProxy::onPluginMoved(const std::function& func) +{ + return m_Proxied->onPluginMoved(MOShared::callIfPluginActive(m_OrganizerProxy, func)); +} + +bool PluginListProxy::onPluginStateChanged(const std::function&)> &func) +{ + return m_Proxied->onPluginStateChanged(MOShared::callIfPluginActive(m_OrganizerProxy, func)); +} diff --git a/src/pluginlistproxy.h b/src/pluginlistproxy.h new file mode 100644 index 00000000..e08406e3 --- /dev/null +++ b/src/pluginlistproxy.h @@ -0,0 +1,36 @@ +#ifndef PLUGINLISTPROXY_H +#define PLUGINLISTPROXY_H + +#include + +class OrganizerProxy; + +class PluginListProxy : public MOBase::IPluginList +{ + +public: + + PluginListProxy(OrganizerProxy* oproxy, IPluginList* pluginlist); + virtual ~PluginListProxy() { } + + QStringList pluginNames() const override; + PluginStates state(const QString& name) const override; + void setState(const QString& name, PluginStates state) override; + int priority(const QString& name) const override; + bool setPriority(const QString& name, int newPriority) override; + int loadOrder(const QString& name) const override; + void setLoadOrder(const QStringList& pluginList) override; + bool isMaster(const QString& name) const override; + QStringList masters(const QString& name) const override; + QString origin(const QString& name) const override; + bool onRefreshed(const std::function& callback) override; + bool onPluginMoved(const std::function& func) override; + bool onPluginStateChanged(const std::function&)>& func) override; + +private: + + OrganizerProxy* m_OrganizerProxy; + IPluginList* m_Proxied; +}; + +#endif // ORGANIZERPROXY_H diff --git a/src/proxyutils.h b/src/proxyutils.h new file mode 100644 index 00000000..4c1717d8 --- /dev/null +++ b/src/proxyutils.h @@ -0,0 +1,26 @@ +#ifndef PROXYUTILS_H +#define PROXYUTILS_H + +#include + +#include "organizerproxy.h" + +namespace MOShared { + + template + auto callIfPluginActive(OrganizerProxy* proxy, Fn&& callback, T defaultReturn = T{}) { + return [fn = std::forward(callback), proxy, defaultReturn](auto&& ...args) { + if (proxy->plugin()->isActive()) { + return fn(std::forward(args)...); + } + else { + if constexpr (!std::is_same_v, decltype(args)... >, void>) { + return defaultReturn; + } + } + }; + } + +} + +#endif -- cgit v1.3.1 From b43fdc3b4c77e81399080e40c13f55db4160c1d8 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sun, 11 Oct 2020 21:24:09 +0200 Subject: Add glob_matching.h to the utility group. --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index beb34ce4..e95179b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,6 +195,7 @@ add_filter(NAME src/utilities GROUPS shared/windows_error thread_utils json + glob_matching ) add_filter(NAME src/widgets GROUPS -- cgit v1.3.1 From 6652e9c3be70b6cc9d66f21e2f95a3331267b662 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sun, 11 Oct 2020 22:04:40 +0200 Subject: Do not use inactive preview plugin. --- src/previewgenerator.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/previewgenerator.cpp b/src/previewgenerator.cpp index f317393e..b406b7bc 100644 --- a/src/previewgenerator.cpp +++ b/src/previewgenerator.cpp @@ -38,13 +38,17 @@ void PreviewGenerator::registerPlugin(MOBase::IPluginPreview *plugin) bool PreviewGenerator::previewSupported(const QString &fileExtension) const { - return m_PreviewPlugins.find(fileExtension.toLower()) != m_PreviewPlugins.end(); + auto it = m_PreviewPlugins.find(fileExtension.toLower()); + if (it == m_PreviewPlugins.end()) { + return false; + } + return it->second->isActive(); } QWidget *PreviewGenerator::genPreview(const QString &fileName) const { auto iter = m_PreviewPlugins.find(QFileInfo(fileName).suffix().toLower()); - if (iter != m_PreviewPlugins.end()) { + if (iter != m_PreviewPlugins.end() && iter->second->isActive()) { return iter->second->genFilePreview(fileName, m_MaxSize); } else { return nullptr; -- cgit v1.3.1 From 7762c1f53a52932ad4e4d9c76d54a62a0ee56d91 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 14 Oct 2020 19:38:10 +0200 Subject: Check for problems when closing the settings dialog. --- src/mainwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fa5a790c..3428d72a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5094,6 +5094,9 @@ void MainWindow::on_actionSettings_triggered() instManager->setModsDirectory(settings.paths().mods()); instManager->setDownloadDirectory(settings.paths().downloads()); + // Schedule a problem check since diagnose plugins may have been enabled / disabled. + scheduleCheckForProblems(); + fixCategories(); refreshFilters(); -- cgit v1.3.1 From 3c1f206d7d29d3b3d27082aca23dafd87a95a71b Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Sun, 18 Oct 2020 10:13:59 +0200 Subject: Always call onPluginSettingChanged and onUserInterfaceInitialized callbacks. --- src/organizerproxy.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 05011e80..2932e6bf 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -278,7 +278,8 @@ bool OrganizerProxy::onModInstalled(const std::function& f bool OrganizerProxy::onUserInterfaceInitialized(std::function const& func) { - return m_Proxied->onUserInterfaceInitialized(MOShared::callIfPluginActive(this, func)); + // Always call this one to allow plugin to initialize themselves even when not active: + return m_Proxied->onUserInterfaceInitialized(func); } bool OrganizerProxy::onProfileChanged(std::function const& func) @@ -288,5 +289,6 @@ bool OrganizerProxy::onProfileChanged(std::function const& func) { - return m_Proxied->onPluginSettingChanged(MOShared::callIfPluginActive(this, func)); + // Always call this one, otherwise plugin cannot detect they are being enabled / disabled: + return m_Proxied->onPluginSettingChanged(func); } -- cgit v1.3.1