From fd9e028f0c5dd9ccbbe713c811cb16d390296eb1 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Tue, 11 Apr 2023 08:54:57 -0400 Subject: [PATCH] Provide a copy function. --- CMakeLists.txt | 1 + icons/copy.svg | 9 +++++++++ main.qml | 46 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 icons/copy.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b8d24b1..7dd6fd0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ qt_add_qml_module(chat icons/stop_generating.svg icons/regenerate.svg icons/logo.svg + icons/copy.svg ) set_target_properties(chat PROPERTIES diff --git a/icons/copy.svg b/icons/copy.svg new file mode 100644 index 00000000..5ab45b5b --- /dev/null +++ b/icons/copy.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/main.qml b/main.qml index d1cfb1fd..3cd18444 100644 --- a/main.qml +++ b/main.qml @@ -106,7 +106,7 @@ Window { } Button { - id: resetContextButton + id: copyButton anchors.right: parent.right anchors.top: parent.top anchors.topMargin: 30 @@ -116,6 +116,50 @@ Window { z: 200 padding: 15 + background: Item { + anchors.fill: parent + Image { + anchors.centerIn: parent + width: 40 + height: 40 + source: "qrc:/gpt4all-chat/icons/copy.svg" + } + } + + TextEdit{ + id: copyEdit + visible: false + } + + onClicked: { + var conversation = ""; + for (var i = 0; i < chatModel.count; i++) { + var item = chatModel.get(i) + var string = item.name; + if (item.currentResponse) + string += LLM.response + else + string += chatModel.get(i).value + string += "\n" + conversation += string + } + copyEdit.text = conversation + copyEdit.selectAll() + copyEdit.copy() + } + } + + Button { + id: resetContextButton + anchors.right: copyButton.left + anchors.top: parent.top + anchors.topMargin: 30 + anchors.rightMargin: 30 + width: 60 + height: 40 + z: 200 + padding: 15 + background: Item { anchors.fill: parent Image {