feat: Add open in editor and remove from list (#267)

* refactor: Rename and move chat items
* feat: Add hotkeys for open in editor and remove file from list
* feat: Add opening by system
* feat: Add context action menu
This commit is contained in:
Petr Mironychev
2025-11-19 01:15:43 +01:00
committed by GitHub
parent bcdec96d92
commit ef73895823
16 changed files with 199 additions and 25 deletions

View File

@ -24,7 +24,8 @@ import QtQuick.Layouts
import ChatView
import UIControls
import Qt.labs.platform as Platform
import "./parts"
import "./chatparts"
ChatRootView {
id: root
@ -188,7 +189,7 @@ ChatRootView {
Component {
id: toolMessageComponent
ToolStatusItem {
ToolBlock {
id: toolsItem
width: parent.width
@ -208,7 +209,7 @@ ChatRootView {
Component {
id: fileEditMessageComponent
FileEditItem {
FileEditBlock {
width: parent.width
editContent: model.content
@ -233,7 +234,7 @@ ChatRootView {
Component {
id: thinkingMessageComponent
ThinkingStatusItem {
ThinkingBlock {
id: thinking
width: parent.width

View File

@ -23,8 +23,6 @@ import QtQuick.Controls
import QtQuick.Layouts
import UIControls
import "./dialog"
Rectangle {
id: root

View File

@ -40,19 +40,68 @@ Flow {
Repeater {
id: attachRepeater
delegate: Rectangle {
delegate: FileItem {
id: fileItem
required property int index
required property string modelData
filePath: modelData
height: 30
width: contentRow.width + 10
radius: 4
color: palette.button
border.width: 1
border.color: mouse.hovered ? palette.highlight : root.accentColor
HoverHandler {
Rectangle {
anchors.fill: parent
radius: 4
color: palette.button
border.width: 1
border.color: mouse.containsMouse ? palette.highlight : root.accentColor
}
MouseArea {
id: mouse
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onClicked: (mouse) => {
if (mouse.button === Qt.RightButton) {
contextMenu.popup()
} else if (mouse.button === Qt.MiddleButton ||
(mouse.button === Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier))) {
root.removeFileFromListByIndex(fileItem.index)
} else if (mouse.modifiers & Qt.ShiftModifier) {
fileItem.openFileInExternalEditor()
} else {
fileItem.openFileInEditor()
}
}
ToolTip.visible: containsMouse
ToolTip.delay: 500
ToolTip.text: "Click: Open in Qt Creator\nShift+Click: Open in external editor\nCtrl+Click / Middle Click: Remove"
}
Menu {
id: contextMenu
MenuItem {
text: "Open in Qt Creator"
onTriggered: fileItem.openFileInEditor()
}
MenuItem {
text: "Open in External Editor"
onTriggered: fileItem.openFileInExternalEditor()
}
MenuSeparator {}
MenuItem {
text: "Remove"
onTriggered: root.removeFileFromListByIndex(fileItem.index)
}
}
Row {