Browse Source

【UI替换】编辑工具 - Compress

lizhe 1 year ago
parent
commit
e428cae043

+ 32 - 8
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -1156,6 +1156,18 @@
 		AD1CA4342A0640FC0070541F /* KMAnnotationScreenHeadView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1CA4332A0640FC0070541F /* KMAnnotationScreenHeadView.xib */; };
 		AD1CA4352A0640FC0070541F /* KMAnnotationScreenHeadView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1CA4332A0640FC0070541F /* KMAnnotationScreenHeadView.xib */; };
 		AD1CA4362A0640FC0070541F /* KMAnnotationScreenHeadView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1CA4332A0640FC0070541F /* KMAnnotationScreenHeadView.xib */; };
+		AD1D48082AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1D48062AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift */; };
+		AD1D48092AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1D48062AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift */; };
+		AD1D480A2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1D48062AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift */; };
+		AD1D480B2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1D48072AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib */; };
+		AD1D480C2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1D48072AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib */; };
+		AD1D480D2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1D48072AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib */; };
+		AD1D480F2AFB1907007AC1F0 /* KMCompressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1D480E2AFB1907007AC1F0 /* KMCompressView.swift */; };
+		AD1D48102AFB1907007AC1F0 /* KMCompressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1D480E2AFB1907007AC1F0 /* KMCompressView.swift */; };
+		AD1D48112AFB1907007AC1F0 /* KMCompressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1D480E2AFB1907007AC1F0 /* KMCompressView.swift */; };
+		AD1D48132AFB1912007AC1F0 /* KMCompressView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1D48122AFB1912007AC1F0 /* KMCompressView.xib */; };
+		AD1D48142AFB1912007AC1F0 /* KMCompressView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1D48122AFB1912007AC1F0 /* KMCompressView.xib */; };
+		AD1D48152AFB1912007AC1F0 /* KMCompressView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD1D48122AFB1912007AC1F0 /* KMCompressView.xib */; };
 		AD2D74AD29F0CEB300EDC5E4 /* KMCancellationWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD2D74AB29F0CEB300EDC5E4 /* KMCancellationWindowController.swift */; };
 		AD2D74AE29F0CEB300EDC5E4 /* KMCancellationWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD2D74AB29F0CEB300EDC5E4 /* KMCancellationWindowController.swift */; };
 		AD2D74AF29F0CEB300EDC5E4 /* KMCancellationWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD2D74AB29F0CEB300EDC5E4 /* KMCancellationWindowController.swift */; };
@@ -4019,6 +4031,10 @@
 		AD1CA4202A061D190070541F /* KMAnnotationScreenAuthorViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMAnnotationScreenAuthorViewItem.xib; sourceTree = "<group>"; };
 		AD1CA42F2A0640F20070541F /* KMAnnotationScreenHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMAnnotationScreenHeadView.swift; sourceTree = "<group>"; };
 		AD1CA4332A0640FC0070541F /* KMAnnotationScreenHeadView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMAnnotationScreenHeadView.xib; sourceTree = "<group>"; };
+		AD1D48062AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCompressWIndowControllerNew.swift; sourceTree = "<group>"; };
+		AD1D48072AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMCompressWIndowControllerNew.xib; sourceTree = "<group>"; };
+		AD1D480E2AFB1907007AC1F0 /* KMCompressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCompressView.swift; sourceTree = "<group>"; };
+		AD1D48122AFB1912007AC1F0 /* KMCompressView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMCompressView.xib; sourceTree = "<group>"; };
 		AD2D74AB29F0CEB300EDC5E4 /* KMCancellationWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCancellationWindowController.swift; sourceTree = "<group>"; };
 		AD2D74AC29F0CEB300EDC5E4 /* KMCancellationWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMCancellationWindowController.xib; sourceTree = "<group>"; };
 		AD2D74B429F0D39500EDC5E4 /* KMCancellationSuccessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCancellationSuccessView.swift; sourceTree = "<group>"; };
@@ -8780,7 +8796,6 @@
 		BBF2454E2AE7726800037D08 /* WindowController */ = {
 			isa = PBXGroup;
 			children = (
-				BBFDFA972AF33D9D00E08AA2 /* OC */,
 				BBE9D0952AF0CEB6002E83CE /* VC */,
 				BBFD2B102AEFAADB0016C456 /* Base */,
 				BB1BFF5C2AE9F1FF003EB179 /* KMBatchOperateBaseWindowController.swift */,
@@ -8984,13 +8999,6 @@
 			path = Base;
 			sourceTree = "<group>";
 		};
-		BBFDFA972AF33D9D00E08AA2 /* OC */ = {
-			isa = PBXGroup;
-			children = (
-			);
-			path = OC;
-			sourceTree = "<group>";
-		};
 		BBFE6E7B2930EB8F00142C01 /* Compress */ = {
 			isa = PBXGroup;
 			children = (
@@ -9005,6 +9013,8 @@
 			children = (
 				BBFE6E7D2930EBD400142C01 /* KMCompressWindowController.swift */,
 				BBFE6E7E2930EBD400142C01 /* KMCompressWindowController.xib */,
+				AD1D48062AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift */,
+				AD1D48072AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib */,
 			);
 			path = Controller;
 			sourceTree = "<group>";
@@ -9013,6 +9023,8 @@
 			isa = PBXGroup;
 			children = (
 				BBFE6E86293210AB00142C01 /* KMCompressCellView.swift */,
+				AD1D480E2AFB1907007AC1F0 /* KMCompressView.swift */,
+				AD1D48122AFB1912007AC1F0 /* KMCompressView.xib */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -9559,6 +9571,7 @@
 				9F8539E7294712D600DF644E /* KMChromiumTabContents.xib in Resources */,
 				BB003018298CA446002DD1A0 /* KMPreferenceGeneralController.xib in Resources */,
 				ADBC376129CC637900D93208 /* KMReadModelView.xib in Resources */,
+				AD1D480B2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib in Resources */,
 				9F1F82DD292F84D60092C4B4 /* KMHomeInsertActionViewController.xib in Resources */,
 				9F78EFBE28F7C1CC001E66F4 /* KMHomeViewController.xib in Resources */,
 				9F3D818A29A0A9A70087B5AD /* KMDesignButton.xib in Resources */,
@@ -9615,6 +9628,7 @@
 				9F00CF542A38657400AC462E /* GoogleService-Info.plist in Resources */,
 				AD88108729A719E500178CA1 /* KMRegisterView.xib in Resources */,
 				BB1EC8012967B26700EC0BC3 /* KMPDFEditViewController.xib in Resources */,
+				AD1D48132AFB1912007AC1F0 /* KMCompressView.xib in Resources */,
 				BBEC00DC295C39FD00A26C98 /* KMBatesPropertyInfoController.xib in Resources */,
 				BB6CA4CF298BB0D000A13864 /* KMPreferenceWindowController.xib in Resources */,
 				AD8810B529A846B100178CA1 /* KMVerficationCodeWindowController.xib in Resources */,
@@ -9821,6 +9835,8 @@
 				BB5DF1ED2959C5CB0025CDA1 /* KMHeaderFooterPreviewController.xib in Resources */,
 				ADEC7A82299397F8009A8256 /* SF-Pro-Text-Regular.otf in Resources */,
 				ADC63E442A49817400854E02 /* KMSubscribeSuccessView.xib in Resources */,
+				AD1D480C2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib in Resources */,
+				AD1D48142AFB1912007AC1F0 /* KMCompressView.xib in Resources */,
 				89E4E77D2967B370002DBA6F /* KMDynamicStampViewController.xib in Resources */,
 				BB49ECE1293EED6100C82CA2 /* KMConvertWordWindowController.xib in Resources */,
 				BBC348572958465C008D2CD1 /* KMBackgroundFilePropertyInfoController.xib in Resources */,
@@ -10084,6 +10100,7 @@
 				ADEC7A83299397F8009A8256 /* SF-Pro-Text-Regular.otf in Resources */,
 				9FD0FA2E29CD3ED400F2AB0D /* KMRightSideEmptyVC.xib in Resources */,
 				9F94748129FA24200042F949 /* Credits.rtf in Resources */,
+				AD1D480D2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.xib in Resources */,
 				AD85D1A92AF09864000F4D28 /* KMHomeQuickToolsWindowController.xib in Resources */,
 				BB49ED03293F459500C82CA2 /* KMConvertPPTsWindowController.xib in Resources */,
 				BB89723F294B3C840045787C /* KMWatermarkPropertyController.xib in Resources */,
@@ -10213,6 +10230,7 @@
 				899700ED28F3E4D3009AF911 /* MainWindowController.xib in Resources */,
 				BB65A0422AF8863F003A27A0 /* GeneralPreferences.xib in Resources */,
 				89E4E70D2963D62C002DBA6F /* KMAnnotationFontWindowController.xib in Resources */,
+				AD1D48152AFB1912007AC1F0 /* KMCompressView.xib in Resources */,
 				AD88109C29A78AEC00178CA1 /* KMVerificationCodeView.xib in Resources */,
 				89E4E7872967BF5A002DBA6F /* KMCustomizeStampViewController.xib in Resources */,
 				BB4EEF3229763EE7003A3537 /* KMRedactBaseWindowController.xib in Resources */,
@@ -10440,6 +10458,7 @@
 				9F78EFC628F7E965001E66F4 /* KMHomeViewController+UI.swift in Sources */,
 				BB8F4582295B0F900037EA22 /* KMHeaderFooterMarginInfoView.swift in Sources */,
 				9FDD0FAA29534FCC000C4DAD /* KMAliasLight.swift in Sources */,
+				AD1D48082AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift in Sources */,
 				BB147029299DC0D100784A6A /* OIDAuthorizationService.m in Sources */,
 				9FF94F1129A7476000B1EF69 /* KMDesignPropertySelector.swift in Sources */,
 				ADBC2D0C299CAA65006280C8 /* KMBaseXibView.swift in Sources */,
@@ -10782,6 +10801,7 @@
 				9FD0D2A72AD4EFB000DA3FF8 /* KMSavePanelAccessoryController.swift in Sources */,
 				BB2C6AC928F4085200478A33 /* CPDFListView.m in Sources */,
 				BBF245582AE78D0300037D08 /* KMBatchOperateWindowController.swift in Sources */,
+				AD1D480F2AFB1907007AC1F0 /* KMCompressView.swift in Sources */,
 				BBFBE6C028DD7B97008B2335 /* ViewController.swift in Sources */,
 				BB4EEF3429764166003A3537 /* KMRedactPropertyWindowController.swift in Sources */,
 				BB6013842AD3A0DE00A76FB2 /* CPDFTextWidgetAnnotation+PDFListView.swift in Sources */,
@@ -11466,6 +11486,7 @@
 				AD3A3588294C11ED00D72802 /* KMPrintPreviewPresenter.swift in Sources */,
 				BB49ED1A293F4D4E00C82CA2 /* KMConvertCSVSettingView.swift in Sources */,
 				9FCFEC7D2AC579F600EAD2CB /* CPDFListSignatureAnnotation.swift in Sources */,
+				AD1D48092AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift in Sources */,
 				ADE3C1C229A4C13700793B13 /* KMPrintAccessoryController_OC.m in Sources */,
 				89752E1A2941FD48003FF08E /* KMSearchCellView.swift in Sources */,
 				9F0CB50A2986563300007028 /* KMDesignToken+BorderBottom.swift in Sources */,
@@ -11962,6 +11983,7 @@
 				BB90E4EF2AF3546500B04B9F /* NSUserDefaultsController+KMExtension.swift in Sources */,
 				ADDEEA7F2AD3FB1D00EF675D /* KMImageAccessoryController.swift in Sources */,
 				BB4EEF4129764FCC003A3537 /* KMWatermarkColorView.swift in Sources */,
+				AD1D48102AFB1907007AC1F0 /* KMCompressView.swift in Sources */,
 				BB146FCA299DC0D100784A6A /* GTMSessionFetcher.m in Sources */,
 				BBC70EB52AEA847500AC1585 /* KMToolbarCustomViewController.swift in Sources */,
 				BB49ECDE293EED6100C82CA2 /* KMConvertWordWindowController.swift in Sources */,
@@ -12080,6 +12102,7 @@
 				9FCFECA62AD237B500EAD2CB /* KMBatchTableRowView.swift in Sources */,
 				BB93CDEB2AE7B6E100B29C57 /* KMToolbarView.swift in Sources */,
 				BB1EC8002967B26700EC0BC3 /* KMPDFEditViewController.swift in Sources */,
+				AD1D480A2AFB18DA007AC1F0 /* KMCompressWIndowControllerNew.swift in Sources */,
 				ADAFDA402AE8F32400F084BC /* KMAdvertisementManager.swift in Sources */,
 				ADAFDA152AE8DD6600F084BC /* KMAdvertisementCollectionViewItem.swift in Sources */,
 				AD015FB929AB484400A57062 /* KMLightMemberConfig.swift in Sources */,
@@ -12289,6 +12312,7 @@
 				BB49ED10293F462E00C82CA2 /* KMConvertImageWindowController.swift in Sources */,
 				BBF38A60294F42FF0086D025 /* KMWatermarkAdjectiveStepper.swift in Sources */,
 				BB2F184C2A0C911B0003F65E /* KMBaseWindowController.swift in Sources */,
+				AD1D48112AFB1907007AC1F0 /* KMCompressView.swift in Sources */,
 				BBA93D2F29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */,
 				89E4E76329656A88002DBA6F /* KMAnnotationStampViewController.m in Sources */,
 				BB89726B294DB41D0045787C /* KMWatermarkAdjectivePositionView.swift in Sources */,

File diff suppressed because it is too large
+ 586 - 831
PDF Office/PDF Master.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist


+ 38 - 8
PDF Office/PDF Master/Class/Batch/View/KMSlider.swift

@@ -34,6 +34,7 @@ class KMSlider: NSSlider, NSPopoverDelegate{
         super.init(coder: coder)
         self.initView()
     }
+    
     func initView() {
         self.isContinuous = true
         self.tipEnabled = true
@@ -57,11 +58,26 @@ class KMSlider: NSSlider, NSPopoverDelegate{
         self.tipPopover?.contentViewController?.view = contentView
         self.tipPopover?.delegate = self
     }
+    
     override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
         if object as? NSObject == self.tipPopover && keyPath == SJTSliderPositioningRectkey {
             self.adjustTipAlignment()
         }
     }
+    
+    override func sendAction(_ action: Selector?, to target: Any?) -> Bool {
+        if tipEnabled {
+            showTipPopover(animated: false)
+        }
+        
+        let event = NSApplication.shared.currentEvent
+        if event?.type == NSEvent.EventType.leftMouseUp {
+            delegate?.valueDidSelect(inSlider: self)
+        }
+        
+        return super.sendAction(action, to: target)
+    }
+    
     func adjustTipAlignment() {
         guard let tipContentView = self.tipPopover?.contentViewController?.view else {
             return
@@ -87,11 +103,7 @@ class KMSlider: NSSlider, NSPopoverDelegate{
         }
         tipView.alignment = tipAlignment
     }
-    override func mouseEntered(with theEvent: NSEvent) {
-        if self.tipEnabled {
-            self.showTipPopover(animated: true)
-        }
-    }
+    
     func showTipPopover(animated: Bool) {
         let tip = self.tipForValue(self.doubleValue)
         if !tip.isEmpty {
@@ -163,15 +175,14 @@ class KMSlider: NSSlider, NSPopoverDelegate{
             }
         }
     }
-    override func mouseExited(with theEvent: NSEvent) {
-        self.closeTipPopover(animated: true)
-    }
+    
     func tipForValue(_ value: Double) -> String {
         if let tip = self.delegate?.tipForValue(inSlider: self, value: self.doubleValue) {
            return tip
         }
         return String(format: "%0.f", self.doubleValue)
     }
+    
     func closeTipPopover(animated: Bool) {
         if ((self.tipPopover?.isShown) != nil) {
             self.tipPopover?.animates = animated 
@@ -180,4 +191,23 @@ class KMSlider: NSSlider, NSPopoverDelegate{
     }
 }
 
+extension KMSlider {
+    override func mouseDown(with event: NSEvent) {
+        if self.tipEnabled {
+            self.showTipPopover(animated: true)
+        }
+        super.mouseDown(with: event)
+    }
+    
+    override func mouseEntered(with theEvent: NSEvent) {
+        if self.tipEnabled {
+            self.showTipPopover(animated: true)
+        }
+    }
+    
+    override func mouseExited(with theEvent: NSEvent) {
+        self.closeTipPopover(animated: true)
+    }
+}
+
 

+ 26 - 0
PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift

@@ -24,3 +24,29 @@ class KMBaseWindowController: NSWindowController {
     func initSubViews() {}
     func initDefaultValue() {}
 }
+
+extension KMBaseWindowController {
+    static func checkPassword(url: URL, password: String = "", completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
+        let document = CPDFDocument.init(url: url)
+        if document!.isLocked {
+            if let unlockSuccess = document?.unlock(withPassword: password) {
+                completion(true, password)
+            } else {
+                DispatchQueue.main.async {
+                    let passwordWindowController = PasswordWindowController(windowNibName: "PasswordWindowController")
+                    passwordWindowController.fileURL = url
+                    passwordWindowController.beginSheetModalForWindow(NSWindow.currentWindow()) { passwordString in
+                        if passwordString.count != 0 {
+                            document?.unlock(withPassword: passwordString)
+                            completion(true, passwordString)
+                        } else {
+                            completion(false, "")
+                        }
+                    }
+                }
+            }
+        } else {
+            completion(true, "")
+        }
+    }
+}

+ 148 - 0
PDF Office/PDF Master/Class/PDFTools/Compress/Controller/KMCompressWIndowControllerNew.swift

@@ -0,0 +1,148 @@
+//
+//  KMCompressWIndowControllerNew.swift
+//  PDF Master
+//
+//  Created by lizhe on 2023/11/8.
+//
+
+import Cocoa
+
+typealias KMCompressWIndowControllerNewBatchAction = (_ view: KMCompressWIndowControllerNew, _ filePaths: [URL]) -> Void
+typealias KMCompressWIndowControllerNewItemClick = () -> Void
+typealias KMCompressWIndowControllerNewResultCallback = (_ result: Bool,_ openDocuemt: Bool, _ fileURL: URL, _ error: String)->()
+
+class KMCompressWIndowControllerNew: KMBaseWindowController {
+    @IBOutlet weak var compressView: KMCompressView!
+    
+    var resultCallback: KMCompressWIndowControllerNewResultCallback!
+    var itemClick: KMCompressWIndowControllerNewItemClick?
+    var batchAction: KMCompressWIndowControllerNewBatchAction?
+    
+    var documentURL: URL! {
+        didSet{
+            KMBaseWindowController.checkPassword(url: documentURL) { [unowned self] success, paasswordString in
+                if success {
+                    self.password = paasswordString
+                    self.compressView.documentURL = self.documentURL
+                } else {
+                    guard let callBack = self.itemClick else { return }
+                    
+                    callBack()
+                }
+            }
+        }
+    }
+    
+    var password: String!
+    private var datas: [String] = []
+    
+    var limit = true
+    var oriDocumentUrl: URL?
+    
+    override func windowDidLoad() {
+        super.windowDidLoad()
+
+        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+        
+        self.compressView.cancelAction = { [unowned self] view in
+//            self.closeWindow()
+            
+            guard let callBack = itemClick else { return }
+            
+            callBack()
+        }
+        
+        self.compressView.batchAction = { [unowned self] view in
+            print("Batch 按钮点击")
+            guard let callBack = batchAction else { return }
+            
+            callBack(self, [documentURL])
+        }
+        
+        self.compressView.compressAction = { [unowned self] view, value in
+            self.compressButtonAction(value: value)
+        }
+    }
+    
+    private func compressButtonAction(value: Int, limit: Bool = false) {
+        DispatchQueue.main.async {
+            NSPanel.savePanel(self.window!, true) { panel in
+                var url: URL = self.documentURL
+                if (self.oriDocumentUrl != nil) {
+                    url = self.oriDocumentUrl!
+                }
+                panel.nameFieldStringValue = ""+url.deletingPathExtension().lastPathComponent+"_Compressed"
+                panel.allowedFileTypes = ["pdf"]
+            } completion: { response, url, isOpen in
+                if (response == .cancel) {
+                    return
+                }
+                
+                self.beginLoading()
+                DispatchQueue.global().async {
+                    let docuemt = CPDFDocument.init(url: self.documentURL)
+                    if (docuemt?.isLocked)! && self.password != nil {
+                        docuemt?.unlock(withPassword: self.password)
+                    }
+                    
+                    let option = value
+                    
+                    var result = false
+                    if (limit) {
+                        if let _document = docuemt, let _ = KMTools.saveWatermarkDocumentForCompress(document: _document, to: url!, imageQuality: option) {
+                            result = true
+                        }
+                    } else {
+                        if let data = docuemt?.writeOptimize(to: url, withOptions: [.imageQualityOption : option]) {
+                            result = data
+                        }
+                    }
+                    
+                    if (result) {
+                        self._clearData()
+                    }
+                    
+                    DispatchQueue.main.async {
+                        self.endLoading()
+                        guard let callback = self.resultCallback else {
+                            if (result) {
+                                if isOpen { /// 开启文档
+                                    NSDocumentController.shared.km_safe_openDocument(withContentsOf: url!, display: true) { _, _, _ in
+                                        
+                                    }
+                                } else {
+                                    NSWorkspace.shared.activateFileViewerSelecting([url!])
+                                }
+                            }
+                            return
+                        }
+                        
+                        callback(result, isOpen, url!, "")
+                    }
+                }
+            }
+        }
+    }
+    
+    private func _clearData() {
+        if let _ = self.oriDocumentUrl {
+            if let data = self.documentURL?.path, FileManager.default.fileExists(atPath: data) {
+                try?FileManager.default.removeItem(atPath: data)
+            }
+        }
+    }
+    
+    func closeWindow() {
+        self.close()
+    }
+}
+
+extension KMCompressWIndowControllerNew: KMLoadingProtocol {
+    func beginLoading() {
+        self.window?.contentView?.beginLoading()
+    }
+    
+    func endLoading() {
+        self.window?.contentView?.endLoading()
+    }
+}

+ 43 - 0
PDF Office/PDF Master/Class/PDFTools/Compress/Controller/KMCompressWIndowControllerNew.xib

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="KMCompressWIndowControllerNew" customModule="PDF_Master" customModuleProvider="target">
+            <connections>
+                <outlet property="compressView" destination="Xp8-iA-nRn" id="D8b-U4-B52"/>
+                <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
+            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+            <rect key="contentRect" x="196" y="240" width="616" height="474"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
+            <view key="contentView" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="616" height="474"/>
+                <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="Xp8-iA-nRn" customClass="KMCompressView" customModule="PDF_Master" customModuleProvider="target">
+                        <rect key="frame" x="0.0" y="0.0" width="616" height="474"/>
+                    </customView>
+                </subviews>
+                <constraints>
+                    <constraint firstItem="Xp8-iA-nRn" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="0qv-8p-phA"/>
+                    <constraint firstAttribute="trailing" secondItem="Xp8-iA-nRn" secondAttribute="trailing" id="1XX-YE-xYu"/>
+                    <constraint firstAttribute="bottom" secondItem="Xp8-iA-nRn" secondAttribute="bottom" id="LWK-sk-cs4"/>
+                    <constraint firstItem="Xp8-iA-nRn" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" id="MU6-NA-czK"/>
+                </constraints>
+            </view>
+            <connections>
+                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
+            </connections>
+            <point key="canvasLocation" x="113" y="238"/>
+        </window>
+    </objects>
+</document>

+ 8 - 8
PDF Office/PDF Master/Class/PDFTools/Compress/Controller/KMCompressWindowController.xib

@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMCompressWindowController" customModule="PDF_Office" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMCompressWindowController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="batchButton" destination="AoG-8q-Bt0" id="pax-kh-bg6"/>
                 <outlet property="cancelBox" destination="cc4-qh-Kgl" id="J5p-tk-MHT"/>
@@ -38,7 +38,7 @@
                             <rect key="frame" x="0.0" y="0.0" width="468" height="50"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qeh-qt-IP2">
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qeh-qt-IP2">
                                     <rect key="frame" x="14" y="17" width="37" height="16"/>
                                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="7Wa-Kg-wnl">
                                         <font key="font" usesAppearanceFont="YES"/>
@@ -132,14 +132,14 @@
                             <subviews>
                                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AoG-8q-Bt0">
                                     <rect key="frame" x="9" y="9" width="94" height="44"/>
-                                    <constraints>
-                                        <constraint firstAttribute="width" constant="80" id="ki7-hn-3sx"/>
-                                        <constraint firstAttribute="height" constant="32" id="zhL-I2-gkZ"/>
-                                    </constraints>
                                     <buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="im4-Oq-Yt3">
                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                         <font key="font" metaFont="system"/>
                                     </buttonCell>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="80" id="ki7-hn-3sx"/>
+                                        <constraint firstAttribute="height" constant="32" id="zhL-I2-gkZ"/>
+                                    </constraints>
                                 </button>
                                 <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="YIe-Q5-WRH">
                                     <rect key="frame" x="372" y="16" width="80" height="32"/>

+ 166 - 0
PDF Office/PDF Master/Class/PDFTools/Compress/View/KMCompressView.swift

@@ -0,0 +1,166 @@
+//
+//  KMCompressView.swift
+//  PDF Master
+//
+//  Created by lizhe on 2023/11/8.
+//
+
+import Cocoa
+
+typealias KMCompressViewCancelAction = (_ view: KMCompressView ) -> Void
+typealias KMCompressViewBatchAction = (_ view: KMCompressView ) -> Void
+typealias KMCompressViewCompressAction = (_ view: KMCompressView, _ compressValue: Int) -> Void
+
+class KMCompressView: KMBaseXibView {
+
+    @IBOutlet weak var previewBox: KMBox!
+    @IBOutlet weak var titleLabel: NSTextField!
+    @IBOutlet weak var sizeLabel: NSTextField!
+    @IBOutlet weak var finalSizeLabel: NSTextField!
+    @IBOutlet weak var fileImageView: NSImageView!
+    @IBOutlet weak var progressSizeLabel: NSTextField!
+    @IBOutlet weak var progress: NSProgressIndicator!
+    
+    @IBOutlet weak var selectLabel: NSTextField!
+    @IBOutlet weak var qulityMatrix: NSMatrix!
+    
+    @IBOutlet weak var lowLabel: NSTextField!
+    @IBOutlet weak var hightLabel: NSTextField!
+    @IBOutlet weak var qualitySlider: KMSlider!
+    
+    @IBOutlet weak var cancelButton: NSButton!
+    @IBOutlet weak var compressButton: NSButton!
+    @IBOutlet weak var batchButton: NSButton!
+    
+    var cancelAction: KMCompressViewCancelAction?
+    var batchAction: KMCompressViewBatchAction?
+    var compressAction: KMCompressViewCompressAction?
+    
+    var documentURL: URL? {
+        didSet {
+            self.reloadData()
+        }
+    }
+//    var password: String!
+//    private var datas: [String] = []
+//    var selectIndex = 2
+//    
+//    var limit = true
+    var oriDocumentUrl: URL?
+    
+    override func draw(_ dirtyRect: NSRect) {
+        super.draw(dirtyRect)
+
+        // Drawing code here.
+    }
+
+    override func setup() {
+        qulityMatrix.selectCell(atRow: 2, column: 0)
+        
+        lowLabel.textColor = KMAppearance.Layout.h0Color()
+        hightLabel.textColor = KMAppearance.Layout.h0Color()
+        
+        previewBox.fillColor = NSColor.black.withAlphaComponent(0.04)
+        previewBox.cornerRadius = 4.0
+        
+        progress.doubleValue = 0;
+        progress.isHidden = true
+        progressSizeLabel.isHidden = true
+    }
+    
+    override func updateLanguage() {
+        selectLabel.stringValue = NSLocalizedString("Optimization Options", comment: "")
+        lowLabel.stringValue = NSLocalizedString("Low Quality", comment: "")
+        hightLabel.stringValue = NSLocalizedString("High Quality", comment: "")
+        cancelButton.title = NSLocalizedString("Cancel", comment: "")
+        compressButton.title = NSLocalizedString("Compress", comment: "")
+        batchButton.title = NSLocalizedString("Batch", comment: "")
+        
+        for cell in qulityMatrix.cells {
+            cell.title = NSLocalizedString(cell.title, comment: "")
+        }
+    }
+    
+    override func reloadData() {
+        let url = documentURL ?? URL(string: "")
+        if url != nil {
+            let filePath = url!.path
+            let attrib = try? FileManager.default.attributesOfItem(atPath: filePath)
+            if attrib != nil {
+                let sizeFloat: Float = attrib![FileAttributeKey(rawValue: "NSFileSize")] as? Float ?? 0.0
+                sizeLabel.stringValue = self.fileSizeString(sizeFloat)
+                
+                titleLabel.stringValue = filePath.lastPathComponent
+                finalSizeLabel.isHidden = true
+                
+                let image: NSImage = NSImage.previewForFile(path: url!, ofSize: fileImageView.bounds.size, asIcon: true) ?? NSImage()
+                fileImageView.image = image;
+            }
+        }
+    
+        self.updateQulityMatrixState()
+    }
+    
+    func updateQulityMatrixState() {
+        if qulityMatrix.selectedRow == 4 {
+            hightLabel.isEnabled = true
+            lowLabel.isEnabled = true
+            qualitySlider.isEnabled = true
+            lowLabel.alphaValue = 1
+            hightLabel.alphaValue = 1
+            qualitySlider.tipEnabled = true
+        } else {
+            hightLabel.isEnabled = false
+            lowLabel.isEnabled = false
+            qualitySlider.isEnabled = false
+            lowLabel.alphaValue = 0.4
+            hightLabel.alphaValue = 0.4
+            qualitySlider.tipEnabled = false
+        }
+    }
+    
+    func fileSizeString(_ fSize: Float) -> String {
+        let fileSize = fSize / 1024
+        let size = fileSize >= 1024 ? (fileSize < 1048576 ? fileSize/1024 : fileSize/1048576.0) : fileSize
+        let unit = fileSize >= 1024 ? (fileSize < 1048576 ? "M" : "G") : "K"
+        return String(format: "%0.1f %@", size, unit)
+    }
+}
+
+//MARK: Action
+extension KMCompressView {
+    @IBAction func batchButtonAction(_ sender: Any) {
+        guard let callBack = batchAction else { return }
+        
+        callBack(self)
+    }
+    
+    @IBAction func cancelButtonAction(_ sender: Any) {
+        guard let callBack = cancelAction else { return }
+        
+        callBack(self)
+    }
+    
+    @IBAction func compressButtonAction(_ sender: Any) {
+        guard let callBack = compressAction else { return }
+        
+        var compressVale = 60
+        if (qulityMatrix.selectedRow == 0) {
+            compressVale = 120
+        } else if (qulityMatrix.selectedRow == 1) {
+            compressVale = 90
+        } else if (qulityMatrix.selectedRow == 2) {
+            compressVale = 60
+        } else if (qulityMatrix.selectedRow == 3) {
+            compressVale = 30
+        } else {
+            compressVale = qualitySlider.integerValue
+        }
+        
+        callBack(self, compressVale)
+    }
+    
+    @IBAction func qulityMatrixAction(_ sender: Any) {
+        self.updateQulityMatrixState()
+    }
+}

+ 248 - 0
PDF Office/PDF Master/Class/PDFTools/Compress/View/KMCompressView.xib

@@ -0,0 +1,248 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="KMCompressView" customModule="PDF_Master" customModuleProvider="target">
+            <connections>
+                <outlet property="batchButton" destination="oK4-qZ-nsZ" id="qs0-gu-74l"/>
+                <outlet property="cancelButton" destination="M8m-46-Uhb" id="K0C-2I-WOj"/>
+                <outlet property="compressButton" destination="IHF-en-Dqi" id="PwN-g7-RFb"/>
+                <outlet property="fileImageView" destination="got-mA-Esq" id="Zls-7k-XND"/>
+                <outlet property="finalSizeLabel" destination="AVp-B0-LcQ" id="syN-mv-nSW"/>
+                <outlet property="hightLabel" destination="QQd-Ip-P83" id="dPU-qd-naS"/>
+                <outlet property="lowLabel" destination="vym-ui-oBO" id="Dqb-89-6Ky"/>
+                <outlet property="previewBox" destination="JoQ-Bg-A7A" id="IFH-92-kmH"/>
+                <outlet property="progress" destination="rI6-3z-z33" id="EnV-KA-efW"/>
+                <outlet property="progressSizeLabel" destination="qSB-Az-aee" id="nUn-C4-CiF"/>
+                <outlet property="qualitySlider" destination="eL4-zP-lte" id="wPt-6Y-4YT"/>
+                <outlet property="qulityMatrix" destination="pD4-qc-WIt" id="CAg-ZN-HuB"/>
+                <outlet property="selectLabel" destination="7pF-2n-frE" id="C6e-zX-bqL"/>
+                <outlet property="sizeLabel" destination="JF7-f4-ihM" id="03Y-DG-toK"/>
+                <outlet property="titleLabel" destination="feZ-ij-cjM" id="4xr-Ws-a8c"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <customView id="c22-O7-iKe">
+            <rect key="frame" x="0.0" y="0.0" width="531" height="424"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <subviews>
+                <view translatesAutoresizingMaskIntoConstraints="NO" id="7D3-FA-RtT">
+                    <rect key="frame" x="0.0" y="0.0" width="531" height="424"/>
+                    <subviews>
+                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="M8m-46-Uhb">
+                            <rect key="frame" x="332" y="11" width="76" height="32"/>
+                            <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="jGJ-6V-t57">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                                <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+                            </buttonCell>
+                            <connections>
+                                <action selector="cancelButtonAction:" target="-2" id="gNl-ks-fY8"/>
+                            </connections>
+                        </button>
+                        <button horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IHF-en-Dqi">
+                            <rect key="frame" x="409" y="11" width="96" height="32"/>
+                            <buttonCell key="cell" type="push" title="Compress" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ZKC-Ne-tUY">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                                <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+                            </buttonCell>
+                            <connections>
+                                <action selector="compressButtonAction:" target="-2" id="5LC-ea-MLd"/>
+                            </connections>
+                        </button>
+                        <matrix verticalHuggingPriority="750" allowsEmptySelection="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pD4-qc-WIt">
+                            <rect key="frame" x="61" y="90" width="357" height="123"/>
+                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                            <size key="cellSize" width="357" height="23"/>
+                            <size key="intercellSpacing" width="4" height="2"/>
+                            <buttonCell key="prototype" type="bevel" title="Radio" imagePosition="left" alignment="left" inset="2" id="ZoF-so-Qrp">
+                                <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <cells>
+                                <column>
+                                    <buttonCell type="radio" title="Large File Size(High Quality)" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" tag="1" inset="2" id="a8s-8G-jq2">
+                                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                    <buttonCell type="radio" title="Medium File Size(Medium Quality)" imagePosition="left" alignment="left" inset="2" id="Tdw-Os-Nhn">
+                                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                    <buttonCell type="radio" title="Small File Size(Recommended Quality)" imagePosition="left" alignment="left" inset="2" id="c7y-5G-qtA">
+                                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                    <buttonCell type="radio" title="Minimum File Size(Low Quality)" imagePosition="left" alignment="left" inset="2" id="LRe-1E-d0e">
+                                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                    <buttonCell type="radio" title="Other" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="IHz-jB-tSr">
+                                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                                        <font key="font" metaFont="system"/>
+                                    </buttonCell>
+                                </column>
+                            </cells>
+                            <connections>
+                                <action selector="qulityMatrixAction:" target="-2" id="tA2-1h-dxN"/>
+                            </connections>
+                        </matrix>
+                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7pF-2n-frE">
+                            <rect key="frame" x="59" y="223" width="154" height="16"/>
+                            <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Select Compress Format" id="unA-fp-iyW">
+                                <font key="font" metaFont="system"/>
+                                <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oK4-qZ-nsZ">
+                            <rect key="frame" x="8" y="11" width="69" height="32"/>
+                            <buttonCell key="cell" type="push" title="Batch" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="d4I-h4-20k">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="system"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="batchButtonAction:" target="-2" id="WsW-uG-03w"/>
+                            </connections>
+                        </button>
+                        <box autoresizesSubviews="NO" borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="JoQ-Bg-A7A" customClass="KMBox" customModule="PDF_Master" customModuleProvider="target">
+                            <rect key="frame" x="37" y="260" width="457" height="146"/>
+                            <view key="contentView" id="qgD-bf-gnS">
+                                <rect key="frame" x="4" y="5" width="449" height="138"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                <subviews>
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JF7-f4-ihM">
+                                        <rect key="frame" x="128" y="81" width="4" height="16"/>
+                                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" id="whk-Hu-7q8">
+                                            <font key="font" metaFont="system"/>
+                                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                        </textFieldCell>
+                                    </textField>
+                                    <progressIndicator wantsLayer="YES" maxValue="100" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="rI6-3z-z33">
+                                        <rect key="frame" x="130" y="47" width="240" height="20"/>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="240" id="r9M-rs-3WM"/>
+                                        </constraints>
+                                    </progressIndicator>
+                                    <textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="feZ-ij-cjM">
+                                        <rect key="frame" x="128" y="102" width="303" height="16"/>
+                                        <textFieldCell key="cell" truncatesLastVisibleLine="YES" sendsActionOnEndEditing="YES" id="He2-H0-3Up">
+                                            <font key="font" metaFont="system"/>
+                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                        </textFieldCell>
+                                    </textField>
+                                    <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="got-mA-Esq">
+                                        <rect key="frame" x="10" y="14" width="110" height="110"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="110" id="Guy-Ta-rMV"/>
+                                            <constraint firstAttribute="width" constant="110" id="TbS-1n-M8o"/>
+                                        </constraints>
+                                        <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="Uy4-7y-Qeb"/>
+                                    </imageView>
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AVp-B0-LcQ">
+                                        <rect key="frame" x="143" y="81" width="4" height="16"/>
+                                        <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" id="XEA-VF-Y0d">
+                                            <font key="font" metaFont="system"/>
+                                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                                        </textFieldCell>
+                                    </textField>
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qSB-Az-aee">
+                                        <rect key="frame" x="383" y="49" width="4" height="16"/>
+                                        <textFieldCell key="cell" lineBreakMode="clipping" id="jbV-Qh-AnI">
+                                            <font key="font" metaFont="system"/>
+                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                        </textFieldCell>
+                                    </textField>
+                                </subviews>
+                                <constraints>
+                                    <constraint firstItem="JF7-f4-ihM" firstAttribute="top" secondItem="feZ-ij-cjM" secondAttribute="bottom" constant="5" id="0Te-Rh-Zal"/>
+                                    <constraint firstItem="rI6-3z-z33" firstAttribute="leading" secondItem="JF7-f4-ihM" secondAttribute="leading" id="0fG-ad-ixq"/>
+                                    <constraint firstItem="got-mA-Esq" firstAttribute="leading" secondItem="qgD-bf-gnS" secondAttribute="leading" constant="10" id="8el-Fe-esX"/>
+                                    <constraint firstItem="feZ-ij-cjM" firstAttribute="top" secondItem="qgD-bf-gnS" secondAttribute="top" constant="20" id="Iog-kr-jgF"/>
+                                    <constraint firstItem="qSB-Az-aee" firstAttribute="centerY" secondItem="rI6-3z-z33" secondAttribute="centerY" id="L6b-vM-oZp"/>
+                                    <constraint firstItem="JF7-f4-ihM" firstAttribute="leading" secondItem="feZ-ij-cjM" secondAttribute="leading" id="RT3-Xi-ANr"/>
+                                    <constraint firstItem="feZ-ij-cjM" firstAttribute="leading" secondItem="got-mA-Esq" secondAttribute="trailing" constant="10" id="ToQ-y4-mKG"/>
+                                    <constraint firstItem="qSB-Az-aee" firstAttribute="leading" secondItem="rI6-3z-z33" secondAttribute="trailing" constant="15" id="YGm-Im-bDy"/>
+                                    <constraint firstItem="rI6-3z-z33" firstAttribute="top" secondItem="JF7-f4-ihM" secondAttribute="bottom" constant="15" id="Ysp-bX-Tau"/>
+                                    <constraint firstItem="AVp-B0-LcQ" firstAttribute="centerY" secondItem="JF7-f4-ihM" secondAttribute="centerY" id="cHu-mi-1qN"/>
+                                    <constraint firstAttribute="trailing" secondItem="feZ-ij-cjM" secondAttribute="trailing" constant="20" id="fGv-MR-AoV"/>
+                                    <constraint firstItem="AVp-B0-LcQ" firstAttribute="leading" secondItem="JF7-f4-ihM" secondAttribute="trailing" constant="15" id="gDW-WJ-ROl"/>
+                                    <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="qSB-Az-aee" secondAttribute="trailing" constant="10" id="gX9-xj-gEb"/>
+                                    <constraint firstItem="got-mA-Esq" firstAttribute="centerY" secondItem="qgD-bf-gnS" secondAttribute="centerY" id="nkG-Zb-rLY"/>
+                                </constraints>
+                            </view>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="140" id="HWO-1j-I4e"/>
+                            </constraints>
+                        </box>
+                        <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eL4-zP-lte" customClass="KMSlider" customModule="PDF_Master" customModuleProvider="target">
+                            <rect key="frame" x="127" y="56" width="204" height="28"/>
+                            <constraints>
+                                <constraint firstAttribute="width" constant="200" id="PSU-qN-bMS"/>
+                            </constraints>
+                            <sliderCell key="cell" state="on" alignment="left" minValue="1" maxValue="120" doubleValue="60" tickMarkPosition="above" sliderType="linear" id="mi1-5s-sLY"/>
+                        </slider>
+                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vym-ui-oBO">
+                            <rect key="frame" x="84" y="64" width="37" height="16"/>
+                            <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="i3j-GV-aUO">
+                                <font key="font" metaFont="system"/>
+                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QQd-Ip-P83">
+                            <rect key="frame" x="337" y="64" width="37" height="16"/>
+                            <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="XHK-Rr-DPO">
+                                <font key="font" metaFont="system"/>
+                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                    </subviews>
+                    <constraints>
+                        <constraint firstAttribute="trailing" secondItem="JoQ-Bg-A7A" secondAttribute="trailing" constant="40" id="0BD-V6-QH5"/>
+                        <constraint firstItem="vym-ui-oBO" firstAttribute="leading" secondItem="7D3-FA-RtT" secondAttribute="leading" constant="86" id="0dc-Pw-Dha"/>
+                        <constraint firstItem="7pF-2n-frE" firstAttribute="top" secondItem="JoQ-Bg-A7A" secondAttribute="bottom" constant="25" id="Aab-bv-j0P"/>
+                        <constraint firstItem="M8m-46-Uhb" firstAttribute="centerY" secondItem="oK4-qZ-nsZ" secondAttribute="centerY" id="BNo-z7-3aF"/>
+                        <constraint firstItem="oK4-qZ-nsZ" firstAttribute="leading" secondItem="7D3-FA-RtT" secondAttribute="leading" constant="15" id="Cpb-jC-cBb"/>
+                        <constraint firstItem="pD4-qc-WIt" firstAttribute="leading" secondItem="7pF-2n-frE" secondAttribute="leading" id="Dkp-ae-eMC"/>
+                        <constraint firstItem="QQd-Ip-P83" firstAttribute="centerY" secondItem="eL4-zP-lte" secondAttribute="centerY" id="GVR-gW-8qX"/>
+                        <constraint firstItem="IHF-en-Dqi" firstAttribute="centerY" secondItem="oK4-qZ-nsZ" secondAttribute="centerY" id="Hd6-wV-p14"/>
+                        <constraint firstItem="QQd-Ip-P83" firstAttribute="leading" secondItem="eL4-zP-lte" secondAttribute="trailing" constant="10" id="Liz-u2-Dsv"/>
+                        <constraint firstAttribute="trailing" secondItem="IHF-en-Dqi" secondAttribute="trailing" constant="33" id="PnY-ds-mE9"/>
+                        <constraint firstItem="eL4-zP-lte" firstAttribute="leading" secondItem="vym-ui-oBO" secondAttribute="trailing" constant="10" id="Q5a-kG-TbE"/>
+                        <constraint firstAttribute="bottom" secondItem="oK4-qZ-nsZ" secondAttribute="bottom" constant="18" id="S50-eb-Jw5"/>
+                        <constraint firstItem="JoQ-Bg-A7A" firstAttribute="leading" secondItem="7D3-FA-RtT" secondAttribute="leading" constant="40" id="SIf-DG-vtq"/>
+                        <constraint firstItem="eL4-zP-lte" firstAttribute="centerY" secondItem="vym-ui-oBO" secondAttribute="centerY" id="c1J-bd-Hr2"/>
+                        <constraint firstItem="JoQ-Bg-A7A" firstAttribute="top" secondItem="7D3-FA-RtT" secondAttribute="top" constant="20" id="cN3-Xc-cuz"/>
+                        <constraint firstItem="7pF-2n-frE" firstAttribute="leading" secondItem="qgD-bf-gnS" secondAttribute="leading" constant="20" id="hrr-AP-NWs"/>
+                        <constraint firstItem="vym-ui-oBO" firstAttribute="top" secondItem="pD4-qc-WIt" secondAttribute="bottom" constant="10" id="iMw-Ts-ws1"/>
+                        <constraint firstItem="pD4-qc-WIt" firstAttribute="top" secondItem="7pF-2n-frE" secondAttribute="bottom" constant="10" id="nj6-Bo-0W9"/>
+                        <constraint firstItem="IHF-en-Dqi" firstAttribute="leading" secondItem="M8m-46-Uhb" secondAttribute="trailing" constant="15" id="qhx-jh-Biu"/>
+                    </constraints>
+                </view>
+            </subviews>
+            <constraints>
+                <constraint firstItem="7D3-FA-RtT" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="FfU-B7-Lu5"/>
+                <constraint firstItem="7D3-FA-RtT" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="Mw2-f6-U8P"/>
+                <constraint firstAttribute="trailing" secondItem="7D3-FA-RtT" secondAttribute="trailing" id="QvG-p4-qhW"/>
+                <constraint firstAttribute="bottom" secondItem="7D3-FA-RtT" secondAttribute="bottom" id="rPf-Hv-ogo"/>
+            </constraints>
+            <point key="canvasLocation" x="45" y="146"/>
+        </customView>
+    </objects>
+</document>

+ 15 - 2
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -1789,7 +1789,7 @@ extension KMMainViewController {
             KMPrint("压缩窗口已显示")
             return
         }
-        let windowController = KMCompressWindowController(windowNibName: "KMCompressWindowController")
+        let windowController = KMCompressWIndowControllerNew(windowNibName: "KMCompressWIndowControllerNew")
         self.view.window?.beginSheet(windowController.window!)
         self.currentWindowController = windowController
         if let _url = url {
@@ -1800,13 +1800,26 @@ extension KMMainViewController {
         }
         windowController.password = self.listView.document.password
         
-        windowController.itemClick = { [weak self] _ in
+        windowController.itemClick = { [weak self] in
             self?.view.window?.endSheet((self?.currentWindowController.window)!)
             self?.currentWindowController = nil
             
             self?.toolbarController.cancelSelected(KMToolbarToolCompressItemIdentifier)
         }
         
+        windowController.batchAction = { [weak self] view, filePaths in
+            self?.view.window?.endSheet((self?.currentWindowController.window)!)
+            self?.currentWindowController = nil
+            
+            self?.toolbarController.cancelSelected(KMToolbarToolCompressItemIdentifier)
+            
+            let batchWindowController = KMBatchOperateWindowController.sharedWindowController
+                    batchWindowController.window?.makeKeyAndOrderFront("")
+            let batchOperateFile = KMBatchOperateFile(filePath: filePaths.first!.path)
+            batchWindowController.switchToOperateType(KMBatchOperationType.Compress, files: [batchOperateFile])
+            batchWindowController.window?.makeKeyAndOrderFront("")
+        }
+        
         windowController.resultCallback = { [weak self] result, openDocument, fileURL, error in
             if (result) {
                 self?.view.window?.endSheet((self?.currentWindowController.window)!)