From 6506ba161b97c31ab8f2e4acf28e9b5ef4a940ca Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Thu, 27 Jun 2024 11:08:32 -0400 Subject: [PATCH] UI tweaks for GPT4All v3.0.0-rc2 (#2474) * clickable link to get API key with hand-style mouse cursor * remove "Force Metal" setting * allow typing incorrect API keys (but don't accept them), add placeholder text Signed-off-by: Jared Van Bortel --- gpt4all-chat/qml/ApplicationSettings.qml | 4 ++-- gpt4all-chat/qml/LocalDocsSettings.qml | 21 +++++++++++++-------- gpt4all-chat/qml/MySettingsLabel.qml | 6 ++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gpt4all-chat/qml/ApplicationSettings.qml b/gpt4all-chat/qml/ApplicationSettings.qml index 19aee29e..c0c3fbfa 100644 --- a/gpt4all-chat/qml/ApplicationSettings.qml +++ b/gpt4all-chat/qml/ApplicationSettings.qml @@ -420,7 +420,7 @@ MySettingsTab { Accessible.description: ToolTip.text } - MySettingsLabel { + /*MySettingsLabel { id: gpuOverrideLabel text: qsTr("Force Metal (macOS+arm)") Layout.row: 13 @@ -437,7 +437,7 @@ MySettingsTab { } ToolTip.text: qsTr("WARNING: On macOS with arm (M1+) this setting forces usage of the GPU. Can cause crashes if the model requires more RAM than the system supports. Because of crash possibility the setting will not persist across restarts of the application. This has no effect on non-macs or intel.") ToolTip.visible: hovered - } + }*/ MySettingsLabel { id: updatesLabel diff --git a/gpt4all-chat/qml/LocalDocsSettings.qml b/gpt4all-chat/qml/LocalDocsSettings.qml index 17aab8cb..5873090a 100644 --- a/gpt4all-chat/qml/LocalDocsSettings.qml +++ b/gpt4all-chat/qml/LocalDocsSettings.qml @@ -117,24 +117,29 @@ MySettingsTab { MySettingsLabel { id: apiKeyLabel text: qsTr("Nomic API Key") - helpText: qsTr("API key to use for Nomic Embed. Get one at https://atlas.nomic.ai/") + helpText: qsTr('API key to use for Nomic Embed. Get one from the Atlas API keys page.') + onLinkActivated: function(link) { Qt.openUrlExternally(link) } } MyTextField { id: apiKeyField + + property bool isValid: validate() + onTextChanged: { isValid = validate(); } + function validate() { return /^(nk-[a-zA-Z0-9_-]{43})?$/.test(apiKeyField.text); } + + placeholderText: "nk-" + "X".repeat(43) text: MySettings.localDocsNomicAPIKey - color: apiKeyField.acceptableInput ? theme.textColor : theme.textErrorColor + color: apiKeyField.isValid ? theme.textColor : theme.textErrorColor font.pixelSize: theme.fontSizeLarge Layout.alignment: Qt.AlignRight Layout.minimumWidth: 200 enabled: useNomicAPIBox.checked - validator: RegularExpressionValidator { - // may be empty - regularExpression: /|nk-[a-zA-Z0-9_-]{43}/ - } onEditingFinished: { - MySettings.localDocsNomicAPIKey = apiKeyField.text; - MySettings.localDocsUseRemoteEmbed = useNomicAPIBox.checked && MySettings.localDocsNomicAPIKey !== ""; + if (apiKeyField.isValid) { + MySettings.localDocsNomicAPIKey = apiKeyField.text; + MySettings.localDocsUseRemoteEmbed = useNomicAPIBox.checked && MySettings.localDocsNomicAPIKey !== ""; + } focus = false; } Accessible.role: Accessible.EditableText diff --git a/gpt4all-chat/qml/MySettingsLabel.qml b/gpt4all-chat/qml/MySettingsLabel.qml index 2517759b..dd06b891 100644 --- a/gpt4all-chat/qml/MySettingsLabel.qml +++ b/gpt4all-chat/qml/MySettingsLabel.qml @@ -37,5 +37,11 @@ ColumnLayout { onLinkActivated: function(link) { root.linkActivated(link); } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton // pass clicks to parent + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } } }