context menu now doesn't select items, just temporarily, statuses and messahes html wrapping fix

This commit is contained in:
Blue 2020-04-12 18:55:05 +03:00
parent a77dfd191a
commit 29c7d31c89
11 changed files with 104 additions and 32 deletions

View file

@ -27,3 +27,22 @@ QString Shared::generateUUID()
uuid_unparse_lower(uuid, uuid_str);
return uuid_str;
}
static const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])("
"(?:https?|ftp):\\/\\/"
"\\w+"
"(?:"
"[\\w\\.\\/\\:\\;\\?\\&\\=\\@\\%\\#\\+\\-]?"
"(?:"
"\\([\\w\\.\\/\\:\\;\\?\\&\\=\\@\\%\\#\\+\\-]+\\)"
")?"
")*"
")");
QString Shared::processMessageBody(const QString& msg)
{
QString processed = msg.toHtmlEscaped();
processed.replace(urlReg, "<a href=\"\\1\">\\1</a>");
return "<p style=\"white-space: pre-wrap;\">" + processed + "</p>";
}

View file

@ -21,6 +21,7 @@
#include <QString>
#include <QColor>
#include <QRegularExpression>
#include <uuid/uuid.h>
#include <vector>
@ -28,6 +29,7 @@
namespace Shared {
QString generateUUID();
QString processMessageBody(const QString& msg);
static const std::vector<QColor> colorPalette = {
QColor(244, 27, 63),