summary refs log tree commit diff
path: root/src/notifications
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2021-02-20 11:52:05 -0500
committerNicolas Werner <nicolas.werner@hotmail.de>2021-03-17 19:17:14 +0100
commitc38c6fe49e9c732f6e784cda04414d82bc092c48 (patch)
treef4cc7cc6c0e5ac1030430381dd0cf1931df111db /src/notifications
parentFix Linux HTML notifications (diff)
downloadnheko-c38c6fe49e9c732f6e784cda04414d82bc092c48.tar.xz
Format notifications according to the FreeDesktop specification
Diffstat (limited to 'src/notifications')
-rw-r--r--src/notifications/ManagerLinux.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp

index c6326254..adaa0a35 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp
@@ -151,15 +151,26 @@ NotificationsManager::notificationClosed(uint id, uint reason) notificationIds.remove(id); } +/** + * @param text This should be an HTML-formatted string. + * + * If D-Bus says that notifications can have body markup, this function will + * automatically format the notification to follow the supported HTML subset + * specified at https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/Markup/ + */ QString NotificationsManager::formatNotification(const QString &text) { static auto capabilites = dbus.call("GetCapabilities").arguments(); for (auto x : capabilites) if (x.toStringList().contains("body-markup")) - return utils::markdownToHtml(text); + return QString(text) + .replace("<em>", "<i>") + .replace("</em>", "</i>") + .replace("<strong>", "<b>") + .replace("</strong>", "</b>"); - return QTextDocumentFragment::fromHtml(utils::markdownToHtml(text)).toPlainText(); + return QTextDocumentFragment::fromHtml(text).toPlainText(); } /**