fix freedesktop backend
This commit is contained in:
parent
62e0ea8843
commit
e5f855ce07
|
@ -23,10 +23,6 @@
|
||||||
|
|
||||||
int FreedesktopImageHint::imageHintID = qDBusRegisterMetaType<FreedesktopImageHint>();
|
int FreedesktopImageHint::imageHintID = qDBusRegisterMetaType<FreedesktopImageHint>();
|
||||||
|
|
||||||
FreedesktopImageHint::FreedesktopImageHint()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FreedesktopImageHint::FreedesktopImageHint(const QImage &img)
|
FreedesktopImageHint::FreedesktopImageHint(const QImage &img)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
class FreedesktopImageHint
|
class FreedesktopImageHint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FreedesktopImageHint();
|
FreedesktopImageHint() = default;
|
||||||
FreedesktopImageHint(const QImage &img);
|
FreedesktopImageHint(const QImage &img);
|
||||||
QImage toQImage()const;
|
QImage toQImage()const;
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,6 @@
|
||||||
|
|
||||||
using namespace Snore;
|
using namespace Snore;
|
||||||
|
|
||||||
FreedesktopBackend::FreedesktopBackend() :
|
|
||||||
SnoreBackend("Freedesktop Notification", true, true, true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FreedesktopBackend::initialize()
|
bool FreedesktopBackend::initialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,7 +19,7 @@ bool FreedesktopBackend::initialize()
|
||||||
QDBusPendingReply<QStringList> reply = m_interface->GetCapabilities();
|
QDBusPendingReply<QStringList> reply = m_interface->GetCapabilities();
|
||||||
reply.waitForFinished();
|
reply.waitForFinished();
|
||||||
QStringList caps = reply.value();
|
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(ActionInvoked(uint,QString)), this, SLOT(slotActionInvoked(uint,QString)));
|
||||||
connect(m_interface, SIGNAL(NotificationClosed(uint,uint)), this , SLOT(slotNotificationClosed(uint,uint)));
|
connect(m_interface, SIGNAL(NotificationClosed(uint,uint)), this , SLOT(slotNotificationClosed(uint,uint)));
|
||||||
|
|
||||||
|
@ -44,6 +39,16 @@ bool FreedesktopBackend::deinitialize()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FreedesktopBackend::canCloseNotification() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FreedesktopBackend::canUpdateNotification() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void FreedesktopBackend::slotNotify(Notification noti)
|
void FreedesktopBackend::slotNotify(Notification noti)
|
||||||
{
|
{
|
||||||
QStringList actions;
|
QStringList actions;
|
||||||
|
@ -70,12 +75,8 @@ void FreedesktopBackend::slotNotify(Notification noti)
|
||||||
m_dbusIdMap.take(updateId);
|
m_dbusIdMap.take(updateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString title = QString("%1 - %2").arg(noti.application().name(), noti.title());
|
QString title = QString("%1 - %2").arg(noti.application().name(), noti.title(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP));
|
||||||
QString body(noti.text());
|
QString body(noti.text(m_supportsRichtext ? Utils::ALL_MARKUP : Utils::NO_MARKUP));
|
||||||
if (!supportsRichtext()) {
|
|
||||||
title = Utils::toPlainText(title);
|
|
||||||
body = Utils::toPlainText(body);
|
|
||||||
}
|
|
||||||
QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, "", title,
|
QDBusPendingReply<uint> id = m_interface->Notify(noti.application().name(), updateId, "", title,
|
||||||
body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000);
|
body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000);
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,13 @@ class FreedesktopBackend: public Snore::SnoreBackend
|
||||||
Q_INTERFACES(Snore::SnoreBackend)
|
Q_INTERFACES(Snore::SnoreBackend)
|
||||||
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "plugin.json")
|
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0" FILE "plugin.json")
|
||||||
public:
|
public:
|
||||||
FreedesktopBackend();
|
FreedesktopBackend() = default;
|
||||||
virtual bool initialize() override;
|
~FreedesktopBackend() = default;
|
||||||
virtual bool deinitialize() override;
|
bool initialize() override;
|
||||||
|
bool deinitialize() override;
|
||||||
|
|
||||||
|
bool canCloseNotification() const override;
|
||||||
|
bool canUpdateNotification() const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotNotify(Snore::Notification notification) override;
|
void slotNotify(Snore::Notification notification) override;
|
||||||
|
@ -23,6 +27,7 @@ public slots:
|
||||||
private:
|
private:
|
||||||
org::freedesktop::Notifications *m_interface;
|
org::freedesktop::Notifications *m_interface;
|
||||||
QHash<uint, Snore::Notification> m_dbusIdMap;
|
QHash<uint, Snore::Notification> m_dbusIdMap;
|
||||||
|
bool m_supportsRichtext;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue