From c121cc167fb58114d4f71467b8722b4ae4f27421 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 16 Jun 2023 06:28:51 +0300 Subject: [PATCH] plasma: implement required features of org.freedesktop.Notifications v1.2 Signed-off-by: Ivailo Monev --- .../notifications/notificationsengine.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plasma/dataengines/notifications/notificationsengine.cpp b/plasma/dataengines/notifications/notificationsengine.cpp index eab4013f..0be254b4 100644 --- a/plasma/dataengines/notifications/notificationsengine.cpp +++ b/plasma/dataengines/notifications/notificationsengine.cpp @@ -35,6 +35,9 @@ #include +// for reference: +// https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html + NotificationsEngine::NotificationsEngine( QObject* parent, const QVariantList& args ) : Plasma::DataEngine( parent, args ), m_nextId( 1 ) { @@ -195,18 +198,23 @@ uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id, notificationData.insert("configurable", configurable); QImage image; - if (hints.contains("image_data")) { + if (hints.contains("image_data")) { // v1.1 QDBusArgument arg = hints["image_data"].value(); image = decodeNotificationSpecImageHint(arg); - } else if (hints.contains("image_path")) { + } else if (hints.contains("image-data")) { // v1.2 + QDBusArgument arg = hints["image-data"].value(); + image = decodeNotificationSpecImageHint(arg); + } else if (hints.contains("image_path")) { // v1.1 QString path = findImageForSpecImagePath(hints["image_path"].toString()); if (!path.isEmpty()) { image.load(path); } - } else if (hints.contains("icon_data")) { - // This hint was in use in version 1.0 of the spec but has been - // replaced by "image_data" in version 1.1. We need to support it for - // users of the 1.0 version of the spec. + } else if (hints.contains("image-path")) { // v1.2 + QString path = findImageForSpecImagePath(hints["image-path"].toString()); + if (!path.isEmpty()) { + image.load(path); + } + } else if (hints.contains("icon_data")) { // v1.0 QDBusArgument arg = hints["icon_data"].value(); image = decodeNotificationSpecImageHint(arg); } @@ -275,7 +283,7 @@ QString NotificationsEngine::GetServerInformation(QString& vendor, QString& vers { vendor = "KDE"; version = "1.0"; // FIXME - specVersion = "1.1"; + specVersion = "1.2"; return "Plasma"; }