瀏覽代碼

【PDF工具 - 批量】添加文件入口交互补充

lizhe 2 年之前
父節點
當前提交
a532ef9c54
共有 17 個文件被更改,包括 186 次插入88 次删除
  1. 16 0
      PDF Office/PDF Office.xcodeproj/project.pbxproj
  2. 18 2
      PDF Office/PDF Office.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 5 2
      PDF Office/PDF Office/Class/Merge/Tools/KMMergeTools.swift
  4. 20 0
      PDF Office/PDF Office/Class/PDFTools/Batch/KMBatchManager/KMBatchManager.swift
  5. 1 1
      PDF Office/PDF Office/Class/PDFTools/Batch/KMBatchWindowController.swift
  6. 1 1
      PDF Office/PDF Office/Class/PDFTools/Batch/View/Choose/ConvertPDF/Model/KMBatchConvertPDFViewModel.swift
  7. 4 3
      PDF Office/PDF Office/Class/PDFTools/Batch/View/Choose/ConvertPDF/Presenter/KMBatchConvertPDFViewPresenter.swift
  8. 1 1
      PDF Office/PDF Office/Class/PDFTools/Batch/View/Choose/ConvertPDF/Views/TextRecognition/KMBatchTextRecognitionView.swift
  9. 1 1
      PDF Office/PDF Office/Class/PDFTools/ImageToPDF/KMImageToPDFWindowController.swift
  10. 94 35
      PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMBatchProcessingView/KMBatchProcessingView.swift
  11. 0 1
      PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMBatchProcessingView/Tableview/KMBatchProcessingTableView.swift
  12. 1 0
      PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMBatchProcessingView/Tableview/Views/Tableview/Views/KMBatchProcessingOrderTableCell.swift
  13. 2 2
      PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMImageToPDFChooseView/KMImageToPDFChooseView.swift
  14. 1 2
      PDF Office/PDF Office/Class/PDFTools/OCR/KMOCRWindowController.swift
  15. 1 1
      PDF Office/PDF Office/Class/PDFTools/OCR/View/KMOCRChooseView/KMOCRChooseView.swift
  16. 1 1
      PDF Office/PDF Office/Class/PDFTools/Print/KMPrintWindowController.swift
  17. 19 35
      PDF Office/PDF Office/Class/PDFTools/Tools/KMTextfieldButton/KMTextfieldButton.swift

+ 16 - 0
PDF Office/PDF Office.xcodeproj/project.pbxproj

@@ -1223,6 +1223,9 @@
 		ADBC2D3A299F0A5A006280C8 /* KMPrintHelpViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADBC2D36299F0A5A006280C8 /* KMPrintHelpViewController.xib */; };
 		ADBC2D3B299F0A5A006280C8 /* KMPrintHelpViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADBC2D36299F0A5A006280C8 /* KMPrintHelpViewController.xib */; };
 		ADBC2D3C299F0A5A006280C8 /* KMPrintHelpViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADBC2D36299F0A5A006280C8 /* KMPrintHelpViewController.xib */; };
+		ADBC2D3F299F70A8006280C8 /* KMBatchManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADBC2D3E299F70A8006280C8 /* KMBatchManager.swift */; };
+		ADBC2D40299F70A8006280C8 /* KMBatchManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADBC2D3E299F70A8006280C8 /* KMBatchManager.swift */; };
+		ADBC2D41299F70A8006280C8 /* KMBatchManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADBC2D3E299F70A8006280C8 /* KMBatchManager.swift */; };
 		ADC075B629866962006C752F /* KMBatchConverPDFWordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC075B529866962006C752F /* KMBatchConverPDFWordView.swift */; };
 		ADC075B729866962006C752F /* KMBatchConverPDFWordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC075B529866962006C752F /* KMBatchConverPDFWordView.swift */; };
 		ADC075B829866962006C752F /* KMBatchConverPDFWordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC075B529866962006C752F /* KMBatchConverPDFWordView.swift */; };
@@ -3271,6 +3274,7 @@
 		ADBC2D27299DCA76006280C8 /* NSTextField+Layer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSTextField+Layer.swift"; sourceTree = "<group>"; };
 		ADBC2D35299F0A5A006280C8 /* KMPrintHelpViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPrintHelpViewController.swift; sourceTree = "<group>"; };
 		ADBC2D36299F0A5A006280C8 /* KMPrintHelpViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMPrintHelpViewController.xib; sourceTree = "<group>"; };
+		ADBC2D3E299F70A8006280C8 /* KMBatchManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchManager.swift; sourceTree = "<group>"; };
 		ADC075B529866962006C752F /* KMBatchConverPDFWordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchConverPDFWordView.swift; sourceTree = "<group>"; };
 		ADC075B929866984006C752F /* KMBatchConverPDFWordView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMBatchConverPDFWordView.xib; sourceTree = "<group>"; };
 		ADC075BF29866AE6006C752F /* KMBatchTextRecognitionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchTextRecognitionView.swift; sourceTree = "<group>"; };
@@ -5024,6 +5028,7 @@
 		ADB1FE21297005DF00ED072D /* Batch */ = {
 			isa = PBXGroup;
 			children = (
+				ADBC2D3D299F704E006280C8 /* KMBatchManager */,
 				ADE614AA29779BE100F62ED7 /* Tool */,
 				ADB1FE4B2972958100ED072D /* Source */,
 				ADB1FE2E297008B000ED072D /* View */,
@@ -5297,6 +5302,14 @@
 			path = Size;
 			sourceTree = "<group>";
 		};
+		ADBC2D3D299F704E006280C8 /* KMBatchManager */ = {
+			isa = PBXGroup;
+			children = (
+				ADBC2D3E299F70A8006280C8 /* KMBatchManager.swift */,
+			);
+			path = KMBatchManager;
+			sourceTree = "<group>";
+		};
 		ADC075B42986693E006C752F /* Views */ = {
 			isa = PBXGroup;
 			children = (
@@ -8314,6 +8327,7 @@
 				F359916929261F0D000D25DE /* CPDFListView+Tool.m in Sources */,
 				9F0CB47F2967F64D00007028 /* KMPropertiesPanelReadOnlySubVC.swift in Sources */,
 				BB2EDF76296ECE17003BCF58 /* KMPageEditInsertPageSizeItemView.swift in Sources */,
+				ADBC2D3F299F70A8006280C8 /* KMBatchManager.swift in Sources */,
 				9F1FE49F29406E4700E952CA /* HoverButton.m in Sources */,
 				F37322F0292DF9410013862C /* CPDFButtonWidgetAnnotation+PDFListView.m in Sources */,
 				F34BF93029530559002C25A2 /* NSBitmapImageRep+PDFListView.m in Sources */,
@@ -8973,6 +8987,7 @@
 				BB89DD7F2953F863007C3FFA /* KMWatermarkFileOutsideView.swift in Sources */,
 				9F0CB4802967F64D00007028 /* KMPropertiesPanelReadOnlySubVC.swift in Sources */,
 				BB2EDF77296ECE17003BCF58 /* KMPageEditInsertPageSizeItemView.swift in Sources */,
+				ADBC2D40299F70A8006280C8 /* KMBatchManager.swift in Sources */,
 				9F1F82DB292F84D60092C4B4 /* KMHomeInsertActionViewController.swift in Sources */,
 				BB86C1EE28F544F4005AD968 /* CPDFListView+Event.m in Sources */,
 				9F1FE4A029406E4700E952CA /* HoverButton.m in Sources */,
@@ -9901,6 +9916,7 @@
 				9FAAA340290FECA70046FFCE /* NSImage+QuickLook.swift in Sources */,
 				BB147025299DC0D100784A6A /* OIDResponseTypes.m in Sources */,
 				BB14701C299DC0D100784A6A /* OIDURLSessionProvider.m in Sources */,
+				ADBC2D41299F70A8006280C8 /* KMBatchManager.swift in Sources */,
 				BB49ECF8293F44DC00C82CA2 /* KMConvertExcelWindowController.swift in Sources */,
 				9FBC48BA299B44C600CA39D7 /* KMSecondaryViewController.m in Sources */,
 				9F1FE4EC29406E4700E952CA /* NSBezierPath+MCAdditions.m in Sources */,

+ 18 - 2
PDF Office/PDF Office.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -190,8 +190,8 @@
             filePath = "PDF Office/Class/PDFTools/OCR/KMOCRWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "89"
-            endingLineNumber = "89"
+            startingLineNumber = "88"
+            endingLineNumber = "88"
             landmarkName = "exportAction(data:)"
             landmarkType = "7">
          </BreakpointContent>
@@ -1066,5 +1066,21 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "BB5EA9D7-D045-4200-8C7B-BAF04E8E5E37"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Office/Class/PDFTools/ImageToPDF/View/KMBatchProcessingView/KMBatchProcessingView.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "169"
+            endingLineNumber = "169"
+            landmarkName = "addFolder()"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 5 - 2
PDF Office/PDF Office/Class/Merge/Tools/KMMergeTools.swift

@@ -9,7 +9,7 @@ import Cocoa
 
 class KMMergeTools: NSObject {
     
-    class func findAllFiles(folder: URL, result: inout [URL]) {
+    class func findAllFiles(folder: URL, result: inout [URL], types: [String] = []) {
         let fileManager = FileManager.default
         var isDirectory: ObjCBool = ObjCBool(false)
         fileManager.fileExists(atPath: folder.path, isDirectory: &isDirectory)
@@ -22,7 +22,10 @@ class KMMergeTools: NSObject {
             return
         }
         
-        let array = ["jpg","cur","bmp","jpeg","gif","png","tiff","tif",/*@"pic",*/"ico","icns","tga","psd","eps","hdr","jp2","jpc","pict","sgi","heic","pdf"]
+        var array = ["jpg","cur","bmp","jpeg","gif","png","tiff","tif",/*@"pic",*/"ico","icns","tga","psd","eps","hdr","jp2","jpc","pict","sgi","heic","pdf"]
+        if types.count != 0 {
+            array = types
+        }
         for documentURL in contents! {
             var isDirectory: ObjCBool = ObjCBool(false)
             fileManager.fileExists(atPath: documentURL.path, isDirectory: &isDirectory)

+ 20 - 0
PDF Office/PDF Office/Class/PDFTools/Batch/KMBatchManager/KMBatchManager.swift

@@ -0,0 +1,20 @@
+//
+//  KMBatchManager.swift
+//  PDF Office
+//
+//  Created by lizhe on 2023/2/17.
+//
+
+import Cocoa
+
+enum KMBatchManagerSate: String, CaseIterable {
+    case unknow
+    case processing
+}
+
+class KMBatchManager: NSObject {
+    public static let manager = KMBatchManager()
+    fileprivate(set) var state: KMBatchManagerSate = .unknow
+    
+    
+}

+ 1 - 1
PDF Office/PDF Office/Class/PDFTools/Batch/KMBatchWindowController.swift

@@ -91,7 +91,7 @@ class KMBatchWindowController: NSWindowController {
             openPanel.canChooseFiles = true
             openPanel.allowsMultipleSelection = true
             openPanel.allowedFileTypes = KMOCRModel.supportedTypes()
-        } completion: { data in
+        } completion: { (panel ,data) in
             if data.count != 0 {
                 let batchWindowController: KMBatchWindowController = KMBatchWindowController.init(windowNibName: "KMBatchWindowController")
                 batchWindowController.showWindow(window)

+ 1 - 1
PDF Office/PDF Office/Class/PDFTools/Batch/View/Choose/ConvertPDF/Model/KMBatchConvertPDFViewModel.swift

@@ -127,7 +127,7 @@ enum KMBatchConvertPDFImageType: String, CaseIterable {
 class KMBatchConvertPDFViewModel: KMBatchSettingItemViewModel {
     var languageType: KMOCRLanguageType = .english
     var convertPDFType: KMBatchConvertPDFType = .word
-    var needRecognizeText: Bool = false
+    var needRecognizeText: Bool = true
     //word
     var layoutSettingType: KMBatchLayoutSettingType = .flowingText
     //excel

+ 4 - 3
PDF Office/PDF Office/Class/PDFTools/Batch/View/Choose/ConvertPDF/Presenter/KMBatchConvertPDFViewPresenter.swift

@@ -82,8 +82,8 @@ extension KMBatchConvertPDFViewPresenter: KMBatchConvertPDFViewPresenterProtocol
         self.delegate?.showData(presenter: self, data: self.modelData)
     }
     
-    func needRecognizeTextAction(button: NSButton) {
-        self.modelData.needRecognizeText = (button.state == .on) ? true : false
+    func needRecognizeTextAction() {
+        self.modelData.needRecognizeText = !self.modelData.needRecognizeText
         
         self.delegate?.showData(presenter: self, data: self.modelData)
     }
@@ -169,7 +169,8 @@ protocol KMBatchConvertPDFViewPresenterProtocol {
      @abstract 文字识别
      */
     func recognizeTextLanguageAction(string: String)
-    func needRecognizeTextAction(button: NSButton)
+    
+    func needRecognizeTextAction()
     /**
      @abstract 解除绑定
      */

+ 1 - 1
PDF Office/PDF Office/Class/PDFTools/Batch/View/Choose/ConvertPDF/Views/TextRecognition/KMBatchTextRecognitionView.swift

@@ -24,7 +24,7 @@ class KMBatchTextRecognitionView: KMBatchConvertPDFItemView {
         self.recognizeTextButton.title = NSLocalizedString("Recognize text if needed", comment: "")
         self.recognizeTextButton.imageName = "btn_checkbox_unsel_on"
         self.recognizeTextButton.action = { [unowned self] (view, button) in
-            self.presenter.needRecognizeTextAction(button: button)
+            self.presenter.needRecognizeTextAction()
         }
         
         self.textRecognitionSettingLabel.textColor = NSColor.init(hex: "#616469")

+ 1 - 1
PDF Office/PDF Office/Class/PDFTools/ImageToPDF/KMImageToPDFWindowController.swift

@@ -54,7 +54,7 @@ class KMImageToPDFWindowController: NSWindowController {
             openPanel.canChooseFiles = true
             openPanel.allowsMultipleSelection = true
             openPanel.allowedFileTypes = KMBatchProcessingTableViewModel.supportedImageTypes()
-        } completion: { data in
+        } completion: { (panel ,data) in
             if data.count != 0 {
                 let imageToPDFWindow: KMImageToPDFWindowController = KMImageToPDFWindowController.init(windowNibName: "KMImageToPDFWindowController")
                 imageToPDFWindow.showWindow(window)

+ 94 - 35
PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMBatchProcessingView/KMBatchProcessingView.swift

@@ -71,19 +71,19 @@ class KMBatchProcessingView: NSView {
     }
     
     func setup() {
-        self.addButton.data = ["Import from", "Import from Camera...", "Import from Scanner..."]
+        self.addButton.data = ["Add Files", "Add Folder", "Add Open Files"]
         self.addButton.textColor = NSColor.init(hex: "#252629")
         self.addButton.font = NSFont.SFProTextRegular(14.0)
         self.addButton.stringValue = NSLocalizedString("Add Files", comment: "")
         self.addButton.border()
-        self.addButton.popWidth = 170.0
+        self.addButton.popWidth = 150.0
         self.addButton.mouseDownAction = { [unowned self] (button, itemString) in
             if itemString == NSLocalizedString(self.addButton.data[0], comment: "") {
-                self.addPhotos(sender: button)
+                self.addFiles()
             } else if itemString == NSLocalizedString(self.addButton.data[1], comment: "") {
-                self.addPhotosFromCamera(sender: button)
+                self.addFolder()
             } else if itemString == NSLocalizedString(self.addButton.data[2], comment: "") {
-                self.addPhotosFromScanner(sender: button)
+                self.addOpenFile()
             }
         }
         
@@ -96,7 +96,7 @@ class KMBatchProcessingView: NSView {
         }
         
         self.selectedFilesView.addAction = {[unowned self] (sender) in
-            self.addPhotos(sender: sender)
+            self.addFiles()
         }
         self.reloadData()
     }
@@ -122,58 +122,113 @@ extension KMBatchProcessingView: KMBatchProcessingViewAction {
         self.reloadData()
     }
     
-    @objc func addPhotos(sender: Any) {
-        weak var weakSelf = self
-        KMBatchProcessingView.openfiles(window: window!) { openPanel in
-            if weakSelf?.inputType == .OCR {
-                openPanel.prompt = "PDF"
+    func addFiles() {
+        KMBatchProcessingView.openfiles(window: window!) { [unowned self] openPanel in
+            if self.inputType == .OCR {
                 openPanel.allowedFileTypes = KMOCRModel.supportedTypes()
-            } else if weakSelf?.inputType == .ImageToPDF {
-                openPanel.prompt = "选择图片"
+            } else if self.inputType == .ImageToPDF {
                 openPanel.allowedFileTypes = KMBatchProcessingTableViewModel.supportedImageTypes()
             }
             
+            openPanel.prompt = "Open"
             openPanel.canChooseDirectories = false //是否允许选择目录
             openPanel.canChooseFiles = true //是否可以选择文件
             openPanel.allowsMultipleSelection = true //是否允许多选
-        } completion: { [unowned self] data in
+            
+            if openPanel.allowsMultipleSelection == true {
+                openPanel.message = NSLocalizedString("Press the keyboard ⌘/⇧ to select multiple files", comment: "")
+            }
+        } completion: { [unowned self] (panel ,data) in
             if data.count != 0 {
                 self.tableView.presenter.addData(data: data)
                 self.reloadData()
             }
         }
-
-        print("AddPhotos")
     }
     
-    @objc func addPhotosFromCamera(sender: AnyObject) {
-        print("AddPhotosFromCamera")
-        let windowController = KMDeviceBrowserWindowController.init(windowNibName: "KMDeviceBrowserWindowController")
-        windowController.type = .camera
-        windowController.importCameraFileCallback = { [unowned self] (url) in
-//            NSDocumentController.shared.openDocumentWithContents(of: url, display: true)
-            print("获取照片成功")
+    func addFolder() {
+        print("addFolder")
+        KMBatchProcessingView.openfiles(window: window!) { [unowned self] openPanel in
+            if self.inputType == .OCR {
+                openPanel.allowedFileTypes = KMOCRModel.supportedTypes()
+            } else if self.inputType == .ImageToPDF {
+                openPanel.allowedFileTypes = KMBatchProcessingTableViewModel.supportedImageTypes()
+            } else {
+                openPanel.allowedFileTypes = KMOCRModel.supportedTypes()
+            }
+            
+            openPanel.prompt = "Open"
+            openPanel.canChooseDirectories = true //是否允许选择目录
+            openPanel.canChooseFiles = false //是否可以选择文件
+            openPanel.allowsMultipleSelection = false //是否允许多选
+        } completion: { [unowned self] (panel ,data) in
+            if data.count != 0 {
+                var filePaths: [URL] = []
+                
+                var types: [String] = []
+                if self.inputType == .OCR {
+                    types = KMOCRModel.supportedTypes()
+                } else if self.inputType == .ImageToPDF {
+                    types = KMBatchProcessingTableViewModel.supportedImageTypes()
+                } else {
+                    types = KMOCRModel.supportedTypes()
+                }
+                
+                KMMergeTools.findAllFiles(folder: data.first!, result: &filePaths, types: types)
+                self.tableView.presenter.addData(data: filePaths)
+                self.reloadData()
+            }
         }
-        windowController.showWindow(nil)
     }
     
-    @objc func addPhotosFromScanner(sender: AnyObject) {
-        print("AddPhotosFromScanner")
-        let windowController = KMDeviceBrowserWindowController.init(windowNibName: "KMDeviceBrowserWindowController")
-        windowController.type = .scanner
-        windowController.importScannerFileCallback = { [unowned self] (url) in
-            print("获取扫描成功")
-//            NSDocumentController.shared.openDocumentWithContents(of: url, display: true)
+    func canAddOpenFile() -> Bool {
+        var result: Bool = false
+        let array = self.addOpenFile()
+        if array.count != 0 {
+            result = true
         }
-        windowController.showWindow(nil)
+        return result
     }
     
+    func addOpenFile() -> [URL] {
+        var files:[URL] = []
+        for window in NSApp.windows {
+            let controller = window.windowController
+            if ((controller?.isKind(of: CTBrowserWindowController.classForCoder())) != nil) {
+                continue
+            }
+            
+            let model = (controller as? CTBrowserWindowController)?.browser.tabStripModel
+            let count = model?.count() ?? 0
+            if count > 0 {
+                for i in 0...(count - 1) {
+                    let document: KMMainDocument = model?.tabContents(at: Int32(i)) as? KMMainDocument ?? KMMainDocument()
+                    if document.isHome {
+                        continue
+                    }
+                    
+                    if !(FileManager.default.fileExists(atPath: document.fileURL?.path ?? "")) {
+                        continue
+                    }
+                    
+                    if document.fileURL != nil {
+                        files.append(document.fileURL!)
+                    }
+                }
+            }
+        }
+        return files
+    }
+}
+
+protocol KMBatchProcessingViewOpenPanel {}
+extension KMBatchProcessingView: KMBatchProcessingViewOpenPanel {
     /**
       @abstract 打开文件
       @param window 显示window
       @param title 标题
       */
-    static func openfiles(window:NSWindow, openPanel:((_ openPanel: NSOpenPanel) -> Void)?, completion:@escaping/**逃逸闭包*/ (_ data:[URL]) -> Void) {
+    static func openfiles(window:NSWindow, openPanel:((_ openPanel: NSOpenPanel) -> Void)?, completion:@escaping/**逃逸闭包*/ (_ panel: NSOpenPanel ,_ data:[URL]) -> Void) {
         let panel = NSOpenPanel()
         if openPanel != nil {
             openPanel!(panel)
@@ -183,14 +238,18 @@ extension KMBatchProcessingView: KMBatchProcessingViewAction {
             panel.canChooseFiles = true //是否可以选择文件
             panel.allowsMultipleSelection = true //是否允许多选
             panel.allowedFileTypes = KMBatchProcessingTableViewModel.supportedImageTypes() //支持类型
+            
+//            let button = NSButton.init(checkboxWithTitle: "保存后打开文档", target: nil, action: nil)
+//            button.state = .off
+//            panel.accessoryView = button
         }
         
         panel.beginSheetModal(for: window, completionHandler: { result in
             if result != .OK {
                 print("取消")
-                completion([])
+                completion(panel, [])
             } else {
-                completion(panel.urls)
+                completion(panel, panel.urls)
             }
         })
     }

+ 0 - 1
PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMBatchProcessingView/Tableview/KMBatchProcessingTableView.swift

@@ -197,7 +197,6 @@ extension KMBatchProcessingTableView: NSTableViewDelegate {
                 for i in 0...self.data!.count - 1 {
                     let model = self.data![i]
                     model.hover = false
-                    print(row)
                     if i == row {
                         if mouseEntered {
                             model.hover = true

+ 1 - 0
PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMBatchProcessingView/Tableview/Views/Tableview/Views/KMBatchProcessingOrderTableCell.swift

@@ -56,6 +56,7 @@ class KMBatchProcessingOrderTableCell: KMBatchProcessingTableCell {
         self.orderButton.stringValue = NSLocalizedString(self.model.pageRange.type.rawValue, comment: "")
         self.orderButton.font = NSFont.SFProTextRegular(12.0)
         self.orderButton.textColor = NSColor.init(hex: "#252629")
+        self.orderButton.backgroundColor(NSColor.init(hex: "FFFFFF"))
         self.orderButton.mouseDownAction = {[unowned self] (button, itemString) in
             self.model.pageRange.type = KMPrintPageRange.PageRangeType.typeOfRawValue(itemString)
             self.orderButton.stringValue = itemString

+ 2 - 2
PDF Office/PDF Office/Class/PDFTools/ImageToPDF/View/KMImageToPDFChooseView/KMImageToPDFChooseView.swift

@@ -185,7 +185,7 @@ extension KMImageToPDFChooseView: KMImageToPDFChooseViewAction {
             openPanel.canChooseFiles = true //是否可以选择文件
             openPanel.allowsMultipleSelection = false //是否允许多选
             openPanel.allowedFileTypes = ["pdf"]
-        } completion: { [unowned self] data in
+        } completion: { [unowned self] (panel, data) in
             if data.count != 0 {
                 self.presenter.addFile(filePath: data.first!.path)
             }
@@ -205,7 +205,7 @@ extension KMImageToPDFChooseView: KMImageToPDFChooseViewAction {
                 openPanel.canChooseDirectories = true //是否允许选择目录
                 openPanel.canChooseFiles = false //是否可以选择文件
                 openPanel.allowsMultipleSelection = false //是否允许多选
-            } completion: { data in
+            } completion: { [unowned self](panel ,data) in
                 if data.count != 0 {
                     self.presenter.export(filePath: data.first!.path)
                 }

+ 1 - 2
PDF Office/PDF Office/Class/PDFTools/OCR/KMOCRWindowController.swift

@@ -48,7 +48,7 @@ class KMOCRWindowController: NSWindowController {
             openPanel.canChooseFiles = true
             openPanel.allowsMultipleSelection = true
             openPanel.allowedFileTypes = ["pdf"]
-        } completion: { data in
+        } completion: {(panel ,data) in
             if data.count != 0 {
                 let imageToPDFWindow: KMOCRWindowController = KMOCRWindowController.init(windowNibName: "KMOCRWindowController")
                 imageToPDFWindow.showWindow(window)
@@ -67,7 +67,6 @@ extension KMOCRWindowController: KMImageToPDFChooseViewDelegate {
 
         if self.batchData != nil {
             self.chooseData?.imageFilePaths = self.batchData
-            weak var weakSelf = self
             KMImageToPDFManager.manager.exportPDF(model: self.chooseData!) { success, savePath, errors, OCRerrors in
                 print(success)
                 if success {

+ 1 - 1
PDF Office/PDF Office/Class/PDFTools/OCR/View/KMOCRChooseView/KMOCRChooseView.swift

@@ -63,7 +63,7 @@ extension KMOCRChooseView: KMOCRChooseViewAction {
                 openPanel.canChooseDirectories = true //是否允许选择目录
                 openPanel.canChooseFiles = false //是否可以选择文件
                 openPanel.allowsMultipleSelection = false //是否允许多选
-            } completion: { data in
+            } completion: { [unowned self](panel ,data) in
                 if data.count != 0 {
                     self.presenter.export(filePath: data.first!.path)
                 }

+ 1 - 1
PDF Office/PDF Office/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -86,7 +86,7 @@ class KMPrintWindowController: NSWindowController, NetServiceBrowserDelegate {
             openPanel.canChooseFiles = true
             openPanel.allowsMultipleSelection = false
             openPanel.allowedFileTypes = KMOCRModel.supportedTypes()
-        } completion: { data in
+        } completion: { (panel ,data) in
             if data.count != 0 {
                 let printWindowController: KMPrintWindowController = KMPrintWindowController.init(windowNibName: "KMPrintWindowController")
                 NSApp.mainWindow?.beginCriticalSheet(printWindowController.window!)

+ 19 - 35
PDF Office/PDF Office/Class/PDFTools/Tools/KMTextfieldButton/KMTextfieldButton.swift

@@ -75,34 +75,27 @@ class KMTextfieldButton: KMBaseXibView {
     
     @IBAction func buttonAction(_ sender: NSButton) {
         if self.data.count != 0 {
-            if createFilePopover == nil {
-                var popViewDataArr: [String] = []
-                for string in self.data {
-                    popViewDataArr.append(NSLocalizedString(string, comment: ""))
-                }
-                
-                let vc: KMHomePopViewController = KMHomePopViewController().initWithPopViewDataArr(popViewDataArr)
-                createFilePopover = NSPopover.init()
-                createFilePopover?.delegate = self
-                createFilePopover!.contentViewController = vc
-                createFilePopover!.animates = true
-                createFilePopover!.behavior = .semitransient
-                createFilePopover!.setValue(true, forKey: "shouldHideAnchor")
-                createFilePopover!.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: -10, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
-                
-                vc.customBoxWidthLayoutConstraint.constant = self.popWidth ?? sender.frame.width
-                vc.downCallback = { [self](downEntered: Bool, count: String) -> Void in
-                    if downEntered {
-                        if self.mouseDownAction != nil {
-                            self.mouseDownAction!(sender, count)
-                        }
-                        createFilePopover!.close()
-                        createFilePopover = nil
+            var popViewDataArr: [String] = []
+            for string in self.data {
+                popViewDataArr.append(NSLocalizedString(string, comment: ""))
+            }
+            
+            let vc: KMHomePopViewController = KMHomePopViewController().initWithPopViewDataArr(popViewDataArr)
+            let createFilePopover: NSPopover = NSPopover.init()
+            createFilePopover.contentViewController = vc
+            createFilePopover.animates = true
+            createFilePopover.behavior = .semitransient
+            createFilePopover.setValue(true, forKey: "shouldHideAnchor")
+            createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: -10, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
+            
+            vc.customBoxWidthLayoutConstraint.constant = self.popWidth ?? sender.frame.width
+            vc.downCallback = { [self](downEntered: Bool, count: String) -> Void in
+                if downEntered {
+                    if self.mouseDownAction != nil {
+                        self.mouseDownAction!(sender, count)
                     }
+                    createFilePopover.close()
                 }
-            } else {
-                createFilePopover!.close()
-                createFilePopover = nil
             }
         } else {
             if self.mouseDownAction != nil {
@@ -111,12 +104,3 @@ class KMTextfieldButton: KMBaseXibView {
         }
     }
 }
-
-extension KMTextfieldButton: NSPopoverDelegate {
-    func popoverDidClose(_ notification: Notification) {
-        if createFilePopover != nil {
-            createFilePopover?.close()
-            createFilePopover = nil
-        }
-    }
-}