made links in system messages clickable

needed to make sub ticket in sub only chat accessible.
This commit is contained in:
TranRed 2019-05-01 12:07:35 +02:00 committed by pajlada
parent 30430b0fb3
commit 7ad6db550d

View file

@ -95,8 +95,23 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text)
: MessageBuilder() : MessageBuilder()
{ {
this->emplace<TimestampElement>(); this->emplace<TimestampElement>();
this->emplace<TextElement>(text, MessageElementFlag::Text,
MessageColor::System); // check system message for links
// (e.g. needed for sub ticket message in sub only mode)
QStringList textFragments = text.split(QRegularExpression("\\s"));
for (const auto &word : textFragments)
{
auto linkString = this->matchLink(word);
if (linkString.isEmpty())
{
this->emplace<TextElement>(word, MessageElementFlag::Text,
MessageColor::System);
}
else
{
this->addLink(word, linkString);
}
}
this->message().flags.set(MessageFlag::System); this->message().flags.set(MessageFlag::System);
this->message().flags.set(MessageFlag::DoNotTriggerNotification); this->message().flags.set(MessageFlag::DoNotTriggerNotification);
this->message().messageText = text; this->message().messageText = text;