LocalDocsSettings: fix embedding device selection after #2690 (#2873)

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
Jared Van Bortel
2024-08-14 16:28:17 -04:00
committed by GitHub
parent 7073fe341f
commit 3aa6806341
9 changed files with 2396 additions and 2333 deletions

View File

@@ -163,7 +163,7 @@ MySettingsTab {
MySettingsLabel {
id: deviceLabel
text: qsTr("Embeddings Device")
helpText: qsTr('The compute device used for embeddings. "Auto" uses the CPU. Requires restart.')
helpText: qsTr('The compute device used for embeddings. Requires restart.')
}
MyComboBox {
id: deviceBox
@@ -172,11 +172,18 @@ MySettingsTab {
Layout.maximumWidth: 400
Layout.fillWidth: false
Layout.alignment: Qt.AlignRight
model: MySettings.embeddingsDeviceList
model: ListModel {
ListElement { text: qsTr("Application default") }
Component.onCompleted: {
MySettings.embeddingsDeviceList.forEach(d => append({"text": d}));
}
}
Accessible.name: deviceLabel.text
Accessible.description: deviceLabel.helpText
function updateModel() {
deviceBox.currentIndex = deviceBox.indexOfValue(MySettings.localDocsEmbedDevice);
var device = MySettings.localDocsEmbedDevice;
// This usage of 'Auto' should not be translated
deviceBox.currentIndex = device === "Auto" ? 0 : deviceBox.indexOfValue(device);
}
Component.onCompleted: {
deviceBox.updateModel();
@@ -188,7 +195,8 @@ MySettingsTab {
}
}
onActivated: {
MySettings.localDocsEmbedDevice = deviceBox.currentText;
// This usage of 'Auto' should not be translated
MySettings.localDocsEmbedDevice = deviceBox.currentIndex === 0 ? "Auto" : deviceBox.currentText;
}
}
}