sidebar: translator: save selected language, cleaner selector

This commit is contained in:
end-4
2025-06-11 11:36:56 +02:00
parent 0fb28af3c7
commit 23f0e90a7b
4 changed files with 36 additions and 14 deletions
@@ -66,8 +66,8 @@ Singleton {
property QtObject language: QtObject {
property QtObject translator: QtObject {
property string engine: "auto" // Run `trans -list-engines` for available engines. auto should use google
property string targetLanguage: "auto" // Run `trans -list-all` for available languages
property string sourceLanguage: "auto"
property string targetLanguage: "English" // Run `trans -list-all` for available languages
}
}
@@ -13,7 +13,8 @@ Item {
property real dialogMargin: 30
property string titleText: "Selection Dialog"
property alias items: choiceModel.values
property int selectedId: -1 // -1 means no selection
property int selectedId: choiceListView.currentIndex
property var defaultChoice
signal canceled();
signal selected(var result);
@@ -68,6 +69,7 @@ Item {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
currentIndex: root.defaultChoice !== undefined ? root.items.indexOf(root.defaultChoice) : -1
model: ScriptModel {
id: choiceModel
@@ -85,11 +87,11 @@ Item {
}
description: modelData.toString()
checked: index === root.selectedId
checked: index === choiceListView.currentIndex
onCheckedChanged: {
if (checked) {
root.selectedId = index;
choiceListView.currentIndex = index;
}
}
}