Browse Source

【综合】截屏创建PDF优化,引导内存调整

niehaoyu 9 months ago
parent
commit
55f16935d3

+ 5 - 3
PDF Office/PDF Master/Class/ChromiumTabs/Screen/KMScreenShotHandler.swift

@@ -14,6 +14,8 @@ class KMScreenShotHandler: NSObject{
     
     
     static let defaultManager = KMScreenShotHandler()
     static let defaultManager = KMScreenShotHandler()
     
     
+    static var screenShotWindow: KMScreenShotMaskWindowController!
+    
     class func fullScreenShot() -> NSImage {
     class func fullScreenShot() -> NSImage {
         var screenShot = CGWindowListCreateImage(.infinite, .optionOnScreenOnly, kCGNullWindowID, [])
         var screenShot = CGWindowListCreateImage(.infinite, .optionOnScreenOnly, kCGNullWindowID, [])
         let img2 = NSImage(cgImage: screenShot!, size: NSZeroSize)
         let img2 = NSImage(cgImage: screenShot!, size: NSZeroSize)
@@ -105,7 +107,7 @@ class KMScreenShotHandler: NSObject{
         if KMScreenShotHandler.defaultManager.isCapturing == true {
         if KMScreenShotHandler.defaultManager.isCapturing == true {
             NotificationCenter.default.post(name: Notification.Name(KMCancelCurrentCapturingActionNotification), object: nil)
             NotificationCenter.default.post(name: Notification.Name(KMCancelCurrentCapturingActionNotification), object: nil)
         }
         }
-        let screenShotWindow = KMScreenShotMaskWindowController { (ima) in
+        screenShotWindow = KMScreenShotMaskWindowController { (ima) in
             if let image = ima {
             if let image = ima {
                 handler(image)
                 handler(image)
             }
             }
@@ -117,7 +119,7 @@ class KMScreenShotHandler: NSObject{
             NotificationCenter.default.post(name: Notification.Name(KMCancelCurrentCapturingActionNotification), object: nil)
             NotificationCenter.default.post(name: Notification.Name(KMCancelCurrentCapturingActionNotification), object: nil)
         }
         }
         KMScreenShotHandler.defaultManager.isCapturing = true
         KMScreenShotHandler.defaultManager.isCapturing = true
-        let screenShotWindow = KMScreenShotMaskWindowController(fullScreenShot: delayTime, completeHandler: { (ima) in
+        screenShotWindow = KMScreenShotMaskWindowController(fullScreenShot: delayTime, completeHandler: { (ima) in
             KMScreenShotHandler.defaultManager.isCapturing = false
             KMScreenShotHandler.defaultManager.isCapturing = false
             if let image = ima {
             if let image = ima {
                 handler(image)
                 handler(image)
@@ -128,7 +130,7 @@ class KMScreenShotHandler: NSObject{
         if KMScreenShotHandler.defaultManager.isCapturing {
         if KMScreenShotHandler.defaultManager.isCapturing {
             NotificationCenter.default.post(name: Notification.Name(KMCancelCurrentCapturingActionNotification), object: nil)
             NotificationCenter.default.post(name: Notification.Name(KMCancelCurrentCapturingActionNotification), object: nil)
         }
         }
-        let screenShotWindow = KMScreenShotMaskWindowController( handler: { (ima) in
+        screenShotWindow = KMScreenShotMaskWindowController( handler: { (ima) in
             if let image = ima {
             if let image = ima {
                 handler(image)
                 handler(image)
             }
             }

+ 12 - 12
PDF Office/PDF Master/Class/ChromiumTabs/Screen/KMScreenShotMaskViewController.swift

@@ -42,29 +42,29 @@ class KMScreenShotMaskViewController: NSViewController{
     func handlerCallBack() {
     func handlerCallBack() {
         self.screenShotMaskView.callBack = self.callBack
         self.screenShotMaskView.callBack = self.callBack
         
         
-        self.screenShotMaskView.frameCallBack = {[unowned self] rect in
-            if self.editViewController.view.isHidden {
-                self.editViewController.view.isHidden = false
+        self.screenShotMaskView.frameCallBack = {[weak self] rect in
+            if self?.editViewController.view.isHidden == true {
+                self?.editViewController.view.isHidden = false
             }
             }
-            if self.holeDragImageView.isHidden{
-                self.holeDragImageView.isHidden = false
+            if self?.holeDragImageView.isHidden == true {
+                self?.holeDragImageView.isHidden = false
             }
             }
-            self.editViewController.updateSize(withRect: rect)
-            self.updateEditViewFrame(with: rect)
-            self.updateHoleButtonPosition(rect)
+            self?.editViewController.updateSize(withRect: rect)
+            self?.updateEditViewFrame(with: rect)
+            self?.updateHoleButtonPosition(rect)
         }
         }
         
         
         self.editViewController.buttonCallBack = { [weak self] captureOrNot in
         self.editViewController.buttonCallBack = { [weak self] captureOrNot in
-            self!.holeDragImageView.isHidden = true
+            self?.holeDragImageView.isHidden = true
             if captureOrNot {
             if captureOrNot {
-                self!.screenShotMaskView.captureImage()
+                self?.screenShotMaskView.captureImage()
             } else {
             } else {
-                self!.screenShotMaskView.endImageCapture()
+                self?.screenShotMaskView.endImageCapture()
             }
             }
         }
         }
         
         
         self.editViewController.sizeCallBack = { [weak self] size in
         self.editViewController.sizeCallBack = { [weak self] size in
-            self!.screenShotMaskView.updateholeSize(newSize: size)
+            self?.screenShotMaskView.updateholeSize(newSize: size)
             self?.updateHoleButtonPositionWithHoleSize(holeSize: size)
             self?.updateHoleButtonPositionWithHoleSize(holeSize: size)
         }
         }
         
         

+ 2 - 2
PDF Office/PDF Master/Class/DigtalSignature/CPDFDigtalView/KMPDFDigitalSignViewController.swift

@@ -353,14 +353,14 @@ extension KMPDFDigitalSignViewController: CPDFDigtalViewDelegate {
         configWindowVC.viewType = .fileList;
         configWindowVC.viewType = .fileList;
         configWindowVC.appearanceWidget = widget;
         configWindowVC.appearanceWidget = widget;
         configWindowVC.isCreatDS = false
         configWindowVC.isCreatDS = false
-        configWindowVC.complentionHandle = {[unowned self] isSign, dic, config, isLock in
+        configWindowVC.complentionHandle = {[weak self] isSign, dic, config, isLock in
             widget.page.removeAnnotation(widget)
             widget.page.removeAnnotation(widget)
             if isSign {
             if isSign {
                 if (dic.object(forKey: SAVEFILEPATH_KEY) != nil) {
                 if (dic.object(forKey: SAVEFILEPATH_KEY) != nil) {
                     let p12Path = dic.object(forKey: SAVEFILEPATH_KEY) as! String
                     let p12Path = dic.object(forKey: SAVEFILEPATH_KEY) as! String
                     let password = dic.object(forKey: PASSWORD_KEY)
                     let password = dic.object(forKey: PASSWORD_KEY)
                     if p12Path.count > 0 {
                     if p12Path.count > 0 {
-                        self.writeSignatureToWidget(annotation as! CPDFSignatureWidgetAnnotation, p12Path, password as! String, config, isLock)
+                        self?.writeSignatureToWidget(annotation as! CPDFSignatureWidgetAnnotation, p12Path, password as! String, config, isLock)
                     }
                     }
                 }
                 }
             }
             }

+ 2 - 2
PDF Office/PDF Master/Class/GuideInfo/KMFunctionGuideWindowController.swift

@@ -91,14 +91,14 @@ class KMFunctionGuideWindowController: NSWindowController {
                 self.singleController = KMFunctionGuideSingleController.init()
                 self.singleController = KMFunctionGuideSingleController.init()
             } else if _type == .functionMulti {
             } else if _type == .functionMulti {
                 self.multiController = KMFunctionGuideMultiController.init()
                 self.multiController = KMFunctionGuideMultiController.init()
-                self.multiController.clickHandle = {[unowned self] controller in
+                self.multiController.clickHandle = {[weak self] controller in
 #if VERSION_DMG
 #if VERSION_DMG
                     var url = URL(string:kAIStoreServerLink)!
                     var url = URL(string:kAIStoreServerLink)!
                     NSWorkspace.shared.open(url)
                     NSWorkspace.shared.open(url)
 #else
 #else
                     AIPurchaseWindowController.currentWC().showWindow(nil)
                     AIPurchaseWindowController.currentWC().showWindow(nil)
 #endif
 #endif
-                    self.closeAction()
+                    self?.closeAction()
                 }
                 }
             }
             }
         }
         }

+ 2 - 2
PDF Office/PDF Master/Class/GuideInfo/KMGuideInfoWindowController.swift

@@ -405,9 +405,9 @@ class KMGuideInfoWindowController: NSWindowController {
                 }
                 }
                 self.customColorGuideView.frame = self.coverView.bounds
                 self.customColorGuideView.frame = self.coverView.bounds
                 self.customColorGuideView.autoresizingMask = [.width, .height]
                 self.customColorGuideView.autoresizingMask = [.width, .height]
-                self.customColorGuideView.clickHandle = {[unowned self] view, actionType in
+                self.customColorGuideView.clickHandle = {[weak self] view, actionType in
                     if actionType == .getIt {
                     if actionType == .getIt {
-                        self.closeAction()
+                        self?.closeAction()
                     }
                     }
                 }
                 }
                 self.customColorGuideView.circleRect = self.digitalBoxRect
                 self.customColorGuideView.circleRect = self.digitalBoxRect