From aa105e0c2cf1df9ac560de8bb8f70adfef78cac2 Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 17 Apr 2019 10:54:55 -0400 Subject: [PATCH] Make links in messages clickable --- harmonyqml/components/base/RichLabel.qml | 23 +++++++++++++++++++ harmonyqml/components/chat/MessageContent.qml | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 harmonyqml/components/base/RichLabel.qml diff --git a/harmonyqml/components/base/RichLabel.qml b/harmonyqml/components/base/RichLabel.qml new file mode 100644 index 00000000..c454d9a8 --- /dev/null +++ b/harmonyqml/components/base/RichLabel.qml @@ -0,0 +1,23 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 + +HLabel { + id: "label" + textFormat: Text.RichText + + MouseArea { + id: "mouseArea" + anchors.fill: parent + hoverEnabled: true + + onPositionChanged: function (event) { + cursorShape = label.linkAt(event.x, event.y) ? + Qt.PointingHandCursor : Qt.ArrowCursor + } + + onClicked: function(event) { + var link = label.linkAt(event.x, event.y) + if (link) { Qt.openUrlExternally(link) } + } + } +} diff --git a/harmonyqml/components/chat/MessageContent.qml b/harmonyqml/components/chat/MessageContent.qml index f13c18ef..dd94b010 100644 --- a/harmonyqml/components/chat/MessageContent.qml +++ b/harmonyqml/components/chat/MessageContent.qml @@ -30,7 +30,7 @@ Row { topPadding: verticalPadding } - Base.HLabel { + Base.RichLabel { id: contentLabel //text: (isOwn ? "" : content + "  ") + //"" +