diff --git a/src/plugins/backends/freedesktop/fredesktopnotification.cpp b/src/plugins/backends/freedesktop/fredesktopnotification.cpp index 5a5fd4e..f40dc00 100644 --- a/src/plugins/backends/freedesktop/fredesktopnotification.cpp +++ b/src/plugins/backends/freedesktop/fredesktopnotification.cpp @@ -23,10 +23,6 @@ int FreedesktopImageHint::imageHintID = qDBusRegisterMetaType(); -FreedesktopImageHint::FreedesktopImageHint() -{ - -} FreedesktopImageHint::FreedesktopImageHint(const QImage &img) { diff --git a/src/plugins/backends/freedesktop/fredesktopnotification.h b/src/plugins/backends/freedesktop/fredesktopnotification.h index 1263292..55239e0 100644 --- a/src/plugins/backends/freedesktop/fredesktopnotification.h +++ b/src/plugins/backends/freedesktop/fredesktopnotification.h @@ -27,7 +27,7 @@ class FreedesktopImageHint { public: - FreedesktopImageHint(); + FreedesktopImageHint() = default; FreedesktopImageHint(const QImage &img); QImage toQImage()const; diff --git a/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp b/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp index 7f030e1..18a129b 100644 --- a/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp +++ b/src/plugins/backends/freedesktop/freedesktopnotification_backend.cpp @@ -10,11 +10,6 @@ using namespace Snore; -FreedesktopBackend::FreedesktopBackend() : - SnoreBackend("Freedesktop Notification", true, true, true) -{ -} - bool FreedesktopBackend::initialize() { @@ -24,7 +19,7 @@ bool FreedesktopBackend::initialize() QDBusPendingReply reply = m_interface->GetCapabilities(); reply.waitForFinished(); QStringList caps = reply.value(); - setSupportsRichtext(caps.contains("body-markup")); + m_supportsRichtext = caps.contains("body-markup"); connect(m_interface, SIGNAL(ActionInvoked(uint,QString)), this, SLOT(slotActionInvoked(uint,QString))); connect(m_interface, SIGNAL(NotificationClosed(uint,uint)), this , SLOT(slotNotificationClosed(uint,uint))); @@ -44,6 +39,16 @@ bool FreedesktopBackend::deinitialize() return false; } +bool FreedesktopBackend::canCloseNotification() const +{ + return true; +} + +bool FreedesktopBackend::canUpdateNotification() const +{ + return true; +} + void FreedesktopBackend::slotNotify(Notification noti) { QStringList actions; @@ -70,12 +75,8 @@ void FreedesktopBackend::slotNotify(Notification noti) m_dbusIdMap.take(updateId); } - QString title = QString("%1 - %2").arg(noti.application().name(), noti.title()); - QString body(noti.text()); - if (!supportsRichtext()) { - title = Utils::toPlainText(title); - body = Utils::toPlainText(body); - } + QString title = QString("%1 - %2").arg(noti.application().name(), noti.title(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP)); + QString body(noti.text(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP)); QDBusPendingReply id = m_interface->Notify(noti.application().name(), updateId, "", title, body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000); diff --git a/src/plugins/backends/freedesktop/freedesktopnotification_backend.h b/src/plugins/backends/freedesktop/freedesktopnotification_backend.h index 2a4edd9..1760c87 100644 --- a/src/plugins/backends/freedesktop/freedesktopnotification_backend.h +++ b/src/plugins/backends/freedesktop/freedesktopnotification_backend.h @@ -9,9 +9,13 @@ class FreedesktopBackend: public Snore::SnoreBackend Q_INTERFACES(Snore::SnoreBackend) Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "plugin.json") public: - FreedesktopBackend(); - virtual bool initialize() override; - virtual bool deinitialize() override; + FreedesktopBackend() = default; + ~FreedesktopBackend() = default; + bool initialize() override; + bool deinitialize() override; + + bool canCloseNotification() const override; + bool canUpdateNotification() const override; public slots: void slotNotify(Snore::Notification notification) override; @@ -23,6 +27,7 @@ public slots: private: org::freedesktop::Notifications *m_interface; QHash m_dbusIdMap; + bool m_supportsRichtext; };