From e369f23bb4c358ccec1c1bbec45eabb62daa270b Mon Sep 17 00:00:00 2001 From: Angela Mazzurco Date: Wed, 19 Jul 2017 16:56:17 +0200 Subject: [PATCH] Add link detection on bubbles --- retroshare-qml-app/src/ChatBubbleDelegate.qml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/retroshare-qml-app/src/ChatBubbleDelegate.qml b/retroshare-qml-app/src/ChatBubbleDelegate.qml index 7b02f6cf9..8f94320c9 100644 --- a/retroshare-qml-app/src/ChatBubbleDelegate.qml +++ b/retroshare-qml-app/src/ChatBubbleDelegate.qml @@ -3,6 +3,7 @@ import QtQuick.Layouts 1.2 import QtQuick.Controls 2.0 import "." // To load styles import "./components" +import "URI.js" as UriJs Item { @@ -80,7 +81,11 @@ Item Text { id: mesageText - text: model.msg + text: UriJs.URI.withinString(model.msg, function(url) + { + return "" + url + ""; + }) + width: rootBubble.width * styles.bubbleMaxWidth + timeText.width anchors.left: (model.incoming)? parent.left : undefined anchors.right:(!model.incoming)? parent.right : undefined @@ -89,6 +94,10 @@ Item anchors.leftMargin: styles.lMarginBubble anchors.rightMargin: styles.rMarginBubble + + textFormat: Text.RichText + onLinkActivated: Qt.openUrlExternally(link) + // Used for the correct alineation when the message must be on right horizontalAlignment:(!model.incoming && mesageText.implicitWidth <= (rootBubble.width * styles.bubbleMaxWidth) @@ -96,6 +105,7 @@ Item wrapMode: Text.Wrap font.pixelSize: styles.messageTextSize + } }