CodeBlock: полный текст без скролла, только иконка 📋

- Убран ScrollView, теперь Rectangle + TextEdit с anchors.fill и implicitHeight: contentHeight+20 — весь код виден целиком, без колёсика
- Кнопка копирования: только 📋 (было '📋 Копировать'), при копировании ✓, hover/active Qt.rgba, размер под иконку
- TextEdit RichText Wrap, JetBrains Mono 13, selectByMouse, contentHeight
This commit is contained in:
2026-09-01 21:56:29 +03:00
parent bfd955a3f9
commit 7e494afbe4
+17 -32
View File
@@ -73,9 +73,9 @@ Rectangle {
Label { Label {
id: copyLabel id: copyLabel
anchors.centerIn: parent anchors.centerIn: parent
text: copyButton.copied ? "✓ Скопировано" : "📋 Копировать" text: copyButton.copied ? "✓" : "📋"
color: copyButton.copied ? "#6ab2f6" : "#ffffff" color: copyButton.copied ? "#6ab2f6" : "#ffffff"
font.pixelSize: 11 font.pixelSize: 13
font.family: "-apple-system, sans-serif" font.family: "-apple-system, sans-serif"
} }
@@ -95,42 +95,27 @@ Rectangle {
} }
} }
// Code area - like real editor // Code area - как в редакторе, но без скролла — весь текст виден целиком
Rectangle { Rectangle {
width: parent.width width: parent.width
color: Qt.rgba(0,0,0,0.22) color: Qt.rgba(0,0,0,0.22)
radius: 8 radius: 8
// height based on content - use contentHeight for accurate implicitHeight: codeText.contentHeight + 20
implicitHeight: Math.max(40, codeText.contentHeight + 20)
ScrollView { TextEdit {
id: codeScroll id: codeText
anchors.fill: parent anchors.fill: parent
anchors.margins: 8 anchors.margins: 10
clip: true text: root.highlightedText.length > 0 ? root.highlightedText : root.code
ScrollBar.horizontal.policy: ScrollBar.AsNeeded textFormat: TextEdit.RichText
ScrollBar.vertical.policy: ScrollBar.AsNeeded wrapMode: TextEdit.Wrap
readOnly: true
TextArea { selectByMouse: true
id: codeText color: "#ffffff"
width: codeScroll.availableWidth selectionColor: "#3a6ea5"
readOnly: true selectedTextColor: "#ffffff"
selectByMouse: true font.family: "JetBrains Mono, Fira Code, Menlo, Consolas, monospace"
textFormat: Text.RichText font.pixelSize: 13
wrapMode: Text.Wrap
color: "#ffffff"
selectionColor: "#3a6ea5"
selectedTextColor: "#ffffff"
font.family: "JetBrains Mono, Fira Code, Menlo, Consolas, monospace"
font.pixelSize: 13
tabStopDistance: 32
text: root.highlightedText.length > 0 ? root.highlightedText : root.code
background: Rectangle { color: "transparent" }
// Ensure contentHeight is updated
onTextChanged: {
// Force update
}
}
} }
} }
} }