Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 17380886 authored by Stefan Brüns's avatar Stefan Brüns

[Devicenotifications Engine] Keep at most one notification per UDI

Each notification was created as new datasource, and was newer removed
as long as the engine exists. This is especially bad for long living
applets like the device notifier. As there can only be one notification
per device (the last error state, or none), use the UDI as source name
and update the contents.

Also cancel (remove source) an old notifications in case of a successful
setup, otherwise old error messages are shown in the device notifier.

Test Plan:
in Dolphin, select "Release" (context menu) for a mounted CD
-> Notification in device notifier appears "Device can be safely removed"
remount without ejecting
-> Notification message is removed, device shows "mounted" emblem.

Without the change, the message stayed and the device kept the notification
emblem "(!)".

Reviewers: #frameworks, broulik

Reviewed By: broulik

Subscribers: broulik, plasma-devel

Tags: #plasma

Differential Revision:
parent b83e5ecc
......@@ -24,10 +24,10 @@
DeviceNotificationsEngine::DeviceNotificationsEngine( QObject* parent, const QVariantList& args )
: Plasma::DataEngine( parent, args ),
m_solidNotify(new KSolidNotify(this))
connect(m_solidNotify, &KSolidNotify::notify, this, &DeviceNotificationsEngine::notify);
connect(m_solidNotify, &KSolidNotify::clearNotification, this, &DeviceNotificationsEngine::clearNotification);
......@@ -36,7 +36,7 @@ DeviceNotificationsEngine::~DeviceNotificationsEngine()
void DeviceNotificationsEngine::notify(Solid::ErrorType solidError, const QString& error, const QString& errorDetails, const QString &udi)
const QString source = QStringLiteral("notification %1").arg(m_id++);
const QString source = QStringLiteral("%1 notification").arg(udi);
Plasma::DataEngine::Data notificationData;
notificationData.insert(QStringLiteral("solidError"), solidError);
......@@ -47,6 +47,11 @@ void DeviceNotificationsEngine::notify(Solid::ErrorType solidError, const QStrin
setData(source, notificationData );
void DeviceNotificationsEngine::clearNotification(const QString &udi)
removeSource(QStringLiteral("%1 notification").arg(udi));
K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(devicenotifications, DeviceNotificationsEngine, "plasma-dataengine-devicenotifications.json")
#include "devicenotificationsengine.moc"
......@@ -39,9 +39,9 @@ public:
private slots:
void notify(Solid::ErrorType solidError, const QString& error, const QString& errorDetails, const QString &udi);
void clearNotification(const QString &udi);
uint m_id;
KSolidNotify * m_solidNotify;
......@@ -72,6 +72,7 @@ void KSolidNotify::onDeviceRemoved(const QString &udi)
emit clearNotification(udi);
bool KSolidNotify::isSafelyRemovable(const QString &udi) const
......@@ -148,6 +149,11 @@ void KSolidNotify::queryBlockingApps(const QString &devicePath)
void KSolidNotify::onSolidReply(SolidReplyType type, Solid::ErrorType error, const QVariant &errorData, const QString &udi)
if ((error == Solid::ErrorType::NoError) && (type == SolidReplyType::Setup)) {
emit clearNotification(udi);
QString errorMsg;
switch (error) {
......@@ -48,6 +48,7 @@ public:
void notify(Solid::ErrorType solidError, const QString& error, const QString& errorDetails, const QString &udi);
void blockingAppsReady(const QStringList &apps);
void clearNotification(const QString &udi);
protected slots:
void onDeviceAdded(const QString &udi);
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