From 4a86e14d04d2f20d02f41801e755e1b2be803e48 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 20 Feb 2021 12:00:13 -0500 Subject: [PATCH] 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. --- src/notifications/ManagerLinux.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index adaa0a35..ab4a6d93 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -9,6 +9,8 @@ #include #include +#include + #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("", "") - .replace("", "") - .replace("", "") - .replace("", ""); + 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("", "") + .replace("", "") + .replace("", "") + .replace("", ""); return QTextDocumentFragment::fromHtml(text).toPlainText(); }