diff --git a/Source/Modules/IMEModules/ctlInputMethod.swift b/Source/Modules/IMEModules/ctlInputMethod.swift index 3a690edb..dbde36e3 100644 --- a/Source/Modules/IMEModules/ctlInputMethod.swift +++ b/Source/Modules/IMEModules/ctlInputMethod.swift @@ -80,6 +80,7 @@ class ctlInputMethod: IMKInputController { menu.addItem(NSMenuItem.separator()) // --------------------- + menu.addItem(withTitle: NSLocalizedString("Open User Data Folder", comment: ""), action: #selector(openUserDataFolder(_:)), keyEquivalent: "") menu.addItem(withTitle: NSLocalizedString("Edit User Phrases", comment: ""), action: #selector(openUserPhrases(_:)), keyEquivalent: "") if optionKeyPressed { @@ -252,6 +253,13 @@ class ctlInputMethod: IMKInputController { open(userFileAt: mgrLangModel.userPhrasesDataPath(keyHandler.inputMode)) } + @objc func openUserDataFolder(_ sender: Any?) { + if !mgrLangModel.checkIfUserDataFolderExists() { + return + } + NSWorkspace.shared.openFile(mgrLangModel.dataFolderPath, withApplication: "Finder") + } + @objc func openExcludedPhrases(_ sender: Any?) { open(userFileAt: mgrLangModel.excludedPhrasesDataPath(keyHandler.inputMode)) } diff --git a/Source/Modules/LangModelRelated/mgrLangModel.h b/Source/Modules/LangModelRelated/mgrLangModel.h index f1113cfb..e76c6ea1 100644 --- a/Source/Modules/LangModelRelated/mgrLangModel.h +++ b/Source/Modules/LangModelRelated/mgrLangModel.h @@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)loadUserPhraseReplacement; + (void)setupDataModelValueConverter; + (BOOL)checkIfUserLanguageModelFilesExist; ++ (BOOL)checkIfUserDataFolderExists; + (BOOL)checkIfUserPhraseExist:(NSString *)userPhrase key:(NSString *)key NS_SWIFT_NAME(checkIfExist(userPhrase:key:)); + (BOOL)writeUserPhrase:(NSString *)userPhrase inputMode:(InputMode)mode;