From a4acfc1f992eb5135c9ae6542ae5ffa8b09a2c2d Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 12 Nov 2020 21:49:57 +0100 Subject: Add callbacks for plugin enabled/disabled. --- src/organizerproxy.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/organizerproxy.cpp') diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 77b7c2d6..c2283acc 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -293,8 +293,36 @@ bool OrganizerProxy::onProfileChanged(std::functiononProfileChanged(MOShared::callIfPluginActive(this, func)); } +// Always call these one, otherwise plugin cannot detect they are being enabled / disabled: bool OrganizerProxy::onPluginSettingChanged(std::function const& func) { - // Always call this one, otherwise plugin cannot detect they are being enabled / disabled: return m_Proxied->onPluginSettingChanged(func); } + +bool OrganizerProxy::onPluginEnabled(std::function const& func) +{ + return m_Proxied->onPluginEnabled(func); +} + +bool OrganizerProxy::onPluginEnabled(const QString& pluginName, std::function const& func) +{ + return m_Proxied->onPluginEnabled([=](const IPlugin* plugin) { + if (plugin->name().compare(pluginName, Qt::CaseInsensitive) == 0) { + func(); + } + }); +} + +bool OrganizerProxy::onPluginDisabled(std::function const& func) +{ + return m_Proxied->onPluginDisabled(func); +} + +bool OrganizerProxy::onPluginDisabled(const QString& pluginName, std::function const& func) +{ + return m_Proxied->onPluginDisabled([=](const IPlugin* plugin) { + if (plugin->name().compare(pluginName, Qt::CaseInsensitive) == 0) { + func(); + } + }); +} -- cgit v1.3.1