Skip to content

Commit 9e30611

Browse files
authored
qml: tweaks to new edit/redo buttons (#3228)
Signed-off-by: Jared Van Bortel <[email protected]>
1 parent 2b1668e commit 9e30611

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

gpt4all-chat/qml/ChatItemView.qml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ GridLayout {
529529

530530
ConfirmationDialog {
531531
id: editPromptDialog
532-
dialogTitle: qsTr("Edit this prompt?")
533-
description: qsTr("The existing response and all later messages will be permanently erased.")
532+
dialogTitle: qsTr("Edit this message?")
533+
description: qsTr("All following messages will be permanently erased.")
534534
onAccepted: {
535535
const msg = currentChat.popPrompt(index);
536536
if (msg !== null)
@@ -541,7 +541,7 @@ GridLayout {
541541
ConfirmationDialog {
542542
id: redoResponseDialog
543543
dialogTitle: qsTr("Redo this response?")
544-
description: qsTr("The existing response and all later messages will be permanently erased.")
544+
description: qsTr("All following messages will be permanently erased.")
545545
onAccepted: currentChat.regenerateResponse(index)
546546
}
547547

@@ -556,33 +556,48 @@ GridLayout {
556556
visible: !isCurrentResponse || !currentChat.responseInProgress
557557
enabled: opacity > 0
558558
opacity: hoverArea.hovered
559-
readonly property var canModify: !currentChat.isServer && currentChat.isModelLoaded && !currentChat.responseInProgress
560559

561560
Behavior on opacity {
562561
OpacityAnimator { duration: 30 }
563562
}
564563

565564
ChatMessageButton {
566-
visible: parent.canModify && model.name === "Prompt: "
565+
readonly property var editingDisabledReason: {
566+
if (!currentChat.isModelLoaded)
567+
return qsTr("Cannot edit chat without a loaded model.");
568+
if (currentChat.responseInProgress)
569+
return qsTr("Cannot edit chat while the model is generating.");
570+
return null;
571+
}
572+
visible: !currentChat.isServer && model.name === "Prompt: "
573+
enabled: editingDisabledReason === null
567574
Layout.maximumWidth: 24
568575
Layout.maximumHeight: 24
569576
Layout.alignment: Qt.AlignVCenter
570577
Layout.fillWidth: false
578+
name: editingDisabledReason ?? qsTr("Edit")
571579
source: "qrc:/gpt4all/icons/edit.svg"
572580
onClicked: {
573581
if (inputBoxText === "")
574582
editPromptDialog.open();
575583
}
576-
name: qsTr("Edit")
577584
}
578585

579586
ChatMessageButton {
580-
visible: parent.canModify && model.name === "Response: "
587+
readonly property var editingDisabledReason: {
588+
if (!currentChat.isModelLoaded)
589+
return qsTr("Cannot redo response without a loaded model.");
590+
if (currentChat.responseInProgress)
591+
return qsTr("Cannot redo response while the model is generating.");
592+
return null;
593+
}
594+
visible: !currentChat.isServer && model.name === "Response: "
595+
enabled: editingDisabledReason === null
581596
Layout.maximumWidth: 24
582597
Layout.maximumHeight: 24
583598
Layout.alignment: Qt.AlignVCenter
584599
Layout.fillWidth: false
585-
name: qsTr("Redo")
600+
name: editingDisabledReason ?? qsTr("Redo")
586601
source: "qrc:/gpt4all/icons/regenerate.svg"
587602
onClicked: redoResponseDialog.open()
588603
}

gpt4all-chat/qml/MyToolButton.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Button {
4949
ColorOverlay {
5050
anchors.fill: image
5151
source: image
52-
color: myButton.hovered ? backgroundColorHovered : backgroundColor
52+
color: !myButton.enabled ? theme.mutedTextColor : myButton.hovered ? backgroundColorHovered : backgroundColor
5353
}
5454
}
5555
Accessible.role: Accessible.Button

0 commit comments

Comments
 (0)