Commit 9e032bf5 authored by Nicolas Fella's avatar Nicolas Fella

Replace old notification when new notification for connection appears

Summary:
When a second notification appears shortly after another, e.g. a wifi network disconnects and then reconnects, replace the first notification with the second one. This avoids having a disconnected and a connected notification simultaneously.

Depends on D28691

Test Plan: dis- and reconnected my wifi

Reviewers: #plasma, broulik, jgrulich

Reviewed By: jgrulich

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28693
parent 0eeb2605
......@@ -372,7 +372,7 @@ void Notification::onActiveConnectionStateChanged(NetworkManager::ActiveConnecti
QString eventId, text, iconName;
const QString acName = ac->id();
const QString connectionId = ac->path();
const QString connectionId = ac->id();
if (state == NetworkManager::ActiveConnection::Activated) {
auto foundConnection = std::find_if(m_activeConnectionsBeforeSleep.constBegin(),
......@@ -426,10 +426,16 @@ void Notification::onActiveConnectionStateChanged(NetworkManager::ActiveConnecti
return;
}
KNotification *notify = new KNotification(eventId, KNotification::CloseOnTimeout);
connect(notify, &KNotification::closed, this, &Notification::notificationClosed);
notify->setProperty("uni", connectionId);
notify->setComponentName(QStringLiteral("networkmanagement"));
KNotification *notify = m_notifications.value(connectionId);
if (!notify) {
notify = new KNotification(eventId, KNotification::CloseOnTimeout);
connect(notify, &KNotification::closed, this, &Notification::notificationClosed);
notify->setProperty("uni", connectionId);
notify->setComponentName(QStringLiteral("networkmanagement"));
m_notifications[connectionId] = notify;
}
if (!iconName.isEmpty()) {
notify->setIconName(iconName);
} else {
......@@ -441,7 +447,6 @@ void Notification::onActiveConnectionStateChanged(NetworkManager::ActiveConnecti
}
notify->setTitle(acName);
notify->setText(text.toHtmlEscaped());
m_notifications[connectionId] = notify;
notify->sendEvent();
}
......
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