[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-workspace] dataengines/notifications: If we get a notification with no body, treat the subje
From: David Edmundson <kde () davidedmundson ! co ! uk>
Date: 2016-12-09 15:06:35
Message-ID: E1cFMkt-00036n-5I () code ! kde ! org
[Download RAW message or body]
Git commit cbf06cf862c5779f2c16a6903e828c67d5c1a670 by David Edmundson.
Committed on 09/12/2016 at 15:05.
Pushed by davidedmundson into branch 'master'.
If we get a notification with no body, treat the subject line as the body
Summary: BUG: 372112
Test Plan:
notify-send "This long title that goes on and on" - wrapped with no
title
notify-send "subject1" "msg1"
notify-send "subject1" "msg2" - appeared as one message with two lines
notify-send "subject2" "msg1"
notify-send "subject3" "msg2" - appeared as two notifications
Reviewers: #plasma
Subscribers: mart, broulik, apol, plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D3425
M +9 -4 dataengines/notifications/notificationsengine.cpp
https://commits.kde.org/plasma-workspace/cbf06cf862c5779f2c16a6903e828c67d5c1a670
diff --git a/dataengines/notifications/notificationsengine.cpp \
b/dataengines/notifications/notificationsengine.cpp index d0d218a8..968965ad 100644
--- a/dataengines/notifications/notificationsengine.cpp
+++ b/dataengines/notifications/notificationsengine.cpp
@@ -202,19 +202,21 @@ uint NotificationsEngine::Notify(const QString &app_name, uint \
replaces_id,
qDebug() << "Currrent active notifications:" << m_activeNotifications;
qDebug() << "Guessing partOf as:" << partOf;
qDebug() << " New Notification: " << summary << body << timeout << "& Part of:" \
<< partOf;
- QString _body;
+ QString bodyFinal = body;
+ QString summaryFinal = summary;
if (partOf > 0) {
const QString source = QStringLiteral("notification %1").arg(partOf);
Plasma::DataContainer *container = containerForSource(source);
if (container) {
// append the body text
- _body = container->data()[QStringLiteral("body")].toString();
+ QString _body = container->data()[QStringLiteral("body")].toString();
if (_body != body) {
_body.append("\n").append(body);
} else {
_body = body;
}
+ bodyFinal = _body;
replaces_id = partOf;
@@ -222,6 +224,10 @@ uint NotificationsEngine::Notify(const QString &app_name, uint \
replaces_id, // TODO: maybe just update the current notification?
CloseNotification(partOf);
}
+ } else if (bodyFinal.isEmpty()) {
+ //some ridiculous apps will send just a title (#372112), in that case, treat \
it as though there's only a body + bodyFinal = summary;
+ summaryFinal = app_name;
}
uint id = replaces_id ? replaces_id : m_nextId++;
@@ -261,7 +267,6 @@ uint NotificationsEngine::Notify(const QString &app_name, uint \
replaces_id,
const QString source = QStringLiteral("notification %1").arg(id);
- QString bodyFinal = (partOf == 0 ? body : _body);
// First trim whitespace from beginning and end
bodyFinal = bodyFinal.trimmed();
// Now replace all \ns with <br/>
@@ -285,7 +290,7 @@ uint NotificationsEngine::Notify(const QString &app_name, uint \
replaces_id, notificationData.insert(QStringLiteral("eventId"), eventId);
notificationData.insert(QStringLiteral("appName"), appname_str);
notificationData.insert(QStringLiteral("appIcon"), app_icon);
- notificationData.insert(QStringLiteral("summary"), summary);
+ notificationData.insert(QStringLiteral("summary"), summaryFinal);
notificationData.insert(QStringLiteral("body"), bodyFinal);
notificationData.insert(QStringLiteral("actions"), actions);
notificationData.insert(QStringLiteral("isPersistent"), isPersistent);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic