diff --git a/Source/Modules/WindowControllers/CtlPrefWindow.swift b/Source/Modules/WindowControllers/CtlPrefWindow.swift index cd254395f..26407d37b 100644 --- a/Source/Modules/WindowControllers/CtlPrefWindow.swift +++ b/Source/Modules/WindowControllers/CtlPrefWindow.swift @@ -462,6 +462,30 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate { } } } + + @IBAction func importYahooKeyKeyUserDictionaryData(_: NSButton) { + let dlgOpenFile = NSOpenPanel() + dlgOpenFile.title = NSLocalizedString( + "i18n:settings.importFromKimoTxt.buttonText", comment: "" + ) + ":" + dlgOpenFile.showsResizeIndicator = true + dlgOpenFile.showsHiddenFiles = true + dlgOpenFile.canChooseFiles = true + dlgOpenFile.allowsMultipleSelection = false + dlgOpenFile.canChooseDirectories = false + dlgOpenFile.allowedContentTypes = [.init(filenameExtension: "txt")].compactMap { $0 } + + if let window = window { + dlgOpenFile.beginSheetModal(for: window) { result in + if result == NSApplication.ModalResponse.OK { + guard let url = dlgOpenFile.url else { return } + guard var rawString = try? String(contentsOf: url) else { return } + let count = LMMgr.importYahooKeyKeyUserDictionary(text: &rawString) + window.callAlert(title: String(format: "i18n:settings.importFromKimoTxt.finishedCount:%@".localized, count.description)) + } + } + } + } } // MARK: - NSToolbarDelegate Methods diff --git a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib index 381970133..ed6348466 100644 --- a/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib +++ b/Source/WindowNIBs/Base.lproj/frmPrefWindow.xib @@ -1492,14 +1492,14 @@ - + - + - + @@ -1507,7 +1507,7 @@ - + @@ -1569,6 +1569,16 @@ + @@ -1708,11 +1718,13 @@ + + @@ -1721,7 +1733,7 @@ - +