PrefUI_Keyboard // Add reset buttons and mistake-proofing.

This commit is contained in:
ShikiSuen 2022-05-18 16:54:04 +08:00
parent 01095a9bcd
commit 5f078d7c40
2 changed files with 55 additions and 23 deletions

View File

@ -138,7 +138,6 @@
"Phonetic Parser:" = "注音排列:"; "Phonetic Parser:" = "注音排列:";
"Push the cursor in front of the phrase after selection" = "在选字后将游标置于该字词的前方"; "Push the cursor in front of the phrase after selection" = "在选字后将游标置于该字词的前方";
"Secondary Pinyin with Numeral Intonation" = "国音二式+数字标调"; "Secondary Pinyin with Numeral Intonation" = "国音二式+数字标调";
"Secondary Pinyin with Numeral Intonation" = "國音二式+数字标调";
"Selection Keys:" = "选字键:"; "Selection Keys:" = "选字键:";
"Show Hanyu-Pinyin in the inline composition buffer" = "拼音并击模式(组字区内看到的是汉语拼音)"; "Show Hanyu-Pinyin in the inline composition buffer" = "拼音并击模式(组字区内看到的是汉语拼音)";
"Show page buttons in candidate window" = "在选字窗内显示翻页按钮"; "Show page buttons in candidate window" = "在选字窗内显示翻页按钮";
@ -155,4 +154,3 @@
"Use ESC key to clear the entire input buffer" = "敲 ESC 键以清空整个组字缓冲区"; "Use ESC key to clear the entire input buffer" = "敲 ESC 键以清空整个组字缓冲区";
"Vertical" = "纵向布局"; "Vertical" = "纵向布局";
"Yale Pinyin with Numeral Intonation" = "耶鲁拼音+数字标调"; "Yale Pinyin with Numeral Intonation" = "耶鲁拼音+数字标调";
"Yale Pinyin with Numeral Intonation" = "耶魯拼音+数字标调";

View File

@ -45,30 +45,60 @@ struct suiPrefPaneKeyboard: View {
var body: some View { var body: some View {
Preferences.Container(contentWidth: contentWidth) { Preferences.Container(contentWidth: contentWidth) {
Preferences.Section(label: { Text(LocalizedStringKey("Phonetic Parser:")) }) { Preferences.Section(label: { Text(LocalizedStringKey("Phonetic Parser:")) }) {
Picker("", selection: $selMandarinParser) { HStack {
Group { Picker("", selection: $selMandarinParser) {
Text(LocalizedStringKey("Dachen (Microsoft Standard / Wang / 01, etc.)")).tag(0) Group {
Text(LocalizedStringKey("Dachen 26 (libChewing)")).tag(7) Text(LocalizedStringKey("Dachen (Microsoft Standard / Wang / 01, etc.)")).tag(0)
Text(LocalizedStringKey("Eten Traditional")).tag(1) Text(LocalizedStringKey("Dachen 26 (libChewing)")).tag(7)
Text(LocalizedStringKey("Eten 26")).tag(3) Text(LocalizedStringKey("Eten Traditional")).tag(1)
Text(LocalizedStringKey("IBM")).tag(4) Text(LocalizedStringKey("Eten 26")).tag(3)
Text(LocalizedStringKey("Hsu")).tag(2) Text(LocalizedStringKey("IBM")).tag(4)
Text(LocalizedStringKey("MiTAC")).tag(5) Text(LocalizedStringKey("Hsu")).tag(2)
Text(LocalizedStringKey("Fake Seigyou")).tag(6) Text(LocalizedStringKey("MiTAC")).tag(5)
Text(LocalizedStringKey("Fake Seigyou")).tag(6)
}
Divider()
Group {
Text(LocalizedStringKey("Hanyu Pinyin with Numeral Intonation")).tag(10)
Text(LocalizedStringKey("Secondary Pinyin with Numeral Intonation")).tag(11)
Text(LocalizedStringKey("Yale Pinyin with Numeral Intonation")).tag(12)
Text(LocalizedStringKey("Hualuo Pinyin with Numeral Intonation")).tag(13)
Text(LocalizedStringKey("Universal Pinyin with Numeral Intonation")).tag(14)
}
}.onChange(of: selMandarinParser) { value in
mgrPrefs.mandarinParser = value
switch value {
case 0:
if !AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(mgrPrefs.basicKeyboardLayout) {
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ZhuyinBopomofo"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
}
default:
if AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(mgrPrefs.basicKeyboardLayout) {
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ABC"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
}
}
} }
Divider() .labelsHidden()
Group { Button {
Text(LocalizedStringKey("Hanyu Pinyin with Numeral Intonation")).tag(10) mgrPrefs.mandarinParser = 0
Text(LocalizedStringKey("Secondary Pinyin with Numeral Intonation")).tag(11) selMandarinParser = mgrPrefs.mandarinParser
Text(LocalizedStringKey("Yale Pinyin with Numeral Intonation")).tag(12) mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ZhuyinBopomofo"
Text(LocalizedStringKey("Hualuo Pinyin with Numeral Intonation")).tag(13) selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
Text(LocalizedStringKey("Universal Pinyin with Numeral Intonation")).tag(14) } label: {
Text("↻ㄅ")
}
Button {
mgrPrefs.mandarinParser = 10
selMandarinParser = mgrPrefs.mandarinParser
mgrPrefs.basicKeyboardLayout = "com.apple.keylayout.ABC"
selBasicKeyboardLayout = mgrPrefs.basicKeyboardLayout
} label: {
Text("↻A")
} }
}.onChange(of: selMandarinParser) { value in
mgrPrefs.mandarinParser = value
} }
.labelsHidden() .frame(width: 380.0)
.frame(width: 320.0)
Text(LocalizedStringKey("Choose the phonetic layout for Mandarin parser.")) Text(LocalizedStringKey("Choose the phonetic layout for Mandarin parser."))
.preferenceDescription() .preferenceDescription()
} }
@ -81,6 +111,10 @@ struct suiPrefPaneKeyboard: View {
}.id(UUID()) }.id(UUID())
}.onChange(of: selBasicKeyboardLayout) { value in }.onChange(of: selBasicKeyboardLayout) { value in
mgrPrefs.basicKeyboardLayout = value mgrPrefs.basicKeyboardLayout = value
if AppleKeyboardConverter.arrDynamicBasicKeyLayout.contains(value) {
mgrPrefs.mandarinParser = 0
selMandarinParser = mgrPrefs.mandarinParser
}
} }
.labelsHidden() .labelsHidden()
.frame(width: 240.0) .frame(width: 240.0)