ChatView: move stop button to chat input box (#2561)

Signed-off-by: Adam Treat <treat.adam@gmail.com>
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
Co-authored-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
AT 2024-07-10 15:23:35 -04:00 committed by GitHub
parent 7340bf85e3
commit a8cdba0427
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 61 additions and 25 deletions

View File

@ -1367,7 +1367,7 @@ Rectangle {
property bool isHovered: {
return conversationTrayButton.isHovered ||
resetContextButton.hovered || copyChatButton.hovered ||
regenerateButton.hovered || stopButton.hovered
regenerateButton.hovered
}
state: conversationTrayContent.isHovered ? "expanded" : "collapsed"
@ -1479,23 +1479,6 @@ Rectangle {
ToolTip.visible: regenerateButton.hovered
ToolTip.text: qsTr("Redo last chat response")
}
MyToolButton {
id: stopButton
Layout.preferredWidth: 40
Layout.preferredHeight: 40
source: "qrc:/gpt4all/icons/stop_generating.svg"
imageWidth: 20
imageHeight: 20
visible: currentChat.responseInProgress
onClicked: {
var index = Math.max(0, chatModel.count - 1);
var listElement = chatModel.get(index);
listElement.stopped = true
currentChat.stopGenerating()
}
ToolTip.visible: stopButton.hovered
ToolTip.text: qsTr("Stop the current response generation")
}
}
}
@ -1646,7 +1629,7 @@ Rectangle {
}
}
function sendMessage() {
if (textInput.text === "")
if (textInput.text === "" || currentChat.responseInProgress || currentChat.isRecalc)
return
currentChat.stopGenerating()
@ -1704,20 +1687,73 @@ Rectangle {
}
}
MyToolButton {
id: stopButton
backgroundColor: theme.conversationInputButtonBackground
backgroundColorHovered: theme.conversationInputButtonBackgroundHovered
anchors.right: textInputView.right
anchors.verticalCenter: textInputView.verticalCenter
anchors.rightMargin: 15
visible: currentChat.responseInProgress && !currentChat.isServer
background: Item {
anchors.fill: parent
Image {
id: stopImage
anchors.centerIn: parent
visible: false
fillMode: Image.PreserveAspectFit
mipmap: true
sourceSize.width: theme.fontSizeLargest
sourceSize.height: theme.fontSizeLargest
source: "qrc:/gpt4all/icons/stop_generating.svg"
}
Rectangle {
anchors.centerIn: stopImage
width: theme.fontSizeLargest + 8
height: theme.fontSizeLargest + 8
color: theme.viewBackground
border.pixelAligned: false
border.color: theme.controlBorder
border.width: 1
radius: width / 2
}
ColorOverlay {
anchors.fill: stopImage
source: stopImage
color: stopButton.hovered ? stopButton.backgroundColorHovered : stopButton.backgroundColor
}
}
Accessible.name: qsTr("Stop generating")
Accessible.description: qsTr("Stop the current response generation")
ToolTip.visible: stopButton.hovered
ToolTip.text: Accessible.description
onClicked: {
var index = Math.max(0, chatModel.count - 1);
var listElement = chatModel.get(index);
listElement.stopped = true
currentChat.stopGenerating()
}
}
MyToolButton {
id: sendButton
backgroundColor: theme.sendButtonBackground
backgroundColorHovered: theme.sendButtonBackgroundHovered
backgroundColor: theme.conversationInputButtonBackground
backgroundColorHovered: theme.conversationInputButtonBackgroundHovered
anchors.right: textInputView.right
anchors.verticalCenter: textInputView.verticalCenter
anchors.rightMargin: 15
imageWidth: theme.fontSizeLargest
imageHeight: theme.fontSizeLargest
visible: !currentChat.isServer && ModelList.selectableModels.count !== 0
enabled: !currentChat.responseInProgress
visible: !currentChat.responseInProgress && !currentChat.isServer && ModelList.selectableModels.count !== 0
source: "qrc:/gpt4all/icons/send_message.svg"
Accessible.name: qsTr("Send message")
Accessible.description: qsTr("Sends the message/prompt contained in textfield to the model")
ToolTip.visible: sendButton.hovered
ToolTip.text: Accessible.description
onClicked: {
textInput.sendMessage()

View File

@ -517,7 +517,7 @@ QtObject {
}
}
property color sendButtonBackground: {
property color conversationInputButtonBackground: {
switch (MySettings.chatTheme) {
case "LegacyDark":
return accentColor
@ -528,7 +528,7 @@ QtObject {
}
}
property color sendButtonBackgroundHovered: {
property color conversationInputButtonBackgroundHovered: {
switch (MySettings.chatTheme) {
case "LegacyDark":
return blue0