From 72185c575270575ec86bce1099453017b53e348f Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Fri, 17 Jul 2026 15:03:45 +0200 Subject: [PATCH] gui: text selection, copy z-index, scroll fix --- gui/ChatPane.qml | 48 ++++++++++++++++++++++++++++++++++-------------- gui/main-kf5.qml | 43 +++++++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 28 deletions(-) diff --git a/gui/ChatPane.qml b/gui/ChatPane.qml index e80b897..d392ea8 100644 --- a/gui/ChatPane.qml +++ b/gui/ChatPane.qml @@ -163,6 +163,7 @@ Item { contentWidth: width contentHeight: paneColumn.implicitHeight boundsBehavior: Flickable.StopAtBounds + interactive: false // scroll via wheel MouseArea; enables text selection property bool _settingY: false @@ -500,6 +501,7 @@ Item { anchors.top: parent.top anchors.left: parent.left anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 32 implicitHeight: 32 @@ -563,6 +565,7 @@ Item { anchors.top: parent.top anchors.right: parent.right anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 32 implicitHeight: 32 @@ -655,6 +658,7 @@ Item { anchors.top: parent.top anchors.right: parent.right anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 24 implicitHeight: 24 @@ -715,6 +719,7 @@ Item { anchors.top: parent.top anchors.right: parent.right anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 24 implicitHeight: 24 @@ -786,16 +791,21 @@ Item { Component { id: proseSubDelegate - Text { - width: parent ? parent.width : implicitWidth + TextEdit { + id: proseText + width: parent ? parent.width : 100 + implicitWidth: 0 // prevent binding loop with parent sizing text: paneModel.linkifyFilePaths(subBlock.content || "") - wrapMode: Text.Wrap - textFormat: Text.MarkdownText + wrapMode: TextEdit.Wrap + textFormat: TextEdit.MarkdownText color: palette.text + selectionColor: palette.highlight + selectedTextColor: palette.highlightedText + readOnly: true + selectByMouse: true // Qt 6 renders Markdown text noticeably smaller than Controls text. font.pointSize: root.font.pointSize + 2 font.family: root.font.family - lineHeight: 1.3 onLinkActivated: function(link) { paneModel.openLink(link) } @@ -804,15 +814,19 @@ Item { Component { id: plainSubDelegate - Text { - width: parent ? parent.width : implicitWidth + TextEdit { + width: parent ? parent.width : 100 + implicitWidth: 0 text: subBlock.content || "" - wrapMode: Text.Wrap - textFormat: Text.PlainText + wrapMode: TextEdit.Wrap + textFormat: TextEdit.PlainText color: palette.text + selectionColor: palette.highlight + selectedTextColor: palette.highlightedText + readOnly: true + selectByMouse: true font.family: "monospace" font.pixelSize: Qt.application.font.pixelSize * 0.9 - lineHeight: 1.3 } } @@ -915,24 +929,30 @@ Item { } // Code content — show plain first, highlight lazily - Text { + TextEdit { id: codeText Layout.fillWidth: true Layout.margins: 8 + implicitWidth: 0 text: subBlock.content - textFormat: Text.PlainText - wrapMode: Text.Wrap + textFormat: TextEdit.PlainText + wrapMode: TextEdit.Wrap font.family: "monospace" font.pixelSize: Qt.application.font.pixelSize * 0.9 color: palette.text + selectionColor: palette.highlight + selectedTextColor: palette.highlightedText + readOnly: true + selectByMouse: true property bool highlighted: false + Timer { interval: 150 running: true onTriggered: { codeText.text = paneModel.highlightedHtml(subBlock.content, subBlock.language) - codeText.textFormat = Text.RichText + codeText.textFormat = TextEdit.RichText codeText.highlighted = true } } diff --git a/gui/main-kf5.qml b/gui/main-kf5.qml index 8ebbb95..669b652 100644 --- a/gui/main-kf5.qml +++ b/gui/main-kf5.qml @@ -864,6 +864,7 @@ ApplicationWindow { contentWidth: width contentHeight: paneColumn.implicitHeight boundsBehavior: Flickable.StopAtBounds + interactive: false // scroll via wheel; text not selectable in Qt5 Text property bool _settingY: false @@ -1193,6 +1194,7 @@ ApplicationWindow { anchors.top: parent.top anchors.left: parent.left anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 32 implicitHeight: 32 @@ -1256,6 +1258,7 @@ ApplicationWindow { anchors.top: parent.top anchors.right: parent.right anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 32 implicitHeight: 32 @@ -1348,6 +1351,7 @@ ApplicationWindow { anchors.top: parent.top anchors.right: parent.right anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 24 implicitHeight: 24 @@ -1408,6 +1412,7 @@ ApplicationWindow { anchors.top: parent.top anchors.right: parent.right anchors.margins: 4 + z: 10 icon.name: "edit-copy" implicitWidth: 24 implicitHeight: 24 @@ -1479,30 +1484,36 @@ ApplicationWindow { Component { id: proseSubDelegate - Text { - width: parent ? parent.width : implicitWidth + TextEdit { + width: parent ? parent.width : 100 text: chatModel.linkifyFilePaths(subBlock.content || "") - wrapMode: Text.Wrap - textFormat: Text.MarkdownText + wrapMode: TextEdit.Wrap + textFormat: TextEdit.MarkdownText color: palette.text + selectionColor: palette.highlight + selectedTextColor: palette.highlightedText + readOnly: true + selectByMouse: true font.pointSize: root.font.pointSize font.family: root.font.family - lineHeight: 1.3 onLinkActivated: chatModel.openLink(link) } } Component { id: plainSubDelegate - Text { - width: parent ? parent.width : implicitWidth + TextEdit { + width: parent ? parent.width : 100 text: subBlock.content || "" - wrapMode: Text.Wrap - textFormat: Text.PlainText + wrapMode: TextEdit.Wrap + textFormat: TextEdit.PlainText color: palette.text + selectionColor: palette.highlight + selectedTextColor: palette.highlightedText + readOnly: true + selectByMouse: true font.family: "monospace" font.pixelSize: Qt.application.font.pixelSize * 0.9 - lineHeight: 1.3 } } @@ -1601,16 +1612,20 @@ ApplicationWindow { } } - Text { + TextEdit { id: codeText Layout.fillWidth: true Layout.margins: 8 text: subBlock.content - textFormat: Text.PlainText - wrapMode: Text.Wrap + textFormat: TextEdit.PlainText + wrapMode: TextEdit.Wrap font.family: "monospace" font.pixelSize: Qt.application.font.pixelSize * 0.9 color: palette.text + selectionColor: palette.highlight + selectedTextColor: palette.highlightedText + readOnly: true + selectByMouse: true property bool highlighted: false Timer { @@ -1618,7 +1633,7 @@ ApplicationWindow { running: true onTriggered: { codeText.text = chatModel.highlightedHtml(subBlock.content, subBlock.language) - codeText.textFormat = Text.RichText + codeText.textFormat = TextEdit.RichText codeText.highlighted = true } }