Commit 532534a1 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Support default action, priority hints, set desktop-entry

This adds support for default actions and priority hints, both of which we support in KNotification these days.
Also send along the desktop-entry of the issuing application so the notification server can identify where the notification is actually coming from.

Differential Revision: https://phabricator.kde.org/D20651
parent b4403de2
......@@ -90,15 +90,24 @@ void NotificationPortal::AddNotification(const QString &app_id,
}
}
}
if (notification.contains(QStringLiteral("priority"))) {
// TODO KNotification has no option for priority
}
if (notification.contains(QStringLiteral("default-action"))) {
// TODO KNotification has no option for default action
const QString priority = notification.value(QStringLiteral("priority")).toString();
if (priority == QLatin1String("low")) {
notify->setUrgency(KNotification::LowUrgency);
} else if (priority == QLatin1String("normal")) {
notify->setUrgency(KNotification::NormalUrgency);
} else if (priority == QLatin1String("high")) {
notify->setUrgency(KNotification::HighUrgency);
} else if (priority == QLatin1String("urgent")) {
notify->setUrgency(KNotification::CriticalUrgency);
}
if (notification.contains(QStringLiteral("default-action-target"))) {
// TODO KNotification has no option for default action
if (notification.contains(QStringLiteral("default-action"))
&& notification.contains(QStringLiteral("default-action-target"))) {
// default action is conveniently mapped to action number 0 so it uses the same action invocation method as the others
notify->setDefaultAction(notification.value(QStringLiteral("default-action")).toString());
}
if (notification.contains(QStringLiteral("buttons"))) {
QList<QVariantMap> buttons;
QDBusArgument dbusArgument = notification.value(QStringLiteral("buttons")).value<QDBusArgument>();
......@@ -116,6 +125,8 @@ void NotificationPortal::AddNotification(const QString &app_id,
}
}
notify->setHint(QStringLiteral("desktop-entry"), app_id);
notify->setProperty("app_id", app_id);
notify->setProperty("id", id);
connect(notify, static_cast<void (KNotification::*)(uint)>(&KNotification::activated), this, &NotificationPortal::notificationActivated);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment