refactor: UI for opening content from chat (#318)

* refactor: Changed options to opening images from chat
* refactor: Add customizable tooltip
This commit is contained in:
Petr Mironychev
2026-02-25 07:49:37 +01:00
committed by GitHub
parent 3de1619bf0
commit 2ba58a403f
5 changed files with 118 additions and 49 deletions

View File

@ -117,8 +117,10 @@ QVariant ChatModel::data(const QModelIndex &index, int role) const
QString contentFolder = QDir(dirPath).filePath(baseName + "_content");
QString fullPath = QDir(contentFolder).filePath(image.storedPath);
imageMap["imageUrl"] = QUrl::fromLocalFile(fullPath).toString();
imageMap["filePath"] = fullPath;
} else {
imageMap["imageUrl"] = QString();
imageMap["filePath"] = QString();
}
imagesList.append(imageMap);

View File

@ -181,9 +181,12 @@ Rectangle {
onClicked: function() {
root.resetChatToMessage(root.messageIndex)
}
ToolTip.visible: hovered
ToolTip.text: qsTr("Reset chat to this message and edit")
ToolTip.delay: 500
QoAToolTip {
visible: stopButtonId.hovered
text: qsTr("Reset chat to this message and edit")
delay: 500
}
}
component TextComponent : TextBlock {
@ -267,33 +270,21 @@ Rectangle {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onClicked: (mouse) => {
if (mouse.button === Qt.LeftButton) {
if (mouse.modifiers & Qt.ShiftModifier) {
fileItem.openFileInExternalEditor()
} else {
fileItem.openFileInEditor()
} else if (mouse.button === Qt.RightButton) {
attachmentContextMenu.popup()
}
}
ToolTip.visible: containsMouse
ToolTip.text: qsTr("Left click: Open in Qt Creator\nRight click: More options")
ToolTip.delay: 500
}
Menu {
id: attachmentContextMenu
MenuItem {
text: qsTr("Open in Qt Creator")
onTriggered: fileItem.openFileInEditor()
}
MenuItem {
text: qsTr("Open in System Editor")
onTriggered: fileItem.openFileInExternalEditor()
QoAToolTip {
visible: attachFileMouseArea.containsMouse
text: qsTr("Click: Open in Qt Creator\nShift+Click: Open in System Editor")
delay: 500
}
}
}
@ -315,7 +306,7 @@ Rectangle {
FileItem {
id: imageFileItem
filePath: itemData.imageUrl ? itemData.imageUrl.toString().replace("file://", "") : ""
filePath: itemData.filePath || ""
}
ColumnLayout {
@ -371,33 +362,21 @@ Rectangle {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onClicked: (mouse) => {
if (mouse.button === Qt.LeftButton) {
if (mouse.modifiers & Qt.ShiftModifier) {
imageFileItem.openFileInExternalEditor()
} else {
imageFileItem.openFileInEditor()
} else if (mouse.button === Qt.RightButton) {
imageContextMenu.popup()
}
}
ToolTip.visible: containsMouse
ToolTip.text: qsTr("Left click: Open in System\nRight click: More options")
ToolTip.delay: 500
}
Menu {
id: imageContextMenu
MenuItem {
text: qsTr("Open in Qt Creator")
onTriggered: imageFileItem.openFileInEditor()
}
MenuItem {
text: qsTr("Open in System Viewer")
onTriggered: imageFileItem.openFileInExternalEditor()
QoAToolTip {
visible: imageMouseArea.containsMouse
text: qsTr("Click: Open in Qt Creator\nShift+Click: Open in System Editor")
delay: 500
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2025 Petr Mironychev
* Copyright (C) 2024-2026 Petr Mironychev
*
* This file is part of QodeAssist.
*
@ -21,6 +21,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import ChatView
import UIControls
Flow {
id: root
@ -78,9 +79,11 @@ Flow {
}
}
ToolTip.visible: containsMouse
ToolTip.delay: 500
ToolTip.text: "Click: Open in Qt Creator\nShift+Click: Open in external editor\nCtrl+Click / Middle Click: Remove"
QoAToolTip {
visible: mouse.containsMouse
delay: 500
text: "Click: Open in Qt Creator\nShift+Click: Open in external editor\nCtrl+Click / Middle Click: Remove"
}
}
Menu {