Changeset View
Changeset View
Standalone View
Standalone View
plugins/notifications/notification.cpp
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #include "notification.h" | 21 | #include "notification.h" | ||
22 | 22 | | |||
23 | #include <KNotification> | 23 | #include <KNotification> | ||
24 | #include <QIcon> | 24 | #include <QIcon> | ||
25 | #include <QString> | 25 | #include <QString> | ||
26 | #include <QUrl> | 26 | #include <QUrl> | ||
27 | #include <QPixmap> | 27 | #include <QPixmap> | ||
28 | #include <KLocalizedString> | ||||
28 | 29 | | |||
29 | #include <core/filetransferjob.h> | 30 | #include <core/filetransferjob.h> | ||
30 | 31 | | |||
31 | 32 | | |||
32 | Notification::Notification(const NetworkPackage& np, QObject* parent) | 33 | Notification::Notification(const NetworkPackage& np, QObject* parent) | ||
33 | : QObject(parent) | 34 | : QObject(parent) | ||
34 | { | 35 | { | ||
35 | mImagesDir = QDir::temp().absoluteFilePath(QStringLiteral("kdeconnect")); | 36 | mImagesDir = QDir::temp().absoluteFilePath(QStringLiteral("kdeconnect")); | ||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 112 | } else { | |||
112 | mIconPath = mImagesDir.absoluteFilePath(filename); | 113 | mIconPath = mImagesDir.absoluteFilePath(filename); | ||
113 | QUrl destinationUrl(mIconPath); | 114 | QUrl destinationUrl(mIconPath); | ||
114 | FileTransferJob* job = np.createPayloadTransferJob(destinationUrl); | 115 | FileTransferJob* job = np.createPayloadTransferJob(destinationUrl); | ||
115 | job->start(); | 116 | job->start(); | ||
116 | connect(job, &FileTransferJob::result, this, &Notification::applyIconAndShow); | 117 | connect(job, &FileTransferJob::result, this, &Notification::applyIconAndShow); | ||
117 | } | 118 | } | ||
118 | } | 119 | } | ||
119 | 120 | | |||
121 | if(!mRequestReplyId.isEmpty()) { | ||||
122 | mNotification->setActions( QStringList(i18n("Reply")) ); | ||||
123 | connect(mNotification, &KNotification::action1Activated, this, &Notification::replyRequested); | ||||
124 | } | ||||
125 | | ||||
120 | connect(mNotification, &KNotification::closed, this, &Notification::closed); | 126 | connect(mNotification, &KNotification::closed, this, &Notification::closed); | ||
121 | 127 | | |||
122 | return mNotification; | 128 | return mNotification; | ||
123 | } | 129 | } | ||
124 | 130 | | |||
125 | void Notification::closed() | 131 | void Notification::closed() | ||
126 | { | 132 | { | ||
127 | mClosed = true; | 133 | mClosed = true; | ||
128 | } | 134 | } | ||
129 | 135 | | |||
130 | void Notification::parseNetworkPackage(const NetworkPackage &np) | 136 | void Notification::parseNetworkPackage(const NetworkPackage &np) | ||
131 | { | 137 | { | ||
132 | mInternalId = np.get<QString>(QStringLiteral("id")); | 138 | mInternalId = np.get<QString>(QStringLiteral("id")); | ||
133 | mAppName = np.get<QString>(QStringLiteral("appName")); | 139 | mAppName = np.get<QString>(QStringLiteral("appName")); | ||
134 | mTicker = np.get<QString>(QStringLiteral("ticker")); | 140 | mTicker = np.get<QString>(QStringLiteral("ticker")); | ||
135 | mTitle = np.get<QString>(QStringLiteral("title")); | 141 | mTitle = np.get<QString>(QStringLiteral("title")); | ||
136 | mText = np.get<QString>(QStringLiteral("text")); | 142 | mText = np.get<QString>(QStringLiteral("text")); | ||
137 | mDismissable = np.get<bool>(QStringLiteral("isClearable")); | 143 | mDismissable = np.get<bool>(QStringLiteral("isClearable")); | ||
138 | mHasIcon = np.hasPayload(); | 144 | mHasIcon = np.hasPayload(); | ||
139 | mSilent = np.get<bool>(QStringLiteral("silent")); | 145 | mSilent = np.get<bool>(QStringLiteral("silent")); | ||
140 | mPayloadHash = np.get<QString>(QStringLiteral("payloadHash")); | 146 | mPayloadHash = np.get<QString>(QStringLiteral("payloadHash")); | ||
147 | mRequestReplyId = np.get<QString>(QStringLiteral("requestReplyId"), QStringLiteral("")); | ||||
apol: QString() to create an empty string. | |||||
141 | } | 148 | } | ||
142 | 149 | |
QString() to create an empty string.