qml: tweaks to new edit/redo buttons (#3228)

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
Jared Van Bortel 2024-12-06 14:14:36 -05:00 committed by GitHub
parent 2b1668eff2
commit 9e306114d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 9 deletions

View File

@ -529,8 +529,8 @@ GridLayout {
ConfirmationDialog { ConfirmationDialog {
id: editPromptDialog id: editPromptDialog
dialogTitle: qsTr("Edit this prompt?") dialogTitle: qsTr("Edit this message?")
description: qsTr("The existing response and all later messages will be permanently erased.") description: qsTr("All following messages will be permanently erased.")
onAccepted: { onAccepted: {
const msg = currentChat.popPrompt(index); const msg = currentChat.popPrompt(index);
if (msg !== null) if (msg !== null)
@ -541,7 +541,7 @@ GridLayout {
ConfirmationDialog { ConfirmationDialog {
id: redoResponseDialog id: redoResponseDialog
dialogTitle: qsTr("Redo this response?") dialogTitle: qsTr("Redo this response?")
description: qsTr("The existing response and all later messages will be permanently erased.") description: qsTr("All following messages will be permanently erased.")
onAccepted: currentChat.regenerateResponse(index) onAccepted: currentChat.regenerateResponse(index)
} }
@ -556,33 +556,48 @@ GridLayout {
visible: !isCurrentResponse || !currentChat.responseInProgress visible: !isCurrentResponse || !currentChat.responseInProgress
enabled: opacity > 0 enabled: opacity > 0
opacity: hoverArea.hovered opacity: hoverArea.hovered
readonly property var canModify: !currentChat.isServer && currentChat.isModelLoaded && !currentChat.responseInProgress
Behavior on opacity { Behavior on opacity {
OpacityAnimator { duration: 30 } OpacityAnimator { duration: 30 }
} }
ChatMessageButton { ChatMessageButton {
visible: parent.canModify && model.name === "Prompt: " readonly property var editingDisabledReason: {
if (!currentChat.isModelLoaded)
return qsTr("Cannot edit chat without a loaded model.");
if (currentChat.responseInProgress)
return qsTr("Cannot edit chat while the model is generating.");
return null;
}
visible: !currentChat.isServer && model.name === "Prompt: "
enabled: editingDisabledReason === null
Layout.maximumWidth: 24 Layout.maximumWidth: 24
Layout.maximumHeight: 24 Layout.maximumHeight: 24
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: false Layout.fillWidth: false
name: editingDisabledReason ?? qsTr("Edit")
source: "qrc:/gpt4all/icons/edit.svg" source: "qrc:/gpt4all/icons/edit.svg"
onClicked: { onClicked: {
if (inputBoxText === "") if (inputBoxText === "")
editPromptDialog.open(); editPromptDialog.open();
} }
name: qsTr("Edit")
} }
ChatMessageButton { ChatMessageButton {
visible: parent.canModify && model.name === "Response: " readonly property var editingDisabledReason: {
if (!currentChat.isModelLoaded)
return qsTr("Cannot redo response without a loaded model.");
if (currentChat.responseInProgress)
return qsTr("Cannot redo response while the model is generating.");
return null;
}
visible: !currentChat.isServer && model.name === "Response: "
enabled: editingDisabledReason === null
Layout.maximumWidth: 24 Layout.maximumWidth: 24
Layout.maximumHeight: 24 Layout.maximumHeight: 24
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: false Layout.fillWidth: false
name: qsTr("Redo") name: editingDisabledReason ?? qsTr("Redo")
source: "qrc:/gpt4all/icons/regenerate.svg" source: "qrc:/gpt4all/icons/regenerate.svg"
onClicked: redoResponseDialog.open() onClicked: redoResponseDialog.open()
} }

View File

@ -49,7 +49,7 @@ Button {
ColorOverlay { ColorOverlay {
anchors.fill: image anchors.fill: image
source: image source: image
color: myButton.hovered ? backgroundColorHovered : backgroundColor color: !myButton.enabled ? theme.mutedTextColor : myButton.hovered ? backgroundColorHovered : backgroundColor
} }
} }
Accessible.role: Accessible.Button Accessible.role: Accessible.Button