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

Simplify determination of whether markup is supported

This should also result in a speed increase (however slight), since the capabilities are now sorted through only once.
parent 4150d75b
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@
#include <QImage>
#include <QTextDocumentFragment>
#include <functional>
#include "Utils.h"
NotificationsManager::NotificationsManager(QObject *parent)
......@@ -161,14 +163,18 @@ NotificationsManager::notificationClosed(uint id, uint reason)
QString
NotificationsManager::formatNotification(const QString &text)
{
static auto capabilites = dbus.call("GetCapabilities").arguments();
for (auto x : capabilites)
if (x.toStringList().contains("body-markup"))
return QString(text)
.replace("<em>", "<i>")
.replace("</em>", "</i>")
.replace("<strong>", "<b>")
.replace("</strong>", "</b>");
static const auto hasMarkup = std::invoke([this]() -> bool {
for (auto x : dbus.call("GetCapabilities").arguments())
if (x.toStringList().contains("body-markup"))
return true;
return false;
});
if (hasMarkup)
return QString(text)
.replace("<em>", "<i>")
.replace("</em>", "</i>")
.replace("<strong>", "<b>")
.replace("</strong>", "</b>");
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