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 <treat.adam@gmail.com>
This commit is contained in:
AT 2024-06-28 12:54:12 -04:00 committed by GitHub
parent 81bbeef5b3
commit 426aa5eb47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 { Menu {
id: conversationContextMenu id: conversationContextMenu
MenuItem { MenuItem {
@ -1320,7 +1330,8 @@ Rectangle {
} }
Text { Text {
id: device id: statusBar
property string hoveredLink: ""
anchors.top: textInputView.bottom anchors.top: textInputView.bottom
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
@ -1330,10 +1341,13 @@ Rectangle {
horizontalAlignment: Qt.AlignRight horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
color: theme.mutedTextColor color: theme.mutedTextColor
visible: currentChat.tokenSpeed !== "" visible: currentChat.tokenSpeed !== "" || hoveredLink !== ""
elide: Text.ElideRight elide: Text.ElideRight
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: { text: {
if (hoveredLink !== "")
return hoveredLink
const segments = [currentChat.tokenSpeed]; const segments = [currentChat.tokenSpeed];
const device = currentChat.device; const device = currentChat.device;
const backend = currentChat.deviceBackend; const backend = currentChat.deviceBackend;