diff --git a/Source/Modules/IME.swift b/Source/Modules/IME.swift
index 8c56f79c..11b8a007 100644
--- a/Source/Modules/IME.swift
+++ b/Source/Modules/IME.swift
@@ -20,6 +20,8 @@ import Cocoa
@objc public class IME: NSObject {
+ static let dlgOpenPath = NSOpenPanel();
+
// MARK: - Functions
// Print debug information to the console.
diff --git a/Source/WindowControllers/ctlPrefWindow.swift b/Source/WindowControllers/ctlPrefWindow.swift
index deae0fe5..26d271e7 100644
--- a/Source/WindowControllers/ctlPrefWindow.swift
+++ b/Source/WindowControllers/ctlPrefWindow.swift
@@ -38,12 +38,15 @@ extension RangeReplaceableCollection where Element: Hashable {
@IBOutlet weak var selectionKeyComboBox: NSComboBox!
@IBOutlet weak var chkTrad2KangXi: NSButton!
@IBOutlet weak var chkTrad2JISShinjitai: NSButton!
+ @IBOutlet weak var lblCurrentlySpecifiedUserDataFolder: NSTextFieldCell!
var currentLanguageSelectItem: NSMenuItem? = nil
override func windowDidLoad() {
super.windowDidLoad()
+ lblCurrentlySpecifiedUserDataFolder.placeholderString = mgrLangModel.dataFolderPath(isDefaultFolder: true)
+
let languages = ["auto", "en", "zh-Hans", "zh-Hant", "ja"]
var autoMUISelectItem: NSMenuItem? = nil
var chosenLanguageItem: NSMenuItem? = nil
@@ -234,4 +237,43 @@ extension RangeReplaceableCollection where Element: Hashable {
}
}
+ @IBAction func resetSpecifiedUserDataFolder(_ sender: Any) {
+ UserDefaults.standard.removeObject(forKey: "UserDataFolderSpecified")
+ IME.initLangModels(userOnly: true)
+ }
+
+ @IBAction func chooseUserDataFolderToSpecify(_ sender: Any) {
+ IME.dlgOpenPath.title = NSLocalizedString("Choose your desired user data folder.", comment: "");
+ IME.dlgOpenPath.showsResizeIndicator = true;
+ IME.dlgOpenPath.showsHiddenFiles = true;
+ IME.dlgOpenPath.canChooseFiles = false;
+ IME.dlgOpenPath.canChooseDirectories = true;
+
+ let PreviousFolderValidity = mgrLangModel.checkIfSpecifiedUserDataFolderValid(NSString(string: mgrPrefs.userDataFolderSpecified).expandingTildeInPath)
+
+ if self.window != nil {
+ IME.dlgOpenPath.beginSheetModal(for: self.window!) { result in
+ if result == NSApplication.ModalResponse.OK {
+ if (IME.dlgOpenPath.url != nil) {
+ if (mgrLangModel.checkIfSpecifiedUserDataFolderValid(IME.dlgOpenPath.url!.path)) {
+ mgrPrefs.userDataFolderSpecified = IME.dlgOpenPath.url!.path
+ IME.initLangModels(userOnly: true)
+ } else {
+ clsSFX.beep()
+ if !PreviousFolderValidity {
+ self.resetSpecifiedUserDataFolder(self)
+ }
+ return
+ }
+ }
+ } else {
+ if !PreviousFolderValidity {
+ self.resetSpecifiedUserDataFolder(self)
+ }
+ return
+ }
+ }
+ } // End If self.window != nil
+ } // End IBAction
+
}
diff --git a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib
index 5cf4fda9..5409f63e 100644
--- a/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib
+++ b/Source/WindowNIBs/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib
@@ -12,6 +12,7 @@
+
@@ -23,7 +24,7 @@
-
+
@@ -162,7 +163,7 @@