mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
fix: Copy button can flow in expanded codeblock
This commit is contained in:
@@ -272,6 +272,7 @@ ChatRootView {
|
||||
id: chatItemInstance
|
||||
|
||||
width: parent.width
|
||||
chatViewport: chatListView
|
||||
msgModel: root.chatModel.processMessageContent(model.content)
|
||||
messageAttachments: model.attachments
|
||||
messageImages: model.images
|
||||
|
||||
@@ -30,6 +30,7 @@ Rectangle {
|
||||
property int textFontSize: Qt.application.font.pointSize
|
||||
property int codeFontSize: Qt.application.font.pointSize
|
||||
property int textFormat: 0
|
||||
property Flickable chatViewport: null
|
||||
|
||||
property bool isUserMessage: false
|
||||
property int messageIndex: -1
|
||||
@@ -259,6 +260,7 @@ Rectangle {
|
||||
language: itemData.language
|
||||
codeFontFamily: root.codeFontFamily
|
||||
codeFontSize: root.codeFontSize
|
||||
viewport: root.chatViewport
|
||||
}
|
||||
|
||||
component AttachmentComponent : Rectangle {
|
||||
|
||||
@@ -13,6 +13,7 @@ Rectangle {
|
||||
property string code: ""
|
||||
property string language: ""
|
||||
property bool expanded: false
|
||||
property Flickable viewport: null
|
||||
|
||||
property alias codeFontFamily: codeText.font.family
|
||||
property alias codeFontSize: codeText.font.pointSize
|
||||
@@ -122,7 +123,16 @@ Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 5
|
||||
|
||||
y: 5
|
||||
y: {
|
||||
if (!root.expanded || !root.viewport)
|
||||
return 5
|
||||
const flick = root.viewport
|
||||
const topInContent = root.mapToItem(flick.contentItem, 0, 0).y
|
||||
const topInView = topInContent - flick.contentY
|
||||
const desired = topInView < 0 ? (-topInView + 5) : 5
|
||||
const maxY = Math.max(5, root.height - copyButton.height - 5)
|
||||
return Math.max(5, Math.min(desired, maxY))
|
||||
}
|
||||
text: qsTr("Copy")
|
||||
|
||||
onClicked: {
|
||||
|
||||
Reference in New Issue
Block a user