From 8fe73832a653d93e92fa4406ed68125b70fea5a6 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Fri, 28 Jun 2024 14:19:20 -0400 Subject: [PATCH] Fix up the loading default model to display the actual name as per Vincent. Signed-off-by: Adam Treat --- gpt4all-chat/qml/ChatView.qml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/gpt4all-chat/qml/ChatView.qml b/gpt4all-chat/qml/ChatView.qml index b07b7815..fa94cc38 100644 --- a/gpt4all-chat/qml/ChatView.qml +++ b/gpt4all-chat/qml/ChatView.qml @@ -631,13 +631,24 @@ Rectangle { } MyButton { + id: loadDefaultModelButton visible: ModelList.installedModels.count !== 0 anchors.top: modelInstalledLabel.bottom anchors.topMargin: 50 anchors.horizontalCenter: modelInstalledLabel.horizontalCenter rightPadding: 60 leftPadding: 60 - text: qsTr("Load default model \u2192"); + property string defaultModel + function updateDefaultModel() { + var i = comboBox.find(MySettings.userDefaultModel) + if (i !== -1) { + defaultModel = comboBox.valueAt(i); + } else { + defaultModel = comboBox.valueAt(0); + } + } + + text: qsTr("Load \u00B7 ") + defaultModel + qsTr(" (default) \u2192"); onClicked: { var i = comboBox.find(MySettings.userDefaultModel) if (i !== -1) { @@ -646,6 +657,20 @@ Rectangle { comboBox.changeModel(0); } } + + // This requires a bit of work because apparently the combobox valueAt + // function only works after the combobox component is loaded so we have + // to use our own component loaded to make this work along with a signal + // from MySettings for when the setting for user default model changes + Connections { + target: MySettings + function onUserDefaultModelChanged() { + loadDefaultModelButton.updateDefaultModel() + } + } + Component.onCompleted: { + loadDefaultModelButton.updateDefaultModel() + } Accessible.role: Accessible.Button Accessible.name: qsTr("Load the default model") Accessible.description: qsTr("Loads the default model which can be changed in settings")