mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-12-16 14:22:54 -05:00
revert: Remove compact mode for chat blocks
This commit is contained in:
@ -28,14 +28,11 @@ Rectangle {
|
||||
|
||||
property string code: ""
|
||||
property string language: ""
|
||||
|
||||
enum DisplayMode { Collapsed, Compact, Expanded }
|
||||
property int displayMode: CodeBlock.DisplayMode.Compact
|
||||
property int compactHeight: 150
|
||||
property bool expanded: false
|
||||
|
||||
property alias codeFontFamily: codeText.font.family
|
||||
property alias codeFontSize: codeText.font.pointSize
|
||||
readonly property real headerHeight: copyButton.height + 10
|
||||
readonly property real collapsedHeight: copyButton.height + 10
|
||||
|
||||
color: palette.alternateBase
|
||||
border.color: root.color.hslLightness > 0.5 ? Qt.darker(root.color, 1.3)
|
||||
@ -49,17 +46,6 @@ Rectangle {
|
||||
NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
|
||||
}
|
||||
|
||||
implicitHeight: {
|
||||
if (displayMode === CodeBlock.DisplayMode.Collapsed) {
|
||||
return headerHeight
|
||||
} else if (displayMode === CodeBlock.DisplayMode.Compact) {
|
||||
let fullHeight = headerHeight + codeText.implicitHeight + 20
|
||||
return Math.min(fullHeight, headerHeight + compactHeight)
|
||||
} else {
|
||||
return headerHeight + codeText.implicitHeight + 20
|
||||
}
|
||||
}
|
||||
|
||||
ChatUtils {
|
||||
id: utils
|
||||
}
|
||||
@ -73,17 +59,9 @@ Rectangle {
|
||||
id: header
|
||||
|
||||
width: parent.width
|
||||
height: root.headerHeight
|
||||
height: root.collapsedHeight
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (root.displayMode === CodeBlock.DisplayMode.Collapsed) {
|
||||
root.displayMode = CodeBlock.DisplayMode.Compact
|
||||
} else if (root.displayMode === CodeBlock.DisplayMode.Compact) {
|
||||
root.displayMode = CodeBlock.DisplayMode.Collapsed
|
||||
} else {
|
||||
root.displayMode = CodeBlock.DisplayMode.Compact
|
||||
}
|
||||
}
|
||||
onClicked: root.expanded = !root.expanded
|
||||
|
||||
Row {
|
||||
id: headerRow
|
||||
@ -105,35 +83,26 @@ Rectangle {
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.displayMode === CodeBlock.DisplayMode.Collapsed ? "▶" : "▼"
|
||||
text: root.expanded ? "▼" : "▶"
|
||||
font.pixelSize: 10
|
||||
color: palette.mid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: codeWrapper
|
||||
TextEdit {
|
||||
id: codeText
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: header.bottom
|
||||
bottom: parent.bottom
|
||||
margins: 10
|
||||
bottomMargin: expandButton.visible ? expandButton.height + 15 : 10
|
||||
}
|
||||
clip: true
|
||||
visible: root.displayMode !== CodeBlock.DisplayMode.Collapsed
|
||||
|
||||
TextEdit {
|
||||
id: codeText
|
||||
|
||||
width: parent.width
|
||||
text: root.code
|
||||
readOnly: true
|
||||
selectByMouse: true
|
||||
color: root.color.hslLightness > 0.5 ? "black" : "white"
|
||||
color: parent.color.hslLightness > 0.5 ? "black" : "white"
|
||||
wrapMode: Text.WordWrap
|
||||
selectionColor: palette.highlight
|
||||
|
||||
@ -143,45 +112,6 @@ Rectangle {
|
||||
onClicked: contextMenu.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: expandButton
|
||||
|
||||
property bool needsExpand: codeText.implicitHeight > compactHeight - 20
|
||||
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottomMargin: 5
|
||||
leftMargin: 10
|
||||
rightMargin: 10
|
||||
}
|
||||
height: 24
|
||||
radius: 4
|
||||
color: palette.button
|
||||
visible: needsExpand && root.displayMode !== CodeBlock.DisplayMode.Collapsed
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: root.displayMode === CodeBlock.DisplayMode.Expanded ? qsTr("▲ Show less") : qsTr("▼ Show more")
|
||||
font.pixelSize: 11
|
||||
color: palette.buttonText
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (root.displayMode === CodeBlock.DisplayMode.Expanded) {
|
||||
root.displayMode = CodeBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = CodeBlock.DisplayMode.Expanded
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Platform.Menu {
|
||||
id: contextMenu
|
||||
@ -197,26 +127,8 @@ Rectangle {
|
||||
Platform.MenuSeparator {}
|
||||
|
||||
Platform.MenuItem {
|
||||
text: root.displayMode === CodeBlock.DisplayMode.Collapsed ? qsTr("Expand") : qsTr("Collapse")
|
||||
onTriggered: {
|
||||
if (root.displayMode === CodeBlock.DisplayMode.Collapsed) {
|
||||
root.displayMode = CodeBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = CodeBlock.DisplayMode.Collapsed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Platform.MenuItem {
|
||||
text: root.displayMode === CodeBlock.DisplayMode.Expanded ? qsTr("Compact view") : qsTr("Full view")
|
||||
enabled: root.displayMode !== CodeBlock.DisplayMode.Collapsed
|
||||
onTriggered: {
|
||||
if (root.displayMode === CodeBlock.DisplayMode.Expanded) {
|
||||
root.displayMode = CodeBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = CodeBlock.DisplayMode.Expanded
|
||||
}
|
||||
}
|
||||
text: root.expanded ? qsTr("Collapse") : qsTr("Expand")
|
||||
onTriggered: root.expanded = !root.expanded
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,4 +153,21 @@ Rectangle {
|
||||
onTriggered: parent.text = qsTr("Copy")
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
when: !root.expanded
|
||||
PropertyChanges {
|
||||
target: root
|
||||
implicitHeight: root.collapsedHeight
|
||||
}
|
||||
},
|
||||
State {
|
||||
when: root.expanded
|
||||
PropertyChanges {
|
||||
target: root
|
||||
implicitHeight: header.height + codeText.implicitHeight + 10
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -24,11 +24,9 @@ Rectangle {
|
||||
id: root
|
||||
|
||||
property string thinkingContent: ""
|
||||
// property string signature: ""
|
||||
property bool isRedacted: false
|
||||
|
||||
enum DisplayMode { Collapsed, Compact, Expanded }
|
||||
property int displayMode: ThinkingBlock.DisplayMode.Compact
|
||||
property int compactHeight: 120
|
||||
property bool expanded: false
|
||||
|
||||
property alias headerOpacity: headerRow.opacity
|
||||
|
||||
@ -40,32 +38,13 @@ Rectangle {
|
||||
NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
|
||||
}
|
||||
|
||||
implicitHeight: {
|
||||
if (displayMode === ThinkingBlock.DisplayMode.Collapsed) {
|
||||
return header.height
|
||||
} else if (displayMode === ThinkingBlock.DisplayMode.Compact) {
|
||||
let fullHeight = header.height + contentColumn.height + 20
|
||||
return Math.min(fullHeight, header.height + compactHeight)
|
||||
} else {
|
||||
return header.height + contentColumn.height + 20
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: header
|
||||
|
||||
width: parent.width
|
||||
height: headerRow.height + 10
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (root.displayMode === ThinkingBlock.DisplayMode.Collapsed) {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Compact
|
||||
} else if (root.displayMode === ThinkingBlock.DisplayMode.Compact) {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Collapsed
|
||||
} else {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Compact
|
||||
}
|
||||
}
|
||||
onClicked: root.expanded = !root.expanded
|
||||
|
||||
Row {
|
||||
id: headerRow
|
||||
@ -88,31 +67,22 @@ Rectangle {
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.displayMode === ThinkingBlock.DisplayMode.Collapsed ? "▶" : "▼"
|
||||
text: root.expanded ? "▼" : "▶"
|
||||
font.pixelSize: 10
|
||||
color: palette.mid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentWrapper
|
||||
Column {
|
||||
id: contentColumn
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: header.bottom
|
||||
bottom: parent.bottom
|
||||
margins: 10
|
||||
bottomMargin: expandButton.visible ? expandButton.height + 15 : 10
|
||||
}
|
||||
clip: true
|
||||
visible: root.displayMode !== ThinkingBlock.DisplayMode.Collapsed
|
||||
|
||||
Column {
|
||||
id: contentColumn
|
||||
|
||||
width: parent.width
|
||||
spacing: 8
|
||||
|
||||
Text {
|
||||
@ -139,45 +109,30 @@ Rectangle {
|
||||
font.pixelSize: 11
|
||||
selectionColor: palette.highlight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: expandButton
|
||||
// Rectangle {
|
||||
// visible: root.signature.length > 0 && root.expanded
|
||||
// width: parent.width
|
||||
// height: signatureText.height + 10
|
||||
// color: palette.alternateBase
|
||||
// radius: 4
|
||||
|
||||
property bool needsExpand: contentColumn.height > compactHeight - 20
|
||||
// Text {
|
||||
// id: signatureText
|
||||
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottomMargin: 5
|
||||
leftMargin: 10
|
||||
rightMargin: 10
|
||||
}
|
||||
height: 24
|
||||
radius: 4
|
||||
color: palette.button
|
||||
visible: needsExpand && root.displayMode !== ThinkingBlock.DisplayMode.Collapsed
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: root.displayMode === ThinkingBlock.DisplayMode.Expanded ? qsTr("▲ Show less") : qsTr("▼ Show more")
|
||||
font.pixelSize: 11
|
||||
color: palette.buttonText
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (root.displayMode === ThinkingBlock.DisplayMode.Expanded) {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Expanded
|
||||
}
|
||||
}
|
||||
}
|
||||
// anchors {
|
||||
// left: parent.left
|
||||
// right: parent.right
|
||||
// verticalCenter: parent.verticalCenter
|
||||
// margins: 5
|
||||
// }
|
||||
// text: qsTr("Signature: %1").arg(root.signature.substring(0, Math.min(40, root.signature.length)) + "...")
|
||||
// font.pixelSize: 9
|
||||
// font.family: "monospace"
|
||||
// color: palette.mid
|
||||
// elide: Text.ElideRight
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@ -191,26 +146,8 @@ Rectangle {
|
||||
id: contextMenu
|
||||
|
||||
Platform.MenuItem {
|
||||
text: root.displayMode === ThinkingBlock.DisplayMode.Collapsed ? qsTr("Expand") : qsTr("Collapse")
|
||||
onTriggered: {
|
||||
if (root.displayMode === ThinkingBlock.DisplayMode.Collapsed) {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Collapsed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Platform.MenuItem {
|
||||
text: root.displayMode === ThinkingBlock.DisplayMode.Expanded ? qsTr("Compact view") : qsTr("Full view")
|
||||
enabled: root.displayMode !== ThinkingBlock.DisplayMode.Collapsed
|
||||
onTriggered: {
|
||||
if (root.displayMode === ThinkingBlock.DisplayMode.Expanded) {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = ThinkingBlock.DisplayMode.Expanded
|
||||
}
|
||||
}
|
||||
text: root.expanded ? qsTr("Collapse") : qsTr("Expand")
|
||||
onTriggered: root.expanded = !root.expanded
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,4 +162,22 @@ Rectangle {
|
||||
: Qt.lighter(palette.alternateBase, 1.3))
|
||||
radius: root.radius
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
when: !root.expanded
|
||||
PropertyChanges {
|
||||
target: root
|
||||
implicitHeight: header.height
|
||||
}
|
||||
},
|
||||
State {
|
||||
when: root.expanded
|
||||
PropertyChanges {
|
||||
target: root
|
||||
implicitHeight: header.height + contentColumn.height + 20
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -24,10 +24,7 @@ Rectangle {
|
||||
id: root
|
||||
|
||||
property string toolContent: ""
|
||||
|
||||
enum DisplayMode { Collapsed, Compact, Expanded }
|
||||
property int displayMode: ToolBlock.DisplayMode.Compact
|
||||
property int compactHeight: 120
|
||||
property bool expanded: false
|
||||
|
||||
property alias headerOpacity: headerRow.opacity
|
||||
|
||||
@ -43,32 +40,13 @@ Rectangle {
|
||||
NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
|
||||
}
|
||||
|
||||
implicitHeight: {
|
||||
if (displayMode === ToolBlock.DisplayMode.Collapsed) {
|
||||
return header.height
|
||||
} else if (displayMode === ToolBlock.DisplayMode.Compact) {
|
||||
let fullHeight = header.height + contentColumn.height + 20
|
||||
return Math.min(fullHeight, header.height + compactHeight)
|
||||
} else {
|
||||
return header.height + contentColumn.height + 20
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: header
|
||||
|
||||
width: parent.width
|
||||
height: headerRow.height + 10
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (root.displayMode === ToolBlock.DisplayMode.Collapsed) {
|
||||
root.displayMode = ToolBlock.DisplayMode.Compact
|
||||
} else if (root.displayMode === ToolBlock.DisplayMode.Compact) {
|
||||
root.displayMode = ToolBlock.DisplayMode.Collapsed
|
||||
} else {
|
||||
root.displayMode = ToolBlock.DisplayMode.Compact
|
||||
}
|
||||
}
|
||||
onClicked: root.expanded = !root.expanded
|
||||
|
||||
Row {
|
||||
id: headerRow
|
||||
@ -90,31 +68,22 @@ Rectangle {
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.displayMode === ToolBlock.DisplayMode.Collapsed ? "▶" : "▼"
|
||||
text: root.expanded ? "▼" : "▶"
|
||||
font.pixelSize: 10
|
||||
color: palette.mid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentWrapper
|
||||
Column {
|
||||
id: contentColumn
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: header.bottom
|
||||
bottom: parent.bottom
|
||||
margins: 10
|
||||
bottomMargin: expandButton.visible ? expandButton.height + 15 : 10
|
||||
}
|
||||
clip: true
|
||||
visible: root.displayMode !== ToolBlock.DisplayMode.Collapsed
|
||||
|
||||
Column {
|
||||
id: contentColumn
|
||||
|
||||
width: parent.width
|
||||
spacing: 8
|
||||
|
||||
TextEdit {
|
||||
@ -131,45 +100,6 @@ Rectangle {
|
||||
selectionColor: palette.highlight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: expandButton
|
||||
|
||||
property bool needsExpand: contentColumn.height > compactHeight - 20
|
||||
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottomMargin: 5
|
||||
leftMargin: 10
|
||||
rightMargin: 10
|
||||
}
|
||||
height: 24
|
||||
radius: 4
|
||||
color: palette.button
|
||||
visible: needsExpand && root.displayMode !== ToolBlock.DisplayMode.Collapsed
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: root.displayMode === ToolBlock.DisplayMode.Expanded ? qsTr("▲ Show less") : qsTr("▼ Show more")
|
||||
font.pixelSize: 11
|
||||
color: palette.buttonText
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (root.displayMode === ToolBlock.DisplayMode.Expanded) {
|
||||
root.displayMode = ToolBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = ToolBlock.DisplayMode.Expanded
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
@ -196,26 +126,8 @@ Rectangle {
|
||||
Platform.MenuSeparator {}
|
||||
|
||||
Platform.MenuItem {
|
||||
text: root.displayMode === ToolBlock.DisplayMode.Collapsed ? qsTr("Expand") : qsTr("Collapse")
|
||||
onTriggered: {
|
||||
if (root.displayMode === ToolBlock.DisplayMode.Collapsed) {
|
||||
root.displayMode = ToolBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = ToolBlock.DisplayMode.Collapsed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Platform.MenuItem {
|
||||
text: root.displayMode === ToolBlock.DisplayMode.Expanded ? qsTr("Compact view") : qsTr("Full view")
|
||||
enabled: root.displayMode !== ToolBlock.DisplayMode.Collapsed
|
||||
onTriggered: {
|
||||
if (root.displayMode === ToolBlock.DisplayMode.Expanded) {
|
||||
root.displayMode = ToolBlock.DisplayMode.Compact
|
||||
} else {
|
||||
root.displayMode = ToolBlock.DisplayMode.Expanded
|
||||
}
|
||||
}
|
||||
text: root.expanded ? qsTr("Collapse") : qsTr("Expand")
|
||||
onTriggered: root.expanded = !root.expanded
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,4 +141,22 @@ Rectangle {
|
||||
: Qt.lighter(palette.alternateBase, 1.3)
|
||||
radius: root.radius
|
||||
}
|
||||
|
||||
|
||||
states: [
|
||||
State {
|
||||
when: !root.expanded
|
||||
PropertyChanges {
|
||||
target: root
|
||||
implicitHeight: header.height
|
||||
}
|
||||
},
|
||||
State {
|
||||
when: root.expanded
|
||||
PropertyChanges {
|
||||
target: root
|
||||
implicitHeight: header.height + contentColumn.height + 20
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user