From 5112904d325dd41de4eb34826e259cf98f3738fe Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Wed, 15 Jul 2015 11:21:14 +0200 Subject: [PATCH] cleanup plugin loading --- src/libsnore/plugins/plugincontainer.cpp | 12 ++++++++---- src/libsnore/plugins/plugincontainer.h | 1 + src/libsnore/plugins/plugins.cpp | 6 +++--- src/libsnore/plugins/plugins.h | 8 ++++---- src/libsnore/snore.cpp | 5 ++--- src/libsnore/snore_p.cpp | 4 ++-- .../freedesktop/freedesktopnotification_backend.cpp | 4 ++-- .../freedesktop/freedesktopnotification_backend.h | 5 +++-- src/plugins/backends/growl/growlbackend.cpp | 4 ++-- src/plugins/backends/growl/growlbackend.h | 4 +++- src/plugins/backends/snarl/snarl.cpp | 4 ++-- src/plugins/backends/snarl/snarl.h | 4 +++- src/plugins/backends/snore/snorenotifier.cpp | 4 ++-- src/plugins/backends/snore/snorenotifier.h | 4 +++- src/plugins/backends/snoretoast/snoretoast.cpp | 8 ++++---- src/plugins/backends/snoretoast/snoretoast.h | 4 +++- src/plugins/backends/trayicon/trayiconnotifer.cpp | 4 ++-- src/plugins/backends/trayicon/trayiconnotifer.h | 4 +++- .../freedesktop/freedesktopnotificationfrontend.cpp | 8 ++++---- .../freedesktop/freedesktopnotificationfrontend.h | 4 +++- src/plugins/frontends/pushover/pushover_frontend.cpp | 4 ++-- src/plugins/frontends/pushover/pushover_frontend.h | 4 +++- src/plugins/frontends/snarlnetwork/snarlnetwork.cpp | 6 +++--- src/plugins/frontends/snarlnetwork/snarlnetwork.h | 2 +- src/plugins/secondary_backends/nma/nma.cpp | 4 ++-- src/plugins/secondary_backends/nma/nma.h | 4 +++- src/plugins/secondary_backends/pushover/pushover.cpp | 4 ++-- src/plugins/secondary_backends/pushover/pushover.h | 4 +++- src/plugins/secondary_backends/sound/sound.cpp | 4 ++-- src/plugins/secondary_backends/sound/sound.h | 5 ++++- src/plugins/secondary_backends/toasty/toasty.cpp | 4 ++-- src/plugins/secondary_backends/toasty/toasty.h | 4 +++- 32 files changed, 89 insertions(+), 61 deletions(-) diff --git a/src/libsnore/plugins/plugincontainer.cpp b/src/libsnore/plugins/plugincontainer.cpp index 4697e5c..8e2b15f 100644 --- a/src/libsnore/plugins/plugincontainer.cpp +++ b/src/libsnore/plugins/plugincontainer.cpp @@ -52,15 +52,19 @@ SnorePlugin *PluginContainer::load() snoreDebug(SNORE_WARNING) << "Failed loading plugin: " << m_loader.errorString(); return nullptr; } - SnorePlugin *plugin = qobject_cast (m_loader.instance()); - plugin->m_container = this; - plugin->setDefaultSettings(); - return plugin; + if (!m_plugin) { + m_plugin = qobject_cast (m_loader.instance()); + m_plugin->m_container = this; + m_plugin->setDefaultSettings(); + QMetaObject::invokeMethod(m_plugin, "load", Qt::QueuedConnection); + } + return m_plugin; } void PluginContainer::unload() { m_loader.unload(); + m_plugin = nullptr; } const QString &PluginContainer::file() diff --git a/src/libsnore/plugins/plugincontainer.h b/src/libsnore/plugins/plugincontainer.h index 6fcdc11..ced5aee 100644 --- a/src/libsnore/plugins/plugincontainer.h +++ b/src/libsnore/plugins/plugincontainer.h @@ -87,6 +87,7 @@ private: QString m_pluginName; SnorePlugin::PluginTypes m_pluginType; QPluginLoader m_loader; + SnorePlugin *m_plugin = nullptr; }; } diff --git a/src/libsnore/plugins/plugins.cpp b/src/libsnore/plugins/plugins.cpp index 2700665..3529514 100644 --- a/src/libsnore/plugins/plugins.cpp +++ b/src/libsnore/plugins/plugins.cpp @@ -35,7 +35,7 @@ SnorePlugin::SnorePlugin() if (thread() != qApp->thread()) { snoreDebug(SNORE_WARNING) << "Plugin initialized in wrong thread."; } - connect(this, &SnorePlugin::initializeChanged, [this](bool b) { + connect(this, &SnorePlugin::loadedStateChanged, [this](bool b) { snoreDebug(SNORE_DEBUG) << "Plugin:" << name() << "initialized" << b; Q_ASSERT_X(!(b && m_initialized), Q_FUNC_INFO, "Plugin initialized multiple times."); if (!b) { @@ -50,7 +50,7 @@ SnorePlugin::~SnorePlugin() snoreDebug(SNORE_DEBUG) << name() << this << "deleted"; } -bool SnorePlugin::isInitialized() const +bool SnorePlugin::isLoaded() const { return m_initialized; } @@ -118,7 +118,7 @@ void SnorePlugin::setDefaultSettings() void SnorePlugin::setEnabled(bool enabled) { - Q_ASSERT_X(!enabled || isInitialized(), Q_FUNC_INFO, "Plugin not initialized"); + Q_ASSERT_X(!enabled || isLoaded(), Q_FUNC_INFO, "Plugin not initialized"); if (enabled != m_enabled) { emit enabledChanged(enabled); diff --git a/src/libsnore/plugins/plugins.h b/src/libsnore/plugins/plugins.h index cd88e00..4ad01ee 100644 --- a/src/libsnore/plugins/plugins.h +++ b/src/libsnore/plugins/plugins.h @@ -58,7 +58,7 @@ public: void enable(); void disable(); - bool isInitialized() const; + bool isLoaded() const; bool isEnabled() const; @@ -84,11 +84,11 @@ public: virtual PluginSettingsWidget *settingsWidget(); Q_SIGNALS: - void initializeChanged(bool initialized); + void loadedStateChanged(bool loaded); void enabledChanged(bool enabled); -public Q_SLOTS: - virtual void slotInitialize() = 0; +private Q_SLOTS: + virtual void load() = 0; protected: /** diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index 1ad208f..d7f30a3 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -84,7 +84,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) case SnorePlugin::SECONDARY_BACKEND: case SnorePlugin::FRONTEND: case SnorePlugin::PLUGIN: - connect(plugin, &SnorePlugin::initializeChanged, [plugin](bool initialized) { + connect(plugin, &SnorePlugin::loadedStateChanged, [plugin](bool initialized) { if (initialized) { plugin->setEnabled(plugin->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool()); } @@ -95,7 +95,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) continue; } - connect(plugin, &SnorePlugin::initializeChanged, [d, plugin](bool initialized) { + connect(plugin, &SnorePlugin::loadedStateChanged, [d, plugin](bool initialized) { if (!initialized) { //TODO: improve d->m_pluginNames[plugin->type()].removeAll(plugin->name()); @@ -103,7 +103,6 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) } }); - QMetaObject::invokeMethod(plugin, "slotInitialize", Qt::QueuedConnection); snoreDebug(SNORE_DEBUG) << info->name() << "is a" << info->type(); d->m_pluginNames[info->type()].append(info->name()); auto key = qMakePair(type, info->name()); diff --git a/src/libsnore/snore_p.cpp b/src/libsnore/snore_p.cpp index 6a019ba..1e0574e 100644 --- a/src/libsnore/snore_p.cpp +++ b/src/libsnore/snore_p.cpp @@ -86,14 +86,14 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend) } snoreDebug(SNORE_DEBUG) << "Setting Notification Backend to:" << backend; SnoreBackend *b = qobject_cast(backends.value(backend)->load()); - if (!b->isInitialized()) { + if (!b->isLoaded()) { snoreDebug(SNORE_DEBUG) << "Failed to initialize" << b->name(); return false; } if (m_notificationBackend) { m_notificationBackend->disable(); } - connect(b, &SnoreBackend::initializeChanged, [this, b](bool initialized) { + connect(b, &SnoreBackend::loadedStateChanged, [this, b](bool initialized) { if (!initialized) { slotInitPrimaryNotificationBackend(); } diff --git a/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp b/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp index da5c2ad..5e89867 100644 --- a/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp +++ b/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp @@ -24,7 +24,7 @@ FreedesktopBackend::FreedesktopBackend() }); } -void FreedesktopBackend::slotInitialize() +void FreedesktopBackend::load() { m_interface = new org::freedesktop::Notifications(QLatin1String("org.freedesktop.Notifications"), QLatin1String("/org/freedesktop/Notifications"), @@ -33,7 +33,7 @@ void FreedesktopBackend::slotInitialize() reply.waitForFinished(); QStringList caps = reply.value(); m_supportsRichtext = caps.contains(QLatin1String("body-markup")); - emit initializeChanged(true); + emit loadedStateChanged(true); } bool FreedesktopBackend::canCloseNotification() const diff --git a/src/plugins/backends/freedesktop/freedesktopnotification_backend.h b/src/plugins/backends/freedesktop/freedesktopnotification_backend.h index 8b4fb93..c317d77 100644 --- a/src/plugins/backends/freedesktop/freedesktopnotification_backend.h +++ b/src/plugins/backends/freedesktop/freedesktopnotification_backend.h @@ -16,14 +16,15 @@ public: bool canUpdateNotification() const override; public Q_SLOTS: - void slotInitialize() override; - void slotNotify(Snore::Notification notification) override; void slotCloseNotification(Snore::Notification notification) override; void slotActionInvoked(const uint &id, const QString &actionID); void slotNotificationClosed(const uint &id, const uint &reason); +private Q_SLOTS: + void load() override; + private: org::freedesktop::Notifications *m_interface; QHash m_dbusIdMap; diff --git a/src/plugins/backends/growl/growlbackend.cpp b/src/plugins/backends/growl/growlbackend.cpp index 8f08406..fdaf30d 100644 --- a/src/plugins/backends/growl/growlbackend.cpp +++ b/src/plugins/backends/growl/growlbackend.cpp @@ -63,9 +63,9 @@ GrowlBackend::~GrowlBackend() Growl::shutdown(); } -void GrowlBackend::slotInitialize() +void GrowlBackend::load() { - emit initializeChanged(Growl::isRunning(GROWL_TCP, settingsValue(QLatin1String("Host")).toString().toUtf8().constData())); + emit loadedStateChanged(Growl::isRunning(GROWL_TCP, settingsValue(QLatin1String("Host")).toString().toUtf8().constData())); } void GrowlBackend::slotRegisterApplication(const Application &application) diff --git a/src/plugins/backends/growl/growlbackend.h b/src/plugins/backends/growl/growlbackend.h index 7e24643..04578ce 100644 --- a/src/plugins/backends/growl/growlbackend.h +++ b/src/plugins/backends/growl/growlbackend.h @@ -43,11 +43,13 @@ private: QHash m_applications; public Q_SLOTS: - void slotInitialize() override; void slotRegisterApplication(const Snore::Application &application) override; void slotDeregisterApplication(const Snore::Application &application) override; void slotNotify(Snore::Notification notification) override; +private Q_SLOTS: + void load() override; + }; #endif // GROWL_BACKEND_H diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index 259029e..5dc559f 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -121,11 +121,11 @@ SnarlBackend::~SnarlBackend() delete m_eventLoop; } -void SnarlBackend::slotInitialize() +void SnarlBackend::load() { SnarlInterface *snarlInterface = new SnarlInterface(); - emit initializeChanged(snarlInterface->IsSnarlRunning()); + emit loadedStateChanged(snarlInterface->IsSnarlRunning()); delete snarlInterface; } diff --git a/src/plugins/backends/snarl/snarl.h b/src/plugins/backends/snarl/snarl.h index 5fac414..e180376 100644 --- a/src/plugins/backends/snarl/snarl.h +++ b/src/plugins/backends/snarl/snarl.h @@ -43,12 +43,14 @@ private: QHash m_applications; public Q_SLOTS: - void slotInitialize() override; void slotRegisterApplication(const Snore::Application &application); void slotDeregisterApplication(const Snore::Application &application); void slotNotify(Snore::Notification notification); void slotCloseNotification(Snore::Notification notification); +private Q_SLOTS: + void load() override; + private: QHash m_idMap; diff --git a/src/plugins/backends/snore/snorenotifier.cpp b/src/plugins/backends/snore/snorenotifier.cpp index 4c6a44a..94f0d65 100644 --- a/src/plugins/backends/snore/snorenotifier.cpp +++ b/src/plugins/backends/snore/snorenotifier.cpp @@ -105,7 +105,7 @@ void SnoreNotifier::slotCloseNotification(Snore::Notification notification) //the timer will show the next } -void SnoreNotifier::slotInitialize() +void SnoreNotifier::load() { for (int i = 0; i < m_widgets.size(); ++i) { NotifyWidget *w = new NotifyWidget(i, this); @@ -123,7 +123,7 @@ void SnoreNotifier::slotInitialize() slotCloseNotification(notification); }); } - emit initializeChanged(true); + emit loadedStateChanged(true); } bool SnoreNotifier::canCloseNotification() const diff --git a/src/plugins/backends/snore/snorenotifier.h b/src/plugins/backends/snore/snorenotifier.h index 4e939cd..0728b8b 100644 --- a/src/plugins/backends/snore/snorenotifier.h +++ b/src/plugins/backends/snore/snorenotifier.h @@ -41,10 +41,12 @@ protected: void setDefaultSettings() override; public Q_SLOTS: - void slotInitialize() override; virtual void slotNotify(Snore::Notification notification) override; virtual void slotCloseNotification(Snore::Notification notification) override; +private Q_SLOTS: + void load() override; + private: QList m_queue; diff --git a/src/plugins/backends/snoretoast/snoretoast.cpp b/src/plugins/backends/snoretoast/snoretoast.cpp index eb62b4e..5f6f2ae 100644 --- a/src/plugins/backends/snoretoast/snoretoast.cpp +++ b/src/plugins/backends/snoretoast/snoretoast.cpp @@ -14,13 +14,13 @@ using namespace Snore; -void SnoreToast::slotInitialize() +void SnoreToast::load() { if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS8) { snoreDebug(SNORE_DEBUG) << "SnoreToast does not work on windows" << QSysInfo::windowsVersion(); - emit initializeChanged(false); + emit loadedStateChanged(false); } - emit initializeChanged(true); + emit loadedStateChanged(true); } bool SnoreToast::canCloseNotification() const @@ -134,7 +134,7 @@ QProcess *SnoreToast::createProcess(Notification noti) if (noti.isValid()) { closeNotification(noti, Notification::NONE); } - emit initializeChanged(false); + emit loadedStateChanged(false); p->deleteLater(); }); connect(qApp, &QApplication::aboutToQuit, p, &QProcess::kill); diff --git a/src/plugins/backends/snoretoast/snoretoast.h b/src/plugins/backends/snoretoast/snoretoast.h index a0a17fa..4e0af21 100644 --- a/src/plugins/backends/snoretoast/snoretoast.h +++ b/src/plugins/backends/snoretoast/snoretoast.h @@ -16,11 +16,13 @@ public: virtual bool canCloseNotification() const override; public Q_SLOTS: - virtual void slotInitialize() override; void slotNotify(Snore::Notification notification) override; void slotRegisterApplication(const Snore::Application &application) override; void slotCloseNotification(Snore::Notification notification) override; +private Q_SLOTS: + void load() override; + private: QString appId(const Snore::Application &application); diff --git a/src/plugins/backends/trayicon/trayiconnotifer.cpp b/src/plugins/backends/trayicon/trayiconnotifer.cpp index 7bb1909..a1c510f 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.cpp +++ b/src/plugins/backends/trayicon/trayiconnotifer.cpp @@ -6,10 +6,10 @@ #include using namespace Snore; -void TrayIconNotifer::slotInitialize() +void TrayIconNotifer::load() { m_currentlyDisplaying = false; - emit initializeChanged(true); + emit loadedStateChanged(true); } bool TrayIconNotifer::canCloseNotification() const diff --git a/src/plugins/backends/trayicon/trayiconnotifer.h b/src/plugins/backends/trayicon/trayiconnotifer.h index 83b424d..1e16596 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.h +++ b/src/plugins/backends/trayicon/trayiconnotifer.h @@ -21,12 +21,14 @@ public: virtual bool canCloseNotification() const override; public Q_SLOTS: - void slotInitialize() override; void slotNotify(Snore::Notification notification) override; void slotCloseNotification(Snore::Notification notification) override; void slotRegisterApplication(const Snore::Application &application) override; void slotDeregisterApplication(const Snore::Application &application) override; +private Q_SLOTS: + void load() override; + private: QSystemTrayIcon *trayIcon(const Snore::Application &app); QList m_notificationQue; diff --git a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp index c3f45ba..6af1e24 100644 --- a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp +++ b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp @@ -38,11 +38,11 @@ FreedesktopFrontend::FreedesktopFrontend() if (dbus.registerService(QLatin1String("org.freedesktop.Notifications"))) { if (!dbus.registerObject(QLatin1String("/org/freedesktop/Notifications"), this)) { snoreDebug(SNORE_WARNING) << "Failed to initialize" << name() << "failed to register object"; - emit initializeChanged(false); + emit loadedStateChanged(false); } } else { snoreDebug(SNORE_WARNING) << "Failed to initialize" << name() << "failed to register service"; - emit initializeChanged(false); + emit loadedStateChanged(false); } } else { QDBusConnection dbus = QDBusConnection::sessionBus(); @@ -54,9 +54,9 @@ FreedesktopFrontend::FreedesktopFrontend() }); } -void FreedesktopFrontend::slotInitialize() +void FreedesktopFrontend::load() { - emit initializeChanged(true); + emit loadedStateChanged(true); } void FreedesktopFrontend::slotActionInvoked(Notification notification) diff --git a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h index a15a91f..a16f826 100644 --- a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h +++ b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.h @@ -43,10 +43,12 @@ Q_SIGNALS: void ActionInvoked(uint id, const QString &actionKey); public Q_SLOTS: - void slotInitialize() override; void slotActionInvoked(Snore::Notification notification) override; void slotNotificationClosed(Snore::Notification notification) override; +private Q_SLOTS: + void load() override; + private: Snore::Alert m_alert; NotificationsAdaptor *m_adaptor; diff --git a/src/plugins/frontends/pushover/pushover_frontend.cpp b/src/plugins/frontends/pushover/pushover_frontend.cpp index a9aa54c..6b6f057 100644 --- a/src/plugins/frontends/pushover/pushover_frontend.cpp +++ b/src/plugins/frontends/pushover/pushover_frontend.cpp @@ -51,9 +51,9 @@ PushoverFrontend::PushoverFrontend() }); } -void PushoverFrontend::slotInitialize() +void PushoverFrontend::load() { - emit initializeChanged(true); + emit loadedStateChanged(true); } PluginSettingsWidget *PushoverFrontend::settingsWidget() diff --git a/src/plugins/frontends/pushover/pushover_frontend.h b/src/plugins/frontends/pushover/pushover_frontend.h index d1b5da7..699a44f 100644 --- a/src/plugins/frontends/pushover/pushover_frontend.h +++ b/src/plugins/frontends/pushover/pushover_frontend.h @@ -47,9 +47,11 @@ protected: void setDefaultSettings() override; public Q_SLOTS: - void slotInitialize() override; void slotActionInvoked(Snore::Notification notification); +private Q_SLOTS: + void load() override; + Q_SIGNALS: void loggedInChanged(bool isLoggedIn); void error(QString error); diff --git a/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp b/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp index 2826ca0..33ef85f 100644 --- a/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp +++ b/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp @@ -44,16 +44,16 @@ SnarlNetworkFrontend::~SnarlNetworkFrontend() delete parser; } -void SnarlNetworkFrontend::slotInitialize() +void SnarlNetworkFrontend::load() { tcpServer = new QTcpServer(this); if (!tcpServer->listen(QHostAddress::Any, port)) { snoreDebug(SNORE_DEBUG) << "The port is already used"; - emit initializeChanged(false); + emit loadedStateChanged(false); } else { std::cout << "The Snarl Network Protokoll is developed for Snarl " << std::endl; } - emit initializeChanged(true); + emit loadedStateChanged(true); } void SnarlNetworkFrontend::slotActionInvoked(Snore::Notification notification) diff --git a/src/plugins/frontends/snarlnetwork/snarlnetwork.h b/src/plugins/frontends/snarlnetwork/snarlnetwork.h index ea730b8..3a085d5 100644 --- a/src/plugins/frontends/snarlnetwork/snarlnetwork.h +++ b/src/plugins/frontends/snarlnetwork/snarlnetwork.h @@ -39,11 +39,11 @@ public: ~SnarlNetworkFrontend(); public Q_SLOTS: - void slotInitialize() override; void slotActionInvoked(Snore::Notification notification) override; void slotNotificationClosed(Snore::Notification notification) override; private Q_SLOTS: + void load() override; void handleConnection(); void handleMessages(); diff --git a/src/plugins/secondary_backends/nma/nma.cpp b/src/plugins/secondary_backends/nma/nma.cpp index 4262924..6343df0 100644 --- a/src/plugins/secondary_backends/nma/nma.cpp +++ b/src/plugins/secondary_backends/nma/nma.cpp @@ -59,9 +59,9 @@ void NotifyMyAndroid::slotNotify(Notification notification) } -void NotifyMyAndroid::slotInitialize() +void NotifyMyAndroid::load() { - emit initializeChanged(true); + emit loadedStateChanged(true); } PluginSettingsWidget *NotifyMyAndroid::settingsWidget() diff --git a/src/plugins/secondary_backends/nma/nma.h b/src/plugins/secondary_backends/nma/nma.h index 95c2cea..0b285a0 100644 --- a/src/plugins/secondary_backends/nma/nma.h +++ b/src/plugins/secondary_backends/nma/nma.h @@ -37,9 +37,11 @@ protected: void setDefaultSettings() override; public Q_SLOTS: - void slotInitialize() override; void slotNotify(Snore::Notification notification) override; +private Q_SLOTS: + void load() override; + private: QNetworkAccessManager m_manager; diff --git a/src/plugins/secondary_backends/pushover/pushover.cpp b/src/plugins/secondary_backends/pushover/pushover.cpp index 86bd498..10f8ed1 100644 --- a/src/plugins/secondary_backends/pushover/pushover.cpp +++ b/src/plugins/secondary_backends/pushover/pushover.cpp @@ -120,9 +120,9 @@ void Pushover::slotNotify(Notification notification) } -void Pushover::slotInitialize() +void Pushover::load() { - emit initializeChanged(true); + emit loadedStateChanged(true); } PluginSettingsWidget *Pushover::settingsWidget() diff --git a/src/plugins/secondary_backends/pushover/pushover.h b/src/plugins/secondary_backends/pushover/pushover.h index 4f2d88b..b1d343f 100644 --- a/src/plugins/secondary_backends/pushover/pushover.h +++ b/src/plugins/secondary_backends/pushover/pushover.h @@ -37,9 +37,11 @@ protected: void setDefaultSettings() override; public Q_SLOTS: - void slotInitialize() override; void slotNotify(Snore::Notification notification) override; +private Q_SLOTS: + void load() override; + private: QNetworkAccessManager m_manager; diff --git a/src/plugins/secondary_backends/sound/sound.cpp b/src/plugins/secondary_backends/sound/sound.cpp index f5cd835..d2482f2 100644 --- a/src/plugins/secondary_backends/sound/sound.cpp +++ b/src/plugins/secondary_backends/sound/sound.cpp @@ -34,10 +34,10 @@ Sound::Sound(): }); } -void Sound::slotInitialize() +void Sound::load() { m_player->setVolume(settingsValue(QLatin1String("Volume")).toInt()); - emit initializeChanged(true); + emit loadedStateChanged(true); } PluginSettingsWidget *Sound::settingsWidget() diff --git a/src/plugins/secondary_backends/sound/sound.h b/src/plugins/secondary_backends/sound/sound.h index 23abaaf..f125457 100644 --- a/src/plugins/secondary_backends/sound/sound.h +++ b/src/plugins/secondary_backends/sound/sound.h @@ -37,8 +37,11 @@ protected: void setDefaultSettings() override; public Q_SLOTS: - void slotInitialize() override; void slotNotificationDisplayed(Snore::Notification notification) override; + +private Q_SLOTS: + void load() override; + private: QMediaPlayer *m_player; }; diff --git a/src/plugins/secondary_backends/toasty/toasty.cpp b/src/plugins/secondary_backends/toasty/toasty.cpp index bfbd9f0..2064b68 100644 --- a/src/plugins/secondary_backends/toasty/toasty.cpp +++ b/src/plugins/secondary_backends/toasty/toasty.cpp @@ -77,9 +77,9 @@ void Toasty::slotNotify(Notification notification) } -void Toasty::slotInitialize() +void Toasty::load() { - emit initializeChanged(true); + emit loadedStateChanged(true); } PluginSettingsWidget *Toasty::settingsWidget() diff --git a/src/plugins/secondary_backends/toasty/toasty.h b/src/plugins/secondary_backends/toasty/toasty.h index ca9ab2d..29dc12c 100644 --- a/src/plugins/secondary_backends/toasty/toasty.h +++ b/src/plugins/secondary_backends/toasty/toasty.h @@ -37,9 +37,11 @@ protected: void setDefaultSettings() override; public Q_SLOTS: - void slotInitialize() override; void slotNotify(Snore::Notification notification) override; +private Q_SLOTS: + void load() override; + private: QNetworkAccessManager m_manager;