PrefUI // Allow enabling / disabling external dictionary plists.
This commit is contained in:
parent
5ef515fa23
commit
8b16674240
|
@ -20,6 +20,8 @@ struct VwrPrefPaneDictionary: View {
|
|||
?? LMMgr.dataFolderPath(isDefaultFolder: true)
|
||||
@State private var selAutoReloadUserData: Bool = UserDefaults.standard.bool(
|
||||
forKey: UserDef.kShouldAutoReloadUserDataFiles.rawValue)
|
||||
@State private var selUseExternalFactoryDict: Bool = UserDefaults.standard.bool(
|
||||
forKey: UserDef.kUseExternalFactoryDict.rawValue)
|
||||
@State private var selOnlyLoadFactoryLangModelsIfNeeded: Bool = UserDefaults.standard.bool(
|
||||
forKey: UserDef.kOnlyLoadFactoryLangModelsIfNeeded.rawValue)
|
||||
@State private var selEnableCNS11643: Bool = UserDefaults.standard.bool(forKey: UserDef.kCNS11643Enabled.rawValue)
|
||||
|
@ -59,137 +61,153 @@ struct VwrPrefPaneDictionary: View {
|
|||
// MARK: - User Data Folder Path Management
|
||||
|
||||
SSPreferences.Section(title: "", bottomDivider: true) {
|
||||
Text(LocalizedStringKey("Choose your desired user data folder path. Will be omitted if invalid."))
|
||||
HStack {
|
||||
TextField(fdrUserDataDefault, text: $tbxUserDataPathSpecified).disabled(true)
|
||||
.help(tbxUserDataPathSpecified)
|
||||
Button {
|
||||
Self.dlgOpenPath.title = NSLocalizedString(
|
||||
"Choose your desired user data folder.", comment: ""
|
||||
)
|
||||
Self.dlgOpenPath.showsResizeIndicator = true
|
||||
Self.dlgOpenPath.showsHiddenFiles = true
|
||||
Self.dlgOpenPath.canChooseFiles = false
|
||||
Self.dlgOpenPath.allowsMultipleSelection = false
|
||||
Self.dlgOpenPath.canChooseDirectories = true
|
||||
Group {
|
||||
Text(LocalizedStringKey("Choose your desired user data folder path. Will be omitted if invalid."))
|
||||
HStack {
|
||||
TextField(fdrUserDataDefault, text: $tbxUserDataPathSpecified).disabled(true)
|
||||
.help(tbxUserDataPathSpecified)
|
||||
Button {
|
||||
Self.dlgOpenPath.title = NSLocalizedString(
|
||||
"Choose your desired user data folder.", comment: ""
|
||||
)
|
||||
Self.dlgOpenPath.showsResizeIndicator = true
|
||||
Self.dlgOpenPath.showsHiddenFiles = true
|
||||
Self.dlgOpenPath.canChooseFiles = false
|
||||
Self.dlgOpenPath.allowsMultipleSelection = false
|
||||
Self.dlgOpenPath.canChooseDirectories = true
|
||||
|
||||
let bolPreviousFolderValidity = LMMgr.checkIfSpecifiedUserDataFolderValid(
|
||||
PrefMgr.shared.userDataFolderSpecified.expandingTildeInPath)
|
||||
let bolPreviousFolderValidity = LMMgr.checkIfSpecifiedUserDataFolderValid(
|
||||
PrefMgr.shared.userDataFolderSpecified.expandingTildeInPath)
|
||||
|
||||
if let window = CtlPrefUI.shared.controller.window {
|
||||
Self.dlgOpenPath.beginSheetModal(for: window) { result in
|
||||
if result == NSApplication.ModalResponse.OK {
|
||||
guard let url = Self.dlgOpenPath.url else { return }
|
||||
// CommonDialog 讀入的路徑沒有結尾斜槓,這會導致檔案目錄合規性判定失準。
|
||||
// 所以要手動補回來。
|
||||
var newPath = url.path
|
||||
newPath.ensureTrailingSlash()
|
||||
if LMMgr.checkIfSpecifiedUserDataFolderValid(newPath) {
|
||||
PrefMgr.shared.userDataFolderSpecified = newPath
|
||||
tbxUserDataPathSpecified = PrefMgr.shared.userDataFolderSpecified
|
||||
BookmarkManager.shared.saveBookmark(for: url)
|
||||
(NSApp.delegate as? AppDelegate)?.updateDirectoryMonitorPath()
|
||||
if let window = CtlPrefUI.shared.controller.window {
|
||||
Self.dlgOpenPath.beginSheetModal(for: window) { result in
|
||||
if result == NSApplication.ModalResponse.OK {
|
||||
guard let url = Self.dlgOpenPath.url else { return }
|
||||
// CommonDialog 讀入的路徑沒有結尾斜槓,這會導致檔案目錄合規性判定失準。
|
||||
// 所以要手動補回來。
|
||||
var newPath = url.path
|
||||
newPath.ensureTrailingSlash()
|
||||
if LMMgr.checkIfSpecifiedUserDataFolderValid(newPath) {
|
||||
PrefMgr.shared.userDataFolderSpecified = newPath
|
||||
tbxUserDataPathSpecified = PrefMgr.shared.userDataFolderSpecified
|
||||
BookmarkManager.shared.saveBookmark(for: url)
|
||||
(NSApp.delegate as? AppDelegate)?.updateDirectoryMonitorPath()
|
||||
} else {
|
||||
IMEApp.buzz()
|
||||
if !bolPreviousFolderValidity {
|
||||
LMMgr.resetSpecifiedUserDataFolder()
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
IMEApp.buzz()
|
||||
if !bolPreviousFolderValidity {
|
||||
LMMgr.resetSpecifiedUserDataFolder()
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if !bolPreviousFolderValidity {
|
||||
LMMgr.resetSpecifiedUserDataFolder()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Text("...")
|
||||
}
|
||||
Button {
|
||||
LMMgr.resetSpecifiedUserDataFolder()
|
||||
tbxUserDataPathSpecified = ""
|
||||
} label: {
|
||||
Text("↻")
|
||||
}
|
||||
} label: {
|
||||
Text("...")
|
||||
}
|
||||
Button {
|
||||
LMMgr.resetSpecifiedUserDataFolder()
|
||||
tbxUserDataPathSpecified = ""
|
||||
} label: {
|
||||
Text("↻")
|
||||
}
|
||||
Toggle(
|
||||
LocalizedStringKey("Automatically reload user data files if changes detected"),
|
||||
isOn: $selAutoReloadUserData.onChange {
|
||||
PrefMgr.shared.shouldAutoReloadUserDataFiles = selAutoReloadUserData
|
||||
if selAutoReloadUserData {
|
||||
LMMgr.initUserLangModels()
|
||||
}
|
||||
}
|
||||
).controlSize(.small)
|
||||
}
|
||||
Toggle(
|
||||
LocalizedStringKey("Automatically reload user data files if changes detected"),
|
||||
isOn: $selAutoReloadUserData.onChange {
|
||||
PrefMgr.shared.shouldAutoReloadUserDataFiles = selAutoReloadUserData
|
||||
if selAutoReloadUserData {
|
||||
LMMgr.initUserLangModels()
|
||||
Divider()
|
||||
Group {
|
||||
Toggle(
|
||||
LocalizedStringKey("Read external factory dictionary plists if possible"),
|
||||
isOn: $selUseExternalFactoryDict.onChange {
|
||||
PrefMgr.shared.useExternalFactoryDict = selUseExternalFactoryDict
|
||||
LMMgr.reloadFactoryDictionaryPlists()
|
||||
}
|
||||
}
|
||||
).controlSize(.small)
|
||||
}
|
||||
|
||||
// MARK: - Something Else
|
||||
|
||||
SSPreferences.Section(title: "") {
|
||||
Toggle(
|
||||
LocalizedStringKey("Only load factory language models if needed"),
|
||||
isOn: $selOnlyLoadFactoryLangModelsIfNeeded.onChange {
|
||||
PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded = selOnlyLoadFactoryLangModelsIfNeeded
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Enable CNS11643 Support (2022-12-01)"),
|
||||
isOn: $selEnableCNS11643.onChange {
|
||||
PrefMgr.shared.cns11643Enabled = selEnableCNS11643
|
||||
LMMgr.setCNSEnabled(PrefMgr.shared.cns11643Enabled)
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Enable symbol input support (incl. certain emoji symbols)"),
|
||||
isOn: $selEnableSymbolInputSupport.onChange {
|
||||
PrefMgr.shared.symbolInputEnabled = selEnableSymbolInputSupport
|
||||
LMMgr.setSymbolEnabled(PrefMgr.shared.symbolInputEnabled)
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Allow boosting / excluding a candidate of single kanji"),
|
||||
isOn: $selAllowBoostingSingleKanjiAsUserPhrase.onChange {
|
||||
PrefMgr.shared.allowBoostingSingleKanjiAsUserPhrase = selAllowBoostingSingleKanjiAsUserPhrase
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Applying typing suggestions from half-life user override model"),
|
||||
isOn: $selFetchSuggestionsFromUserOverrideModel.onChange {
|
||||
PrefMgr.shared.fetchSuggestionsFromUserOverrideModel = selFetchSuggestionsFromUserOverrideModel
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Always use fixed listing order in candidate window"),
|
||||
isOn: $selUseFixecCandidateOrderOnSelection.onChange {
|
||||
PrefMgr.shared.useFixecCandidateOrderOnSelection = selUseFixecCandidateOrderOnSelection
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Consolidate the context on confirming candidate selection"),
|
||||
isOn: $selConsolidateContextOnCandidateSelection.onChange {
|
||||
PrefMgr.shared.consolidateContextOnCandidateSelection = selConsolidateContextOnCandidateSelection
|
||||
}
|
||||
)
|
||||
Text(
|
||||
LocalizedStringKey(
|
||||
"For example: When typing “章太炎” and you want to override the “太” with “泰”, and the raw operation index range [1,2) which bounds are cutting the current node “章太炎” in range [0,3). If having lack of the pre-consolidation process, this word will become something like “張泰言” after the candidate selection. Only if we enable this consolidation, this word will become “章泰炎” which is the expected result that the context is kept as-is."
|
||||
)
|
||||
)
|
||||
.preferenceDescription().fixedSize(horizontal: false, vertical: true)
|
||||
Toggle(
|
||||
LocalizedStringKey("Harden vertical punctuations during vertical typing (not recommended)"),
|
||||
isOn: $selHardenVerticalPunctuations.onChange {
|
||||
PrefMgr.shared.hardenVerticalPunctuations = selHardenVerticalPunctuations
|
||||
}
|
||||
)
|
||||
Text(
|
||||
LocalizedStringKey(
|
||||
"⚠︎ This feature is useful ONLY WHEN the font you are using doesn't support dynamic vertical punctuations. However, typed vertical punctuations will always shown as vertical punctuations EVEN IF your editor has changed the typing direction to horizontal."
|
||||
Text(
|
||||
LocalizedStringKey(
|
||||
"This will use the plist files deployed by the “make install” command from libvChewing-Data if possible."
|
||||
)
|
||||
)
|
||||
)
|
||||
.preferenceDescription().fixedSize(horizontal: false, vertical: true)
|
||||
.preferenceDescription().fixedSize(horizontal: false, vertical: true)
|
||||
Toggle(
|
||||
LocalizedStringKey("Only load factory language models if needed"),
|
||||
isOn: $selOnlyLoadFactoryLangModelsIfNeeded.onChange {
|
||||
PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded = selOnlyLoadFactoryLangModelsIfNeeded
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Enable CNS11643 Support (2022-12-01)"),
|
||||
isOn: $selEnableCNS11643.onChange {
|
||||
PrefMgr.shared.cns11643Enabled = selEnableCNS11643
|
||||
LMMgr.setCNSEnabled(PrefMgr.shared.cns11643Enabled)
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Enable symbol input support (incl. certain emoji symbols)"),
|
||||
isOn: $selEnableSymbolInputSupport.onChange {
|
||||
PrefMgr.shared.symbolInputEnabled = selEnableSymbolInputSupport
|
||||
LMMgr.setSymbolEnabled(PrefMgr.shared.symbolInputEnabled)
|
||||
}
|
||||
)
|
||||
}
|
||||
// Divider()
|
||||
Group {
|
||||
Toggle(
|
||||
LocalizedStringKey("Allow boosting / excluding a candidate of single kanji"),
|
||||
isOn: $selAllowBoostingSingleKanjiAsUserPhrase.onChange {
|
||||
PrefMgr.shared.allowBoostingSingleKanjiAsUserPhrase = selAllowBoostingSingleKanjiAsUserPhrase
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Applying typing suggestions from half-life user override model"),
|
||||
isOn: $selFetchSuggestionsFromUserOverrideModel.onChange {
|
||||
PrefMgr.shared.fetchSuggestionsFromUserOverrideModel = selFetchSuggestionsFromUserOverrideModel
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Always use fixed listing order in candidate window"),
|
||||
isOn: $selUseFixecCandidateOrderOnSelection.onChange {
|
||||
PrefMgr.shared.useFixecCandidateOrderOnSelection = selUseFixecCandidateOrderOnSelection
|
||||
}
|
||||
)
|
||||
Toggle(
|
||||
LocalizedStringKey("Consolidate the context on confirming candidate selection"),
|
||||
isOn: $selConsolidateContextOnCandidateSelection.onChange {
|
||||
PrefMgr.shared.consolidateContextOnCandidateSelection = selConsolidateContextOnCandidateSelection
|
||||
}
|
||||
)
|
||||
Text(
|
||||
LocalizedStringKey(
|
||||
"For example: When typing “章太炎” and you want to override the “太” with “泰”, and the raw operation index range [1,2) which bounds are cutting the current node “章太炎” in range [0,3). If having lack of the pre-consolidation process, this word will become something like “張泰言” after the candidate selection. Only if we enable this consolidation, this word will become “章泰炎” which is the expected result that the context is kept as-is."
|
||||
)
|
||||
)
|
||||
.preferenceDescription().fixedSize(horizontal: false, vertical: true)
|
||||
Toggle(
|
||||
LocalizedStringKey("Harden vertical punctuations during vertical typing (not recommended)"),
|
||||
isOn: $selHardenVerticalPunctuations.onChange {
|
||||
PrefMgr.shared.hardenVerticalPunctuations = selHardenVerticalPunctuations
|
||||
}
|
||||
)
|
||||
Text(
|
||||
LocalizedStringKey(
|
||||
"⚠︎ This feature is useful ONLY WHEN the font you are using doesn't support dynamic vertical punctuations. However, typed vertical punctuations will always shown as vertical punctuations EVEN IF your editor has changed the typing direction to horizontal."
|
||||
)
|
||||
)
|
||||
.preferenceDescription().fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,6 +264,7 @@
|
|||
"Please use mouse wheel to scroll this page. The CheatSheet is available in the IME menu." = "Please use mouse wheel to scroll this page. The CheatSheet is available in the IME menu.";
|
||||
"Push the cursor in front of the phrase after selection" = "Push the cursor in front of the phrase after selection";
|
||||
"Quick Setup:" = "Quick Setup:";
|
||||
"Read external factory dictionary plists if possible" = "Read external factory dictionary plists if possible";
|
||||
"Secondary Pinyin with Numeral Intonation" = "Secondary Pinyin with Numeral Intonation";
|
||||
"Seigyou" = "Seigyou (JinYei)";
|
||||
"Selection Keys:" = "Selection Keys:";
|
||||
|
@ -284,6 +285,7 @@
|
|||
"This conversion only affects the cassette module, converting typed contents to either Simplified Chinese or Traditional Chinese in accordance to this setting and your current input mode." = "This conversion only affects the cassette module, converting typed contents to either Simplified Chinese or Traditional Chinese in accordance to this setting and your current input mode.";
|
||||
"This only works with Tadokoro candidate window." = "This only works with Tadokoro candidate window.";
|
||||
"This will batch-replace specified candidates." = "This will batch-replace specified candidates.";
|
||||
"This will use the plist files deployed by the “make install” command from libvChewing-Data if possible." = "This will use the plist files deployed by the “make install” command from libvChewing-Data if possible.";
|
||||
"Traditional Chinese" = "Traditional Chinese";
|
||||
"Trim unfinished readings / strokes on commit" = "Trim unfinished readings / strokes on commit";
|
||||
"Type them into inline composition buffer" = "Type them into inline composition buffer";
|
||||
|
|
|
@ -264,6 +264,7 @@
|
|||
"Please use mouse wheel to scroll this page. The CheatSheet is available in the IME menu." = "Please use mouse wheel to scroll this page. The CheatSheet is available in the IME menu.";
|
||||
"Push the cursor in front of the phrase after selection" = "Push the cursor in front of the phrase after selection";
|
||||
"Quick Setup:" = "Quick Setup:";
|
||||
"Read external factory dictionary plists if possible" = "Read external factory dictionary plists if possible";
|
||||
"Secondary Pinyin with Numeral Intonation" = "Secondary Pinyin with Numeral Intonation";
|
||||
"Seigyou" = "Seigyou (JinYei)";
|
||||
"Selection Keys:" = "Selection Keys:";
|
||||
|
@ -284,6 +285,7 @@
|
|||
"This conversion only affects the cassette module, converting typed contents to either Simplified Chinese or Traditional Chinese in accordance to this setting and your current input mode." = "This conversion only affects the cassette module, converting typed contents to either Simplified Chinese or Traditional Chinese in accordance to this setting and your current input mode.";
|
||||
"This only works with Tadokoro candidate window." = "This only works with Tadokoro candidate window.";
|
||||
"This will batch-replace specified candidates." = "This will batch-replace specified candidates.";
|
||||
"This will use the plist files deployed by the “make install” command from libvChewing-Data if possible." = "This will use the plist files deployed by the “make install” command from libvChewing-Data if possible.";
|
||||
"Traditional Chinese" = "Traditional Chinese";
|
||||
"Trim unfinished readings / strokes on commit" = "Trim unfinished readings / strokes on commit";
|
||||
"Type them into inline composition buffer" = "Type them into inline composition buffer";
|
||||
|
|
|
@ -264,6 +264,7 @@
|
|||
"Please use mouse wheel to scroll this page. The CheatSheet is available in the IME menu." = "マウスホイールでこのページをご覧ください。キーに関する取扱説明のアクセスはメニューに。";
|
||||
"Push the cursor in front of the phrase after selection" = "候補選択の直後、すぐカーソルを単語の向こうに推し進める";
|
||||
"Quick Setup:" = "直接設定:";
|
||||
"Read external factory dictionary plists if possible" = "なるべく(内蔵辞書より)外部の公式辞書ファイルを利用";
|
||||
"Secondary Pinyin with Numeral Intonation" = "国音二式 (ローマ字+数字音調)";
|
||||
"Seigyou" = "精業配列";
|
||||
"Selection Keys:" = "言選り用キー:";
|
||||
|
@ -284,6 +285,7 @@
|
|||
"This conversion only affects the cassette module, converting typed contents to either Simplified Chinese or Traditional Chinese in accordance to this setting and your current input mode." = "この転換はカセットモードだけに使える転換であり、転換結果はこの設定と入力モード次第である。";
|
||||
"This only works with Tadokoro candidate window." = "これは田所候補陳列ウィンドウだけに効ける機能である。";
|
||||
"This will batch-replace specified candidates." = "指定された候補そのものを置き換える";
|
||||
"This will use the plist files deployed by the “make install” command from libvChewing-Data if possible." = "これで libvChewing-Data の make install にて設置した公式辞書ファイルを優先的に用いる。";
|
||||
"Traditional Chinese" = "繁体中国語";
|
||||
"Trim unfinished readings / strokes on commit" = "送り出す緩衝列内容から未完成な音読み/筆組みを除く";
|
||||
"Type them into inline composition buffer" = "入力緩衝列にローマ字入力";
|
||||
|
|
|
@ -264,6 +264,7 @@
|
|||
"Please use mouse wheel to scroll this page. The CheatSheet is available in the IME menu." = "请利用滑鼠滚轮检视该页面。也请洽输入法选单内的热键指南。";
|
||||
"Push the cursor in front of the phrase after selection" = "在选字后将游标置于该字词的前方";
|
||||
"Quick Setup:" = "直接设定:";
|
||||
"Read external factory dictionary plists if possible" = "尽量使用外置原厂辞典 plist 档案";
|
||||
"Secondary Pinyin with Numeral Intonation" = "国音二式+数字标调";
|
||||
"Seigyou" = "精业排列";
|
||||
"Selection Keys:" = "选字键:";
|
||||
|
@ -284,6 +285,7 @@
|
|||
"This conversion only affects the cassette module, converting typed contents to either Simplified Chinese or Traditional Chinese in accordance to this setting and your current input mode." = "该转换仅对磁带模式有影响,会将键入的内容根据该选项与当前的简繁体模式来转换。";
|
||||
"This only works with Tadokoro candidate window." = "该方法仅对田所选字窗起作用。";
|
||||
"This will batch-replace specified candidates." = "这将会对指定的候选字词进行整词取代。";
|
||||
"This will use the plist files deployed by the “make install” command from libvChewing-Data if possible." = "这将会优先使用由 libvChewing-Data 的 make install 部署的原厂辞典档案。";
|
||||
"Traditional Chinese" = "繁体中文";
|
||||
"Trim unfinished readings / strokes on commit" = "在递交时清理未完成拼写的读音或字根";
|
||||
"Type them into inline composition buffer" = "直接键入内文组字区";
|
||||
|
|
|
@ -264,6 +264,7 @@
|
|||
"Please use mouse wheel to scroll this page. The CheatSheet is available in the IME menu." = "請利用滑鼠滾輪檢視該頁面。也請洽輸入法選單內的熱鍵指南。";
|
||||
"Push the cursor in front of the phrase after selection" = "在選字後將游標置於該字詞的前方";
|
||||
"Quick Setup:" = "直接設定:";
|
||||
"Read external factory dictionary plists if possible" = "盡量使用外置原廠辭典 plist 檔案";
|
||||
"Secondary Pinyin with Numeral Intonation" = "國音二式+數字標調";
|
||||
"Seigyou" = "精業排列";
|
||||
"Selection Keys:" = "選字鍵:";
|
||||
|
@ -284,6 +285,7 @@
|
|||
"This conversion only affects the cassette module, converting typed contents to either Simplified Chinese or Traditional Chinese in accordance to this setting and your current input mode." = "該轉換僅對磁帶模式有影響,會將鍵入的內容根據該選項與當前的簡繁體模式來轉換。";
|
||||
"This only works with Tadokoro candidate window." = "該方法僅對田所選字窗起作用。";
|
||||
"This will batch-replace specified candidates." = "這將會對指定的候選字詞進行整詞取代。";
|
||||
"This will use the plist files deployed by the “make install” command from libvChewing-Data if possible." = "這將會優先使用由 libvChewing-Data 的 make install 部署的原廠辭典檔案。";
|
||||
"Traditional Chinese" = "繁體中文";
|
||||
"Trim unfinished readings / strokes on commit" = "在遞交時清理未完成拼寫的讀音或字根";
|
||||
"Type them into inline composition buffer" = "直接鍵入內文組字區";
|
||||
|
|
Loading…
Reference in New Issue