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.
This commit is contained in:
parent
4150d75be7
commit
4a86e14d04
@ -9,6 +9,8 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
NotificationsManager::NotificationsManager(QObject *parent)
|
NotificationsManager::NotificationsManager(QObject *parent)
|
||||||
@ -161,14 +163,18 @@ NotificationsManager::notificationClosed(uint id, uint reason)
|
|||||||
QString
|
QString
|
||||||
NotificationsManager::formatNotification(const QString &text)
|
NotificationsManager::formatNotification(const QString &text)
|
||||||
{
|
{
|
||||||
static auto capabilites = dbus.call("GetCapabilities").arguments();
|
static const auto hasMarkup = std::invoke([this]() -> bool {
|
||||||
for (auto x : capabilites)
|
for (auto x : dbus.call("GetCapabilities").arguments())
|
||||||
if (x.toStringList().contains("body-markup"))
|
if (x.toStringList().contains("body-markup"))
|
||||||
return QString(text)
|
return true;
|
||||||
.replace("<em>", "<i>")
|
return false;
|
||||||
.replace("</em>", "</i>")
|
});
|
||||||
.replace("<strong>", "<b>")
|
if (hasMarkup)
|
||||||
.replace("</strong>", "</b>");
|
return QString(text)
|
||||||
|
.replace("<em>", "<i>")
|
||||||
|
.replace("</em>", "</i>")
|
||||||
|
.replace("<strong>", "<b>")
|
||||||
|
.replace("</strong>", "</b>");
|
||||||
|
|
||||||
return QTextDocumentFragment::fromHtml(text).toPlainText();
|
return QTextDocumentFragment::fromHtml(text).toPlainText();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user