From 4f236c6bf45cc58ca60bf7d4b7a4a288d28cf7b9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 17 Apr 2014 15:20:12 -0700 Subject: [PATCH] Add hifi link handling in chat for usernames and locations --- interface/src/ui/ChatWindow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index e1ee30b4b9..9679e73132 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -29,6 +29,7 @@ const int NUM_MESSAGES_TO_TIME_STAMP = 20; const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)"); +const QRegularExpression regexHifiLinks("\\s([#@]\\S+)"); ChatWindow::ChatWindow(QWidget* parent) : FramelessDialog(parent, 0, POSITION_RIGHT), @@ -280,7 +281,10 @@ void ChatWindow::messageReceived(const QXmppMessage& message) { } messageArea->document()->setDefaultStyleSheet("a { text-decoration: none; font-weight: bold; color: #267077;}"); - messageArea->setHtml(userLabel + message.body().toHtmlEscaped().replace(regexLinks, "\\1")); + QString messageText = message.body().toHtmlEscaped(); + messageText = messageText.replace(regexLinks, "\\1"); + messageText = messageText.replace(regexHifiLinks, "\\1"); + messageArea->setHtml(userLabel + messageText); bool atBottom = isAtBottom();