Skip to content
Snippets Groups Projects
Verified Commit c38c6fe4 authored by Loren Burkholder's avatar Loren Burkholder Committed by Nicolas Werner
Browse files

Format notifications according to the FreeDesktop specification

parent dcd9b80d
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment