fix freedesktop backend
This commit is contained in:
parent
62e0ea8843
commit
e5f855ce07
|
@ -23,10 +23,6 @@
|
|||
|
||||
int FreedesktopImageHint::imageHintID = qDBusRegisterMetaType<FreedesktopImageHint>();
|
||||
|
||||
FreedesktopImageHint::FreedesktopImageHint()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FreedesktopImageHint::FreedesktopImageHint(const QImage &img)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
class FreedesktopImageHint
|
||||
{
|
||||
public:
|
||||
FreedesktopImageHint();
|
||||
FreedesktopImageHint() = default;
|
||||
FreedesktopImageHint(const QImage &img);
|
||||
QImage toQImage()const;
|
||||
|
||||
|
|
|
@ -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<QStringList> 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<uint> id = m_interface->Notify(noti.application().name(), updateId, "", title,
|
||||
body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000);
|
||||
|
||||
|
|
|
@ -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<uint, Snore::Notification> m_dbusIdMap;
|
||||
bool m_supportsRichtext;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue