Fix up the loading default model to display the actual name as per Vincent.

Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
Adam Treat 2024-06-28 14:19:20 -04:00
parent 23e8b187a4
commit 8fe73832a6

View File

@ -631,13 +631,24 @@ Rectangle {
} }
MyButton { MyButton {
id: loadDefaultModelButton
visible: ModelList.installedModels.count !== 0 visible: ModelList.installedModels.count !== 0
anchors.top: modelInstalledLabel.bottom anchors.top: modelInstalledLabel.bottom
anchors.topMargin: 50 anchors.topMargin: 50
anchors.horizontalCenter: modelInstalledLabel.horizontalCenter anchors.horizontalCenter: modelInstalledLabel.horizontalCenter
rightPadding: 60 rightPadding: 60
leftPadding: 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: { onClicked: {
var i = comboBox.find(MySettings.userDefaultModel) var i = comboBox.find(MySettings.userDefaultModel)
if (i !== -1) { if (i !== -1) {
@ -646,6 +657,20 @@ Rectangle {
comboBox.changeModel(0); 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.role: Accessible.Button
Accessible.name: qsTr("Load the default model") Accessible.name: qsTr("Load the default model")
Accessible.description: qsTr("Loads the default model which can be changed in settings") Accessible.description: qsTr("Loads the default model which can be changed in settings")