From 1b5aa4617febb73d4b4166d8655bc64e990db16d Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Mon, 26 Jun 2023 12:17:49 -0400 Subject: [PATCH] Enable the add button always, but show an error in placeholder text. --- gpt4all-chat/qml/LocalDocs.qml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gpt4all-chat/qml/LocalDocs.qml b/gpt4all-chat/qml/LocalDocs.qml index 7659ba4d..71fe0e66 100644 --- a/gpt4all-chat/qml/LocalDocs.qml +++ b/gpt4all-chat/qml/LocalDocs.qml @@ -63,6 +63,12 @@ Item { Accessible.role: Accessible.EditableText Accessible.name: collection.text Accessible.description: ToolTip.text + function showError() { + collection.placeholderTextColor = theme.textErrorColor + } + onTextChanged: { + collection.placeholderTextColor = theme.mutedTextColor + } } MyDirectoryField { @@ -77,6 +83,12 @@ Item { placeholderTextColor: theme.mutedTextColor ToolTip.text: qsTr("Folder path to documents (Required)") ToolTip.visible: hovered + function showError() { + folderEdit.placeholderTextColor = theme.textErrorColor + } + onTextChanged: { + folderEdit.placeholderTextColor = theme.mutedTextColor + } } MyButton { @@ -95,11 +107,21 @@ Item { text: qsTr("Add") anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - enabled: root.collection !== "" && root.folder_path !== "" && folderEdit.isValid Accessible.role: Accessible.Button Accessible.name: text Accessible.description: qsTr("Add button") onClicked: { + var isError = false; + if (root.collection === "") { + isError = true; + collection.showError(); + } + if (root.folder_path === "" || !folderEdit.isValid) { + isError = true; + folderEdit.showError(); + } + if (isError) + return; LocalDocs.addFolder(root.collection, root.folder_path) root.collection = "" root.folder_path = ""