ctlPrefWindow // Refine nil handling.
This commit is contained in:
parent
c4c30680aa
commit
e6253f6cbc
|
@ -287,6 +287,7 @@ class ctlPrefWindow: NSWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func chooseUserDataFolderToSpecify(_: Any) {
|
@IBAction func chooseUserDataFolderToSpecify(_: Any) {
|
||||||
|
guard let window = window else { return }
|
||||||
IME.dlgOpenPath.title = NSLocalizedString(
|
IME.dlgOpenPath.title = NSLocalizedString(
|
||||||
"Choose your desired user data folder.", comment: ""
|
"Choose your desired user data folder.", comment: ""
|
||||||
)
|
)
|
||||||
|
@ -298,34 +299,32 @@ class ctlPrefWindow: NSWindowController {
|
||||||
let bolPreviousFolderValidity = mgrLangModel.checkIfSpecifiedUserDataFolderValid(
|
let bolPreviousFolderValidity = mgrLangModel.checkIfSpecifiedUserDataFolderValid(
|
||||||
mgrPrefs.userDataFolderSpecified.expandingTildeInPath)
|
mgrPrefs.userDataFolderSpecified.expandingTildeInPath)
|
||||||
|
|
||||||
if window != nil {
|
IME.dlgOpenPath.beginSheetModal(for: window) { result in
|
||||||
IME.dlgOpenPath.beginSheetModal(for: window!) { result in
|
if result == NSApplication.ModalResponse.OK {
|
||||||
if result == NSApplication.ModalResponse.OK {
|
if IME.dlgOpenPath.url != nil {
|
||||||
if IME.dlgOpenPath.url != nil {
|
// CommonDialog 讀入的路徑沒有結尾斜槓,這會導致檔案目錄合規性判定失準。
|
||||||
// CommonDialog 讀入的路徑沒有結尾斜槓,這會導致檔案目錄合規性判定失準。
|
// 所以要手動補回來。
|
||||||
// 所以要手動補回來。
|
var newPath = IME.dlgOpenPath.url!.path
|
||||||
var newPath = IME.dlgOpenPath.url!.path
|
newPath.ensureTrailingSlash()
|
||||||
newPath.ensureTrailingSlash()
|
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) {
|
||||||
if mgrLangModel.checkIfSpecifiedUserDataFolderValid(newPath) {
|
mgrPrefs.userDataFolderSpecified = newPath
|
||||||
mgrPrefs.userDataFolderSpecified = newPath
|
IME.initLangModels(userOnly: true)
|
||||||
IME.initLangModels(userOnly: true)
|
(NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath()
|
||||||
(NSApplication.shared.delegate as! AppDelegate).updateStreamHelperPath()
|
} else {
|
||||||
} else {
|
clsSFX.beep()
|
||||||
clsSFX.beep()
|
if !bolPreviousFolderValidity {
|
||||||
if !bolPreviousFolderValidity {
|
mgrPrefs.resetSpecifiedUserDataFolder()
|
||||||
mgrPrefs.resetSpecifiedUserDataFolder()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if !bolPreviousFolderValidity {
|
|
||||||
mgrPrefs.resetSpecifiedUserDataFolder()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if !bolPreviousFolderValidity {
|
||||||
|
mgrPrefs.resetSpecifiedUserDataFolder()
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
} // End If self.window != nil
|
}
|
||||||
} // End IBAction
|
} // End IBAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue