I'm abusing the notification dataengine to create notifications in my widgets. Right now I can send notifications (with action buttons), but I can't tell what button the user clicked. The "invokeAction" operation (notifcation applet => dataengine), emits: emit m_engine->ActionInvoked(id, parameters()[QStringLiteral("actionId")].toString()); https://github.com/KDE/plasma-workspace/blob/master/dataengines/notifications/notificationaction.cpp#L53 however, a QML widget can't connect to that since the DataEngine isn't exposed. PlasmaCore.DataSource wraps m_dataEngine, but doesn't expose it. https://github.com/KDE/plasma-framework/blob/91eb0749ed7f0d1439a60e67bc7a23c41636c93c/src/declarativeimports/core/datasource.h#L190 I'm not sure what would be the best way to expose the ActionInvoked signal to QML. ----- If your wondering what I'm using: https://github.com/Zren/plasma-applets/blob/master/org.kde.plasma.eventcalendar/package/contents/ui/NotificationManager.qml I use dataSource.serviceForSource("notifications") to get a Plasma::DataService. In our case, we get NotificationService. https://github.com/KDE/plasma-workspace/blob/master/dataengines/notifications/notificationservice.h Which also doesn't expose the DataEngine. https://api.kde.org/frameworks/plasma-framework/html/service_8cpp_source.html#l00087 The NotificationService returns a NotiticationAction (which extends Plasma::ServiceJob). When we use the "createNotification" operation on that serviceJob, its "result" is the notificationId, which is useful for later. int rv = m_engine->createNotification(...); setResult(rv); https://github.com/KDE/plasma-workspace/blob/master/dataengines/notifications/notificationaction.cpp#L60 The NotificationAction/ServiceJob has a reference to the NotificationEngine, so it might be possible to have it connect to the ActionInvoked/NotificationClosed signals.
KNotifications now offers a QML API. Consider the dataengine deprecated
Oh neat! It was added 2021 Oct, so since KF5 v5.88.0 * https://www.volkerkrause.eu/2021/09/18/kf5-notifications-in-qml.html * https://github.com/KDE/knotifications/blob/master/docs/qml-notifications.md * https://github.com/KDE/knotifications/commit/16e92d643faff27d52f10b14aab68b73d11a4481 Hmm, looks like I'll have to wait for Ubuntu 22.04 at least to use it on the KDE Store. * https://repology.org/project/knotifications/versions I've stopped using the notifications dataengine anyways since it had problems in Latte-Dock. * https://github.com/Zren/plasma-applet-eventcalendar/issues/60 I'm currently using the executable dataengine + python script. I'll see about trying to use the new KNotification API in a QML Loader, then using the python script as a fallback.