summaryrefslogtreecommitdiff
path: root/src/modlistproxy.cpp
diff options
context:
space:
mode:
authorMikaƫl Capelle <capelle.mikael@gmail.com>2020-12-07 08:40:23 +0100
committerGitHub <noreply@github.com>2020-12-07 08:40:23 +0100
commit904264e231a9aef485025cb45f1eb006b017aa1a (patch)
treec3ff682de4ac4761b8d36f0e96a96dce6a034706 /src/modlistproxy.cpp
parent0a6a5eb7868dde908e07ea12c7eb674b2063b950 (diff)
parent3264d7899e2560bce4591ab2142ee9d51bc7890c (diff)
Merge pull request #1313 from Holt59/load-plugin-without-restart
Implement loading/unloading of plugins without restarting
Diffstat (limited to 'src/modlistproxy.cpp')
-rw-r--r--src/modlistproxy.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/modlistproxy.cpp b/src/modlistproxy.cpp
index 8fcbdbdf..6165fc3f 100644
--- a/src/modlistproxy.cpp
+++ b/src/modlistproxy.cpp
@@ -1,12 +1,35 @@
#include "modlistproxy.h"
#include "organizerproxy.h"
#include "proxyutils.h"
+#include "modlist.h"
using namespace MOBase;
+using namespace MOShared;
-ModListProxy::ModListProxy(OrganizerProxy* oproxy, IModList* modlist) :
+ModListProxy::ModListProxy(OrganizerProxy* oproxy, ModList* modlist) :
m_OrganizerProxy(oproxy), m_Proxied(modlist) { }
+ModListProxy::~ModListProxy()
+{
+ disconnectSignals();
+}
+
+void ModListProxy::connectSignals()
+{
+ m_Connections.push_back(m_Proxied->onModInstalled(callSignalIfPluginActive(m_OrganizerProxy, m_ModInstalled)));
+ m_Connections.push_back(m_Proxied->onModMoved(callSignalIfPluginActive(m_OrganizerProxy, m_ModMoved)));
+ m_Connections.push_back(m_Proxied->onModRemoved(callSignalIfPluginActive(m_OrganizerProxy, m_ModRemoved)));
+ m_Connections.push_back(m_Proxied->onModStateChanged(callSignalIfPluginActive(m_OrganizerProxy, m_ModStateChanged)));
+}
+
+void ModListProxy::disconnectSignals()
+{
+ for (auto& conn : m_Connections) {
+ conn.disconnect();
+ }
+ m_Connections.clear();
+}
+
QString ModListProxy::displayName(const QString& internalName) const
{
return m_Proxied->displayName(internalName);
@@ -59,20 +82,20 @@ bool ModListProxy::setPriority(const QString& name, int newPriority)
bool ModListProxy::onModInstalled(const std::function<void(IModInterface*)>& func)
{
- return m_Proxied->onModInstalled(MOShared::callIfPluginActive(m_OrganizerProxy, func));
+ return m_ModInstalled.connect(func).connected();
}
bool ModListProxy::onModRemoved(const std::function<void(QString const&)>& func)
{
- return m_Proxied->onModRemoved(MOShared::callIfPluginActive(m_OrganizerProxy, func));
+ return m_ModRemoved.connect(func).connected();
}
bool ModListProxy::onModStateChanged(const std::function<void(const std::map<QString, ModStates>&)>& func)
{
- return m_Proxied->onModStateChanged(MOShared::callIfPluginActive(m_OrganizerProxy, func));
+ return m_ModStateChanged.connect(func).connected();
}
bool ModListProxy::onModMoved(const std::function<void(const QString&, int, int)>& func)
{
- return m_Proxied->onModMoved(MOShared::callIfPluginActive(m_OrganizerProxy, func));
+ return m_ModMoved.connect(func).connected();
}