feat(translate): add translation presets and custom instructions

This commit is contained in:
tri committed 2026-11-07 13:28:32 +07:00
1 parent cebce0915f
commit 18ba92a6e3
9 files changed
+172 -8

No files matched your search

+45
View File
@@ -145,6 +145,51 @@ SettingsBasePage {
onEditingFinished: QtPotatoSettings.save()
}
Label {
text: KI18n.i18nc("@label:listbox", "Preset")
Layout.alignment: Qt.AlignRight | Qt.AlignTop
}
ColumnLayout {
Layout.fillWidth: true
ComboBox {
id: presetCombo
Layout.fillWidth: true
model: root.translator.translationPresets
textRole: "name"
valueRole: "id"
Component.onCompleted: currentIndex = Math.max(0, indexOfValue(QtPotatoSettings.translationPreset))
onActivated: {
QtPotatoSettings.translationPreset = currentValue
QtPotatoSettings.save()
}
}
Label {
text: presetCombo.currentIndex >= 0 ? presetCombo.model[presetCombo.currentIndex].guidance : ""
wrapMode: Text.WordWrap
opacity: 0.7
Layout.fillWidth: true
}
}
Label {
text: KI18n.i18nc("@label:textbox", "Additional instructions")
Layout.alignment: Qt.AlignRight | Qt.AlignTop
}
TextArea {
text: QtPotatoSettings.customInstructions
placeholderText: KI18n.i18nc("@info:placeholder", "e.g. Translate 'Young Master' as 'Thiếu gia'. Use 'ta/ngươi' between enemies.")
wrapMode: TextArea.Wrap
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 4
// TextArea has no textEdited before Qt 6.9.
onTextChanged: QtPotatoSettings.customInstructions = text
onEditingFinished: QtPotatoSettings.save()
}
Label {
text: KI18n.i18nc("@label:spinbox", "Lines per request")
Layout.alignment: Qt.AlignRight