ai chat: make messages copyable

This commit is contained in:
end-4
2025-05-05 13:29:59 +02:00
parent 9a1e0633a1
commit ddf6181271
2 changed files with 15 additions and 2 deletions
@@ -1,7 +1,7 @@
import "root:/modules/common/functions/icons.js" as Icons
import "root:/services/"
import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/modules/common/functions/icons.js" as Icons
import Qt5Compat.GraphicalEffects
import QtQuick
import QtQuick.Layouts
@@ -123,17 +123,30 @@ Rectangle {
}
}
StyledText { // Message
TextEdit { // Message
id: messageText
Layout.fillWidth: true
Layout.margins: messagePadding
readOnly: true
selectByMouse: true
font.family: Appearance.font.family.reading
font.hintingPreference: Font.PreferNoHinting // Prevent weird bold text
font.pixelSize: Appearance.font.pixelSize.small
wrapMode: Text.WordWrap
color: messageData.thinking ? Appearance.colors.colSubtext : Appearance.colors.colOnLayer1
textFormat: Text.MarkdownText
text: messageData.thinking ? qsTr("Waiting for response...") : root.messageData.content
Keys.onPressed: (event) => {
if (event.key === Qt.Key_Control) { // Prevent de-select
event.accepted = true
}
if ((event.key === Qt.Key_C) && event.modifiers == Qt.ControlModifier) {
messageText.copy()
event.accepted = true
}
}
onLinkActivated: (link) => {
Qt.openUrlExternally(link)