mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-09-19 23:35:41 +00:00
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:
parent
7340bf85e3
commit
a8cdba0427
@ -1367,7 +1367,7 @@ Rectangle {
|
|||||||
property bool isHovered: {
|
property bool isHovered: {
|
||||||
return conversationTrayButton.isHovered ||
|
return conversationTrayButton.isHovered ||
|
||||||
resetContextButton.hovered || copyChatButton.hovered ||
|
resetContextButton.hovered || copyChatButton.hovered ||
|
||||||
regenerateButton.hovered || stopButton.hovered
|
regenerateButton.hovered
|
||||||
}
|
}
|
||||||
|
|
||||||
state: conversationTrayContent.isHovered ? "expanded" : "collapsed"
|
state: conversationTrayContent.isHovered ? "expanded" : "collapsed"
|
||||||
@ -1479,23 +1479,6 @@ Rectangle {
|
|||||||
ToolTip.visible: regenerateButton.hovered
|
ToolTip.visible: regenerateButton.hovered
|
||||||
ToolTip.text: qsTr("Redo last chat response")
|
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() {
|
function sendMessage() {
|
||||||
if (textInput.text === "")
|
if (textInput.text === "" || currentChat.responseInProgress || currentChat.isRecalc)
|
||||||
return
|
return
|
||||||
|
|
||||||
currentChat.stopGenerating()
|
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 {
|
MyToolButton {
|
||||||
id: sendButton
|
id: sendButton
|
||||||
backgroundColor: theme.sendButtonBackground
|
backgroundColor: theme.conversationInputButtonBackground
|
||||||
backgroundColorHovered: theme.sendButtonBackgroundHovered
|
backgroundColorHovered: theme.conversationInputButtonBackgroundHovered
|
||||||
anchors.right: textInputView.right
|
anchors.right: textInputView.right
|
||||||
anchors.verticalCenter: textInputView.verticalCenter
|
anchors.verticalCenter: textInputView.verticalCenter
|
||||||
anchors.rightMargin: 15
|
anchors.rightMargin: 15
|
||||||
imageWidth: theme.fontSizeLargest
|
imageWidth: theme.fontSizeLargest
|
||||||
imageHeight: theme.fontSizeLargest
|
imageHeight: theme.fontSizeLargest
|
||||||
visible: !currentChat.isServer && ModelList.selectableModels.count !== 0
|
visible: !currentChat.responseInProgress && !currentChat.isServer && ModelList.selectableModels.count !== 0
|
||||||
enabled: !currentChat.responseInProgress
|
|
||||||
source: "qrc:/gpt4all/icons/send_message.svg"
|
source: "qrc:/gpt4all/icons/send_message.svg"
|
||||||
Accessible.name: qsTr("Send message")
|
Accessible.name: qsTr("Send message")
|
||||||
Accessible.description: qsTr("Sends the message/prompt contained in textfield to the model")
|
Accessible.description: qsTr("Sends the message/prompt contained in textfield to the model")
|
||||||
|
ToolTip.visible: sendButton.hovered
|
||||||
|
ToolTip.text: Accessible.description
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
textInput.sendMessage()
|
textInput.sendMessage()
|
||||||
|
@ -517,7 +517,7 @@ QtObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property color sendButtonBackground: {
|
property color conversationInputButtonBackground: {
|
||||||
switch (MySettings.chatTheme) {
|
switch (MySettings.chatTheme) {
|
||||||
case "LegacyDark":
|
case "LegacyDark":
|
||||||
return accentColor
|
return accentColor
|
||||||
@ -528,7 +528,7 @@ QtObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property color sendButtonBackgroundHovered: {
|
property color conversationInputButtonBackgroundHovered: {
|
||||||
switch (MySettings.chatTheme) {
|
switch (MySettings.chatTheme) {
|
||||||
case "LegacyDark":
|
case "LegacyDark":
|
||||||
return blue0
|
return blue0
|
||||||
|
Loading…
Reference in New Issue
Block a user