cleanup backend api

This commit is contained in:
Patrick von Reth 2015-06-23 20:53:21 +02:00
parent 22b4d50ce3
commit 8fc1907d6d
11 changed files with 53 additions and 17 deletions

View File

@ -29,10 +29,8 @@
using namespace Snore; using namespace Snore;
SnoreBackend::SnoreBackend(const QString &name , bool canCloseNotification, bool canUpdateNotifications) : SnoreBackend::SnoreBackend(const QString &name) :
SnorePlugin(name), SnorePlugin(name)
m_canCloseNotification(canCloseNotification),
m_canUpdateNotification(canUpdateNotifications)
{ {
} }
@ -147,12 +145,12 @@ void SnoreSecondaryBackend::slotNotificationDisplayed(Notification)
bool SnoreBackend::canCloseNotification() const bool SnoreBackend::canCloseNotification() const
{ {
return m_canCloseNotification; return false;
} }
bool SnoreBackend::canUpdateNotification() const bool SnoreBackend::canUpdateNotification() const
{ {
return m_canUpdateNotification; return false;
} }
void SnoreBackend::slotRegisterApplication(const Application &application) void SnoreBackend::slotRegisterApplication(const Application &application)

View File

@ -31,15 +31,15 @@ class SNORE_EXPORT SnoreBackend : public SnorePlugin
Q_OBJECT Q_OBJECT
Q_INTERFACES(Snore::SnorePlugin) Q_INTERFACES(Snore::SnorePlugin)
public: public:
SnoreBackend(const QString &name, bool canCloseNotification, bool canUpdateNotifications = false); SnoreBackend(const QString &name);
virtual ~SnoreBackend(); virtual ~SnoreBackend();
virtual bool initialize() override; virtual bool initialize() override;
virtual bool deinitialize() override; virtual bool deinitialize() override;
void requestCloseNotification(Snore::Notification notification, Notification::CloseReasons reason); void requestCloseNotification(Snore::Notification notification, Notification::CloseReasons reason);
bool canCloseNotification() const; virtual bool canCloseNotification() const;
bool canUpdateNotification() const; virtual bool canUpdateNotification() const;
signals: signals:
void notificationClosed(Snore::Notification); void notificationClosed(Snore::Notification);
@ -57,9 +57,6 @@ protected slots:
protected: protected:
void closeNotification(Snore::Notification, Snore::Notification::CloseReasons); void closeNotification(Snore::Notification, Snore::Notification::CloseReasons);
private:
bool m_canCloseNotification;
bool m_canUpdateNotification;
}; };

View File

@ -30,7 +30,7 @@ using namespace Snore;
GrowlBackend *GrowlBackend::s_instance = nullptr; GrowlBackend *GrowlBackend::s_instance = nullptr;
GrowlBackend::GrowlBackend(): GrowlBackend::GrowlBackend():
SnoreBackend("Growl", false, false) SnoreBackend("Growl")
{ {
setDefaultValue("Host", "localhost"); setDefaultValue("Host", "localhost");
setDefaultValue("Password", ""); setDefaultValue("Password", "");

View File

@ -112,7 +112,7 @@ private:
}; };
SnarlBackend::SnarlBackend(): SnarlBackend::SnarlBackend():
SnoreBackend("Snarl", true, true) SnoreBackend("Snarl")
{ {
setDefaultValue("Password", QString()); setDefaultValue("Password", QString());
} }
@ -154,6 +154,16 @@ PluginSettingsWidget *SnarlBackend::settingsWidget()
return new SnarlSettings(this); return new SnarlSettings(this);
} }
bool SnarlBackend::canCloseNotification() const
{
return true;
}
bool SnarlBackend::canUpdateNotification() const
{
return true;
}
void SnarlBackend::slotRegisterApplication(const Application &application) void SnarlBackend::slotRegisterApplication(const Application &application)
{ {

View File

@ -33,6 +33,9 @@ public:
bool deinitialize() override; bool deinitialize() override;
Snore::PluginSettingsWidget *settingsWidget() override; Snore::PluginSettingsWidget *settingsWidget() override;
virtual bool canCloseNotification() const override;
virtual bool canUpdateNotification() const override;
private: private:
class SnarlWidget; class SnarlWidget;
SnarlBackend::SnarlWidget *m_eventLoop; SnarlBackend::SnarlWidget *m_eventLoop;

View File

@ -27,7 +27,7 @@
using namespace Snore; using namespace Snore;
SnoreNotifier::SnoreNotifier(): SnoreNotifier::SnoreNotifier():
SnoreBackend("Snore", true, true), SnoreBackend("Snore"),
m_widgets(3), m_widgets(3),
m_timer(new QTimer(this)) m_timer(new QTimer(this))
{ {
@ -142,6 +142,16 @@ bool SnoreNotifier::deinitialize()
return false; return false;
} }
bool SnoreNotifier::canCloseNotification() const
{
return true;
}
bool SnoreNotifier::canUpdateNotification() const
{
return true;
}
PluginSettingsWidget *SnoreNotifier::settingsWidget() PluginSettingsWidget *SnoreNotifier::settingsWidget()
{ {
return new SnoreNotifierSettings(this); return new SnoreNotifierSettings(this);

View File

@ -35,6 +35,9 @@ public:
bool initialize() override; bool initialize() override;
bool deinitialize() override; bool deinitialize() override;
virtual bool canCloseNotification() const override;
virtual bool canUpdateNotification() const override;
Snore::PluginSettingsWidget *settingsWidget() override; Snore::PluginSettingsWidget *settingsWidget() override;
public slots: public slots:

View File

@ -15,7 +15,7 @@
using namespace Snore; using namespace Snore;
SnoreToast::SnoreToast(): SnoreToast::SnoreToast():
SnoreBackend("Windows 8", true, false) SnoreBackend("Windows 8")
{ {
} }
@ -33,6 +33,11 @@ bool SnoreToast::initialize()
return SnoreBackend::initialize(); return SnoreBackend::initialize();
} }
bool SnoreToast::canCloseNotification() const
{
return true;
}
void SnoreToast::slotNotify(Notification notification) void SnoreToast::slotNotify(Notification notification)
{ {
QProcess *p = new QProcess(this); QProcess *p = new QProcess(this);

View File

@ -14,6 +14,8 @@ public:
~SnoreToast(); ~SnoreToast();
virtual bool initialize() override; virtual bool initialize() override;
virtual bool canCloseNotification() const override;
public slots: public slots:
void slotNotify(Snore::Notification notification) override; void slotNotify(Snore::Notification notification) override;
void slotRegisterApplication(const Snore::Application &application) override; void slotRegisterApplication(const Snore::Application &application) override;

View File

@ -7,7 +7,7 @@
using namespace Snore; using namespace Snore;
TrayIconNotifer::TrayIconNotifer() : TrayIconNotifer::TrayIconNotifer() :
SnoreBackend("System Tray Icon", true, false), SnoreBackend("System Tray Icon"),
m_currentlyDisplaying(false) m_currentlyDisplaying(false)
{ {
@ -27,6 +27,11 @@ bool TrayIconNotifer::deinitialize()
return false; return false;
} }
bool TrayIconNotifer::canCloseNotification() const
{
return true;
}
void TrayIconNotifer::slotNotify(Notification notification) void TrayIconNotifer::slotNotify(Notification notification)
{ {
QSystemTrayIcon *icon = trayIcon(notification.application()); QSystemTrayIcon *icon = trayIcon(notification.application());

View File

@ -18,6 +18,9 @@ public:
TrayIconNotifer(); TrayIconNotifer();
virtual ~TrayIconNotifer() override; virtual ~TrayIconNotifer() override;
virtual bool deinitialize() override; virtual bool deinitialize() override;
virtual bool canCloseNotification() const override;
public slots: public slots:
void slotNotify(Snore::Notification notification); void slotNotify(Snore::Notification notification);
void slotCloseNotification(Snore::Notification notification); void slotCloseNotification(Snore::Notification notification);