diff --git a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift index 6ec989ab..98f9593a 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Protocols/PrefMgrProtocol.swift @@ -40,6 +40,7 @@ public protocol PrefMgrProtocol { var trimUnfinishedReadingsOnCommit: Bool { get set } var alwaysShowTooltipTextsHorizontally: Bool { get set } var clientsIMKTextInputIncapable: [String] { get set } + var onlyLoadFactoryLangModelsIfNeeded: Bool { get set } var useIMKCandidateWindow: Bool { get set } var handleDefaultCandidateFontsByLangIdentifier: Bool { get set } var shiftKeyAccommodationBehavior: Int { get set } diff --git a/Packages/vChewing_Shared/Sources/Shared/Shared.swift b/Packages/vChewing_Shared/Sources/Shared/Shared.swift index 74f494bb..f0c5da3c 100644 --- a/Packages/vChewing_Shared/Sources/Shared/Shared.swift +++ b/Packages/vChewing_Shared/Sources/Shared/Shared.swift @@ -58,6 +58,7 @@ public enum UserDef: String, CaseIterable { case kTrimUnfinishedReadingsOnCommit = "TrimUnfinishedReadingsOnCommit" case kAlwaysShowTooltipTextsHorizontally = "AlwaysShowTooltipTextsHorizontally" case kClientsIMKTextInputIncapable = "ClientsIMKTextInputIncapable" + case kOnlyLoadFactoryLangModelsIfNeeded = "OnlyLoadFactoryLangModelsIfNeeded" case kUseIMKCandidateWindow = "UseIMKCandidateWindow" case kHandleDefaultCandidateFontsByLangIdentifier = "HandleDefaultCandidateFontsByLangIdentifier" diff --git a/Source/Modules/AppDelegate.swift b/Source/Modules/AppDelegate.swift index aac63946..e7f66e06 100644 --- a/Source/Modules/AppDelegate.swift +++ b/Source/Modules/AppDelegate.swift @@ -51,7 +51,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele NSUserNotificationCenter.default.deliver(userNotification) } - LMMgr.loadDataModelsOnAppDelegate() + if !PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModelsOnAppDelegate() } DispatchQueue.main.async { LMMgr.initUserLangModels() self.folderMonitor.folderDidChange = { [weak self] in diff --git a/Source/Modules/PrefMgr.swift b/Source/Modules/PrefMgr.swift index 1af72d7e..c1ad69dd 100644 --- a/Source/Modules/PrefMgr.swift +++ b/Source/Modules/PrefMgr.swift @@ -126,6 +126,13 @@ public class PrefMgr: PrefMgrProtocol { @AppProperty(key: UserDef.kClientsIMKTextInputIncapable.rawValue, defaultValue: ["com.valvesoftware.steam"]) public var clientsIMKTextInputIncapable: [String] + @AppProperty(key: UserDef.kOnlyLoadFactoryLangModelsIfNeeded.rawValue, defaultValue: true) + public var onlyLoadFactoryLangModelsIfNeeded: Bool { + didSet { + if !onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModelsOnAppDelegate() } + } + } + // MARK: - Settings (Tier 2) @AppProperty(key: UserDef.kUseIMKCandidateWindow.rawValue, defaultValue: false) diff --git a/Source/Modules/ctlInputMethod_Core.swift b/Source/Modules/ctlInputMethod_Core.swift index 43784396..478fb51e 100644 --- a/Source/Modules/ctlInputMethod_Core.swift +++ b/Source/Modules/ctlInputMethod_Core.swift @@ -177,7 +177,7 @@ class ctlInputMethod: IMKInputController { default: newInputMode = .imeModeNULL } - // LMMgr.loadDataModel(newInputMode) + if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(newInputMode) } if inputMode != newInputMode { UserDefaults.standard.synchronize()