Hrvoje Senjan 2015-06-28 19:14:50 +00:00 committed by Git OBS Bridge
parent 5f55668976
commit d2ec0c9641

View File

@ -1,154 +0,0 @@
From a12bb76502952749c069b9ab70ac61ee1353079b Mon Sep 17 00:00:00 2001
From: Martin Klapetek <mklapetek@kde.org>
Date: Thu, 28 May 2015 17:21:17 +0200
Subject: [PATCH 2/5] Reuse the existing Notify method for Notification's
DataEngine createNotification call
REVIEW: 123923
BUG: 342605
FIXED-IN: 5.3.2
---
applets/notifications/package/contents/ui/Jobs.qml | 25 +++++++++++-----------
.../package/contents/ui/Notifications.qml | 7 ++++++
dataengines/notifications/notificationaction.cpp | 6 +++---
dataengines/notifications/notifications.operations | 5 ++++-
dataengines/notifications/notificationsengine.cpp | 18 +++++-----------
dataengines/notifications/notificationsengine.h | 3 ++-
6 files changed, 34 insertions(+), 30 deletions(-)
diff --git a/applets/notifications/package/contents/ui/Jobs.qml b/applets/notifications/package/contents/ui/Jobs.qml
index 3307d38b9a1ea54b075b61f023b083eae08428ac..d16a55d9b26f966f8a5ed80439bdb780c2a8e7bf 100644
--- a/applets/notifications/package/contents/ui/Jobs.qml
+++ b/applets/notifications/package/contents/ui/Jobs.qml
@@ -80,18 +80,19 @@ Column {
summary = infoMessage ? i18nc("the job, which can be anything, failed to complete", "%1: Failed", infoMessage) : i18n("Job Failed")
}
- notifications.addNotification({
- source: source,
- appIcon: runningJobs[source]["appIconName"],
- appName: runningJobs[source]["appName"],
- summary: summary,
- body: errorText || message,
- isPersistent: true,
- expireTimeout: 6000,
- urgency: 0,
- configurable: false,
- actions: !error && UrlHelper.isUrlValid(message) ? [{"id": message, "text": i18n("Open...")}] : [] // If the source contains "Job", it tries to open the "id" value (which is "message")
- })
+ var op = [];
+ op["source"] = source;
+ op["appIcon"] = runningJobs[source]["appIconName"];
+ op["appName"] = runningJobs[source]["appName"];
+ op["summary"] = summary;
+ op["body"] = errorText || message;
+ op["isPersistent"] = true;
+ op["expireTimeout"] = 6000;
+ op["urgency"] = 0;
+ op["configurable"] = false;
+ op["actions"] = !error && UrlHelper.isUrlValid(message) ? [message, i18n("Open...")] : []; // If the source contains "Job", it tries to open the "id" value (which is "message")
+
+ notifications.createNotification(op);
delete runningJobs[source]
}
diff --git a/applets/notifications/package/contents/ui/Notifications.qml b/applets/notifications/package/contents/ui/Notifications.qml
index 333f5b84202a267227f466d26bb6cc571c3af1e9..5571a7608c9ece18e5475bb80c5fb2accf905b6b 100644
--- a/applets/notifications/package/contents/ui/Notifications.qml
+++ b/applets/notifications/package/contents/ui/Notifications.qml
@@ -98,6 +98,13 @@ Column {
op["appRealName"] = appRealName;
service.startOperationCall(op)
}
+ function createNotification(data) {
+ var service = notificationsSource.serviceForSource("notification");
+ var op = service.operationDescription("createNotification");
+ // add everything from "data" to "op"
+ for (var attrname in data) { op[attrname] = data[attrname]; }
+ service.startOperationCall(op);
+ }
function closeNotification(source) {
var service = notificationsSource.serviceForSource(source)
diff --git a/dataengines/notifications/notificationaction.cpp b/dataengines/notifications/notificationaction.cpp
index db27cb31055668f58291c36bd70314df09000236..5302f7808fd43c924a3f7b1fd7cfc0acba45c500 100644
--- a/dataengines/notifications/notificationaction.cpp
+++ b/dataengines/notifications/notificationaction.cpp
@@ -59,9 +59,9 @@ void NotificationAction::start()
parameters().value("appIcon").toString(),
parameters().value("summary").toString(),
parameters().value("body").toString(),
- parameters().value("timeout").toInt(),
- false,
- QString()
+ parameters().value("expireTimeout").toInt(),
+ QString(),
+ parameters().value("actions").toStringList()
);
setResult(rv);
} else if (operationName() == "configureNotification") {
diff --git a/dataengines/notifications/notifications.operations b/dataengines/notifications/notifications.operations
index 93b7f0c5b37e4b3a0c2379daa6e28e755e1aac03..046776ec1af981d7fb23db9ddb9bd9d34ec55300 100644
--- a/dataengines/notifications/notifications.operations
+++ b/dataengines/notifications/notifications.operations
@@ -23,9 +23,12 @@
<entry name="body" type="String">
<label>The whole text of the notification</label>
</entry>
- <entry name="timeout" type="Int">
+ <entry name="expireTimeout" type="Int">
<label>The timeout after which the notification will be closed</label>
</entry>
+ <entry name="actions" type="StringList">
+ <label>List of actions in the format of [{"id": "id-of-the-action", "text": i18n("User visible text")}], </label>
+ </entry>
</group>
<group name="configureNotification">
diff --git a/dataengines/notifications/notificationsengine.cpp b/dataengines/notifications/notificationsengine.cpp
index 37a11dd1f70bc7692112be1d51918a39682969d9..509f349278f6883f509276b59f088418469a3797 100644
--- a/dataengines/notifications/notificationsengine.cpp
+++ b/dataengines/notifications/notificationsengine.cpp
@@ -354,20 +354,12 @@ QString NotificationsEngine::GetServerInformation(QString& vendor, QString& vers
return "Plasma";
}
-int NotificationsEngine::createNotification(const QString &appName, const QString &appIcon, const QString &summary, const QString &body, int timeout, bool configurable, const QString &appRealName)
+int NotificationsEngine::createNotification(const QString &appName, const QString &appIcon, const QString &summary,
+ const QString &body, int timeout, const QString &appRealName, const QStringList &actions)
{
- const QString source = QString("notification %1").arg(++m_nextId);
- Plasma::DataEngine::Data notificationData;
- notificationData.insert("id", QString::number(m_nextId));
- notificationData.insert("appName", appName);
- notificationData.insert("appIcon", appIcon);
- notificationData.insert("summary", summary);
- notificationData.insert("body", body);
- notificationData.insert("expireTimeout", timeout);
- notificationData.insert("configurable", configurable);
- notificationData.insert("appRealName", appRealName);
-
- setData(source, notificationData);
+ QVariantMap hints;
+ hints.insert("x-kde-appname", appRealName);
+ Notify(appName, 0, appIcon, summary, body, actions, hints, timeout);
return m_nextId;
}
diff --git a/dataengines/notifications/notificationsengine.h b/dataengines/notifications/notificationsengine.h
index d8507d0faafe065db89c1a11cd4f2ff3e741c220..7810787776206c4a74d2d831e3c8f367bfcc7618 100644
--- a/dataengines/notifications/notificationsengine.h
+++ b/dataengines/notifications/notificationsengine.h
@@ -53,7 +53,8 @@ public:
QString GetServerInformation(QString& vendor, QString& version, QString& specVersion);
- int createNotification(const QString &appName, const QString &appIcon, const QString &summary, const QString &body, int timeout, bool configurable, const QString &appRealName);
+ int createNotification(const QString &appName, const QString &appIcon, const QString &summary,
+ const QString &body, int timeout, const QString &appRealName, const QStringList &actions);
void configureNotification(const QString &appName);
--
2.4.1