From 426aa5eb478ff63a59355a3b9c2338fabc1d21df Mon Sep 17 00:00:00 2001 From: AT Date: Fri, 28 Jun 2024 12:54:12 -0400 Subject: [PATCH] Go ahead and try to handle links in the text by opening them externally. (#2479) Handle links in the text by opening them externally. Signed-off-by: Adam Treat --- gpt4all-chat/qml/ChatView.qml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gpt4all-chat/qml/ChatView.qml b/gpt4all-chat/qml/ChatView.qml index 38a66c1f..76956141 100644 --- a/gpt4all-chat/qml/ChatView.qml +++ b/gpt4all-chat/qml/ChatView.qml @@ -844,6 +844,16 @@ Rectangle { } } + onLinkActivated: function(link) { + if (!currentResponse || !currentChat.responseInProgress) + Qt.openUrlExternally(link) + } + + onLinkHovered: function (link) { + if (!currentResponse || !currentChat.responseInProgress) + statusBar.hoveredLink = link + } + Menu { id: conversationContextMenu MenuItem { @@ -1320,7 +1330,8 @@ Rectangle { } Text { - id: device + id: statusBar + property string hoveredLink: "" anchors.top: textInputView.bottom anchors.bottom: parent.bottom anchors.right: parent.right @@ -1330,10 +1341,13 @@ Rectangle { horizontalAlignment: Qt.AlignRight verticalAlignment: Qt.AlignVCenter color: theme.mutedTextColor - visible: currentChat.tokenSpeed !== "" + visible: currentChat.tokenSpeed !== "" || hoveredLink !== "" elide: Text.ElideRight wrapMode: Text.WordWrap text: { + if (hoveredLink !== "") + return hoveredLink + const segments = [currentChat.tokenSpeed]; const device = currentChat.device; const backend = currentChat.deviceBackend;