From f242b565279376bf52ca4b23600a1417e59bf2ad Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Fri, 20 Dec 2024 07:46:12 -0500 Subject: [PATCH] This exactly matches copy behavior in v3.5.3. Signed-off-by: Adam Treat --- gpt4all-chat/qml/ChatView.qml | 5 +---- gpt4all-chat/src/chatmodel.h | 9 ++++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gpt4all-chat/qml/ChatView.qml b/gpt4all-chat/qml/ChatView.qml index b3490d5d5fd6..cf9afd2dc144 100644 --- a/gpt4all-chat/qml/ChatView.qml +++ b/gpt4all-chat/qml/ChatView.qml @@ -935,10 +935,7 @@ Rectangle { visible: false } onClicked: { - var conversation = chatModel.copyToClipboard() - copyEdit.text = conversation - copyEdit.selectAll() - copyEdit.copy() + chatModel.copyToClipboard() copyMessage.open() } ToolTip.visible: copyChatButton.hovered diff --git a/gpt4all-chat/src/chatmodel.h b/gpt4all-chat/src/chatmodel.h index d0a8cbfd9759..da898e965c75 100644 --- a/gpt4all-chat/src/chatmodel.h +++ b/gpt4all-chat/src/chatmodel.h @@ -985,12 +985,15 @@ class ChatModel : public QAbstractListModel Q_INVOKABLE void copyToClipboard() { QMutexLocker locker(&m_mutex); - QStringList content; + QString conversation; for (ChatItem *item : m_chatItems) { - content << item->clipboardContent(); + QString string = item->name; + string += item->clipboardContent(); + string += "\n"; + conversation += string; } QClipboard *clipboard = QGuiApplication::clipboard(); - clipboard->setText(content.join("\n\n"), QClipboard::Clipboard); + clipboard->setText(conversation, QClipboard::Clipboard); } Q_INVOKABLE void copyToClipboard(int index)