Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/notification.cpp
Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Line(s) | |||||
266 | 266 | | |||
267 | QSize Notification::Private::maximumImageSize() | 267 | QSize Notification::Private::maximumImageSize() | ||
268 | { | 268 | { | ||
269 | return QSize(256, 256); | 269 | return QSize(256, 256); | ||
270 | } | 270 | } | ||
271 | 271 | | |||
272 | KService::Ptr Notification::Private::serviceForDesktopEntry(const QString &desktopEntry) | 272 | KService::Ptr Notification::Private::serviceForDesktopEntry(const QString &desktopEntry) | ||
273 | { | 273 | { | ||
274 | KService::Ptr service = KService::serviceByDesktopName(desktopEntry); | 274 | KService::Ptr service; | ||
275 | | ||||
276 | if (desktopEntry.startsWith(QLatin1Char('/'))) { | ||||
277 | service = KService::serviceByDesktopPath(desktopEntry); | ||||
278 | } else { | ||||
279 | service = KService::serviceByDesktopName(desktopEntry); | ||||
280 | } | ||||
275 | 281 | | |||
276 | if (!service) { | 282 | if (!service) { | ||
277 | const QString lowerDesktopEntry = desktopEntry.toLower(); | 283 | const QString lowerDesktopEntry = desktopEntry.toLower(); | ||
278 | service = KService::serviceByDesktopName(lowerDesktopEntry); | 284 | service = KService::serviceByDesktopName(lowerDesktopEntry); | ||
279 | } | 285 | } | ||
280 | 286 | | |||
281 | // Try if it's a renamed flatpak | 287 | // Try if it's a renamed flatpak | ||
282 | if (!service) { | 288 | if (!service) { | ||
Show All 11 Lines | 296 | for (const QString &name : names) { | |||
294 | } | 300 | } | ||
295 | } | 301 | } | ||
296 | } | 302 | } | ||
297 | } | 303 | } | ||
298 | 304 | | |||
299 | return service; | 305 | return service; | ||
300 | } | 306 | } | ||
301 | 307 | | |||
302 | void Notification::Private::processHints(const QVariantMap &hints) | 308 | void Notification::Private::setDesktopEntry(const QString &desktopEntry) | ||
303 | { | 309 | { | ||
304 | auto end = hints.end(); | | |||
305 | | ||||
306 | desktopEntry = hints.value(QStringLiteral("desktop-entry")).toString(); | | |||
307 | | ||||
308 | QString serviceName; | 310 | QString serviceName; | ||
309 | 311 | | |||
310 | configurableService = false; | 312 | configurableService = false; | ||
311 | 313 | | |||
312 | KService::Ptr service = serviceForDesktopEntry(desktopEntry); | 314 | KService::Ptr service = serviceForDesktopEntry(desktopEntry); | ||
313 | if (service) { | 315 | if (service) { | ||
314 | desktopEntry = service->desktopEntryName(); | 316 | this->desktopEntry = service->desktopEntryName(); | ||
315 | serviceName = service->name(); | 317 | serviceName = service->name(); | ||
316 | applicationIconName = service->icon(); | 318 | applicationIconName = service->icon(); | ||
317 | configurableService = !service->noDisplay(); | 319 | configurableService = !service->noDisplay(); | ||
318 | } | 320 | } | ||
319 | 321 | | |||
320 | notifyRcName = hints.value(QStringLiteral("x-kde-appname")).toString(); | | |||
321 | const bool isDefaultEvent = (notifyRcName == defaultComponentName()); | 322 | const bool isDefaultEvent = (notifyRcName == defaultComponentName()); | ||
322 | configurableNotifyRc = false; | 323 | configurableNotifyRc = false; | ||
323 | if (!notifyRcName.isEmpty()) { | 324 | if (!notifyRcName.isEmpty()) { | ||
324 | // Check whether the application actually has notifications we can configure | 325 | // Check whether the application actually has notifications we can configure | ||
325 | KConfig config(notifyRcName + QStringLiteral(".notifyrc"), KConfig::NoGlobals); | 326 | KConfig config(notifyRcName + QStringLiteral(".notifyrc"), KConfig::NoGlobals); | ||
326 | config.addConfigSources(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | 327 | config.addConfigSources(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | ||
327 | QStringLiteral("knotifications5/") + notifyRcName + QStringLiteral(".notifyrc"))); | 328 | QStringLiteral("knotifications5/") + notifyRcName + QStringLiteral(".notifyrc"))); | ||
328 | 329 | | |||
Show All 10 Lines | |||||
339 | // also only overwrite application icon name for non-default events (or if we don't have a service icon) | 340 | // also only overwrite application icon name for non-default events (or if we don't have a service icon) | ||
340 | if (!iconName.isEmpty() && (!isDefaultEvent || applicationIconName.isEmpty())) { | 341 | if (!iconName.isEmpty() && (!isDefaultEvent || applicationIconName.isEmpty())) { | ||
341 | applicationIconName = iconName; | 342 | applicationIconName = iconName; | ||
342 | } | 343 | } | ||
343 | 344 | | |||
344 | const QRegularExpression regexp(QStringLiteral("^Event/([^/]*)$")); | 345 | const QRegularExpression regexp(QStringLiteral("^Event/([^/]*)$")); | ||
345 | configurableNotifyRc = !config.groupList().filter(regexp).isEmpty(); | 346 | configurableNotifyRc = !config.groupList().filter(regexp).isEmpty(); | ||
346 | } | 347 | } | ||
348 | } | ||||
349 | | ||||
350 | void Notification::Private::processHints(const QVariantMap &hints) | ||||
351 | { | ||||
352 | auto end = hints.end(); | ||||
353 | | ||||
354 | notifyRcName = hints.value(QStringLiteral("x-kde-appname")).toString(); | ||||
355 | | ||||
356 | setDesktopEntry(hints.value(QStringLiteral("desktop-entry")).toString()); | ||||
347 | 357 | | |||
348 | // Special override for KDE Connect since the notification is sent by kdeconnectd | 358 | // Special override for KDE Connect since the notification is sent by kdeconnectd | ||
349 | // but actually comes from a different app on the phone | 359 | // but actually comes from a different app on the phone | ||
350 | const QString applicationDisplayName = hints.value(QStringLiteral("x-kde-display-appname")).toString(); | 360 | const QString applicationDisplayName = hints.value(QStringLiteral("x-kde-display-appname")).toString(); | ||
351 | if (!applicationDisplayName.isEmpty()) { | 361 | if (!applicationDisplayName.isEmpty()) { | ||
352 | applicationName = applicationDisplayName; | 362 | applicationName = applicationDisplayName; | ||
353 | } | 363 | } | ||
354 | 364 | | |||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 527 | { | |||
518 | d->image = image; | 528 | d->image = image; | ||
519 | } | 529 | } | ||
520 | 530 | | |||
521 | QString Notification::desktopEntry() const | 531 | QString Notification::desktopEntry() const | ||
522 | { | 532 | { | ||
523 | return d->desktopEntry; | 533 | return d->desktopEntry; | ||
524 | } | 534 | } | ||
525 | 535 | | |||
536 | void Notification::setDesktopEntry(const QString &desktopEntry) | ||||
537 | { | ||||
538 | d->setDesktopEntry(desktopEntry); | ||||
539 | } | ||||
540 | | ||||
526 | QString Notification::notifyRcName() const | 541 | QString Notification::notifyRcName() const | ||
527 | { | 542 | { | ||
528 | return d->notifyRcName; | 543 | return d->notifyRcName; | ||
529 | } | 544 | } | ||
530 | 545 | | |||
531 | QString Notification::eventId() const | 546 | QString Notification::eventId() const | ||
532 | { | 547 | { | ||
533 | return d->eventId; | 548 | return d->eventId; | ||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |