mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-11-22 02:22:44 -05:00
fix: Remove image dublicate (#271)
This commit is contained in:
@ -61,12 +61,18 @@ ChatRootView {
|
||||
SplitDropZone {
|
||||
anchors.fill: parent
|
||||
|
||||
onFilesDroppedToAttach: (filePaths) => {
|
||||
root.addFilesToAttachList(filePaths)
|
||||
onFilesDroppedToAttach: (urlStrings) => {
|
||||
var localPaths = root.convertUrlsToLocalPaths(urlStrings)
|
||||
if (localPaths.length > 0) {
|
||||
root.addFilesToAttachList(localPaths)
|
||||
}
|
||||
}
|
||||
|
||||
onFilesDroppedToLink: (filePaths) => {
|
||||
root.addFilesToLinkList(filePaths)
|
||||
onFilesDroppedToLink: (urlStrings) => {
|
||||
var localPaths = root.convertUrlsToLocalPaths(urlStrings)
|
||||
if (localPaths.length > 0) {
|
||||
root.addFilesToLinkList(localPaths)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -263,12 +263,7 @@ Rectangle {
|
||||
Layout.maximumWidth: parent.parent.maxImageWidth
|
||||
Layout.maximumHeight: parent.parent.maxImageHeight
|
||||
|
||||
source: {
|
||||
if (!itemData.storedPath || !root.chatFilePath) return "";
|
||||
var fileInfo = chatFileInfo(root.chatFilePath);
|
||||
var imagesFolder = fileInfo.dir + "/" + fileInfo.baseName + "_images";
|
||||
return "file://" + imagesFolder + "/" + itemData.storedPath;
|
||||
}
|
||||
source: itemData.imageUrl ? itemData.imageUrl : ""
|
||||
|
||||
sourceSize.width: parent.parent.maxImageWidth
|
||||
sourceSize.height: parent.parent.maxImageHeight
|
||||
@ -303,14 +298,4 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function chatFileInfo(filePath) {
|
||||
if (!filePath) return {dir: "", baseName: ""};
|
||||
var lastSlash = filePath.lastIndexOf("/");
|
||||
var dir = lastSlash >= 0 ? filePath.substring(0, lastSlash) : "";
|
||||
var fileName = lastSlash >= 0 ? filePath.substring(lastSlash + 1) : filePath;
|
||||
var lastDot = fileName.lastIndexOf(".");
|
||||
var baseName = lastDot >= 0 ? fileName.substring(0, lastDot) : fileName;
|
||||
return {dir: dir, baseName: baseName};
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ import QtQuick.Controls
|
||||
Item {
|
||||
id: root
|
||||
|
||||
signal filesDroppedToAttach(var filePaths)
|
||||
signal filesDroppedToLink(var filePaths)
|
||||
signal filesDroppedToAttach(var urlStrings) // Array of URL strings (file://...)
|
||||
signal filesDroppedToLink(var urlStrings) // Array of URL strings (file://...)
|
||||
|
||||
property string activeZone: ""
|
||||
|
||||
@ -216,21 +216,17 @@ Item {
|
||||
splitDropOverlay.visible = false
|
||||
root.activeZone = ""
|
||||
|
||||
if (drop.hasUrls) {
|
||||
var filePaths = []
|
||||
if (drop.hasUrls && drop.urls.length > 0) {
|
||||
// Convert URLs to array of strings for C++ processing
|
||||
var urlStrings = []
|
||||
for (var i = 0; i < drop.urls.length; i++) {
|
||||
var url = drop.urls[i].toString()
|
||||
if (url.startsWith("file://")) {
|
||||
filePaths.push(decodeURIComponent(url.replace(/^file:\/\//, '')))
|
||||
}
|
||||
urlStrings.push(drop.urls[i].toString())
|
||||
}
|
||||
|
||||
if (filePaths.length > 0) {
|
||||
if (targetZone === "right") {
|
||||
root.filesDroppedToLink(filePaths)
|
||||
} else {
|
||||
root.filesDroppedToAttach(filePaths)
|
||||
}
|
||||
|
||||
if (targetZone === "right") {
|
||||
root.filesDroppedToLink(urlStrings)
|
||||
} else {
|
||||
root.filesDroppedToAttach(urlStrings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user