Sfoglia il codice sorgente

【综合】同步AI优化版本内容

niehaoyu 1 anno fa
parent
commit
f19574dbb9

+ 266 - 160
PDF Office/PDF Master/Class/AIInfo/AIConfigWindowController/AIConfigWindowController.swift

@@ -108,7 +108,7 @@ import Cocoa
                 } else if self.configType == .proofreading {
                     tipString = NSLocalizedString("No more than 2000 characters.", comment: "")
                 } else if self.configType == .translate {
-                    tipString = NSLocalizedString("No more than 30 pages of a document.", comment: "")
+                    tipString = NSLocalizedString("1 credit for every 10,000 characters", comment: "")
                 }
                 let popViewController = KMToolbarItemPopViewController.init()
                 if self.popOver == nil {
@@ -336,6 +336,8 @@ import Cocoa
         
         self.translateFinish = false
         self.translateFile = false
+        
+        self.cancelBtn.isEnabled = true
     }
     
     func reloadData() -> Void {
@@ -421,7 +423,9 @@ import Cocoa
         
         if self.aiResultTextView.string.count > 0 && (self.fileEmptyTextView.string.count > 0 || self.filePath.count > 0){
             self.fileActionLabel.stringValue = NSLocalizedString("Redo (1 credit)", comment: "")
-            self.fileActionLabel.stringValue = NSLocalizedString("Redo (1 credit)", comment: "")
+            if self.configType == .translate && self.filePath.isEmpty == false {
+                self.fileActionLabel.stringValue = NSLocalizedString("Redo", comment: "")
+            }
         } else {
             if self.configType == .summarize {
                 self.fileActionLabel.stringValue = NSLocalizedString("Summarize", comment: "") + NSLocalizedString("(1 credit)", comment: "")
@@ -431,6 +435,9 @@ import Cocoa
                 self.fileActionLabel.stringValue = NSLocalizedString("Proofread", comment: "") + NSLocalizedString("(1 credit)", comment: "")
             } else if self.configType == .translate {
                 self.fileActionLabel.stringValue = NSLocalizedString("Translate", comment: "") + NSLocalizedString("(1 credit)", comment: "")
+                if self.filePath.isEmpty == false {
+                    self.fileActionLabel.stringValue = NSLocalizedString("Translate", comment: "")
+                }
             }
         }
         
@@ -485,6 +492,7 @@ import Cocoa
         }
     }
     
+    //MARK: WaitingView
     func addWaingView(_ view: NSView) -> Void {
         self.removeWaitingView(view)
         
@@ -503,8 +511,131 @@ import Cocoa
         }
     }
     
+    func aiTranslateFinish() -> Void {
+        self.aiConvertFinish = true
+        self.removePDFBtn.isEnabled = true
+        self.removeWaitingView(self.resultBGView)
+        self.updateActionViewUI()
+    }
+    
+    //MARK: AI-Action
+    func aiSummarize() -> Void {
+        if FileManager.default.fileExists(atPath: self.filePath) {
+            self.aiResultTextView.string = ""
+            self.addWaingView(self.resultBGView)
+            self.enableActionView(false)
+            self.removePDFBtn.isEnabled = false
+            self.aiConvertFinish = false
+            self.updateResultViewUI()
+//                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
+            KMAIRequestServerManager.defaultManager.aiAction(content: self.filePath, state: .extractSummaryFile) { wrapper in
+                DispatchQueue.main.async {
+                    self.aiConvertFinish = true
+                    self.removePDFBtn.isEnabled = true
+                    self.removeWaitingView(self.resultBGView)
+                    self.updateActionViewUI()
+                    
+                    let success = wrapper.success
+                    if success {
+                        let resultStr = wrapper.content
+                        self.aiResultTextView.string = resultStr
+                        self.updateActionViewUI()
+                        self.updateResultViewUI()
+                    } else {
+                        let alert = NSAlert()
+                        alert.alertStyle = .critical
+                        alert.messageText = wrapper.content
+                        alert.runModal()
+                        return
+                    }
+                }
+            }
+        }
+    }
+    
+    func aiReWriting() -> Void {
+        self.aiResultTextView.string = ""
+        self.addWaingView(self.resultBGView)
+        self.enableActionView(false)
+        self.removePDFBtn.isEnabled = false
+        self.aiConvertFinish = false
+        self.updateResultViewUI()
+//            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
+        KMAIRequestServerManager.defaultManager.aiAction(content: self.fileEmptyTextView.string,
+                                                         state: .rewrite) { wrapper in
+            DispatchQueue.main.async {
+                self.aiConvertFinish = true
+                self.removePDFBtn.isEnabled = true
+                self.removeWaitingView(self.resultBGView)
+                self.updateActionViewUI()
+                
+                let success = wrapper.success
+                if success {
+                    let resultStr = wrapper.content
+                    self.aiResultTextView.string = resultStr
+                    self.updateActionViewUI()
+                    self.updateResultViewUI()
+                } else {
+                    let alert = NSAlert()
+                    alert.alertStyle = .critical
+                    alert.messageText = wrapper.content
+                    alert.runModal()
+                    return
+                }
+            }
+        }
+    }
+    
+    func aiProofreading() -> Void {
+        self.aiResultTextView.string = ""
+        self.addWaingView(self.resultBGView)
+        self.enableActionView(false)
+        self.removePDFBtn.isEnabled = false
+        self.aiConvertFinish = false
+        self.updateResultViewUI()
+//            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
+        KMAIRequestServerManager.defaultManager.aiAction(content: self.fileEmptyTextView.string,
+                                                         state: .correctTypos) { wrapper in
+            DispatchQueue.main.async {
+                self.aiConvertFinish = true
+                self.removePDFBtn.isEnabled = true
+                self.removeWaitingView(self.resultBGView)
+                self.updateActionViewUI()
+                
+                let success = wrapper.success
+                if success {
+                    let resultStr = wrapper.content
+                    self.aiResultTextView.string = resultStr
+                    self.updateActionViewUI()
+                    self.updateResultViewUI()
+                } else {
+                    let alert = NSAlert()
+                    alert.alertStyle = .critical
+                    alert.messageText = wrapper.content
+                    alert.runModal()
+                    return
+                }
+            }
+        }
+    }
+    
+    func aiTranslate() -> Void {
+        
+    }
+    
+    @objc func menuItemClick(_ item: NSMenuItem) {
+        if item.tag < 2000 {
+            self.fromLanguage = item.title
+        } else {
+            self.toLanguage = item.title
+        }
+        self.fromLanguageLabel.stringValue = self.fromLanguage
+        self.toLanguageLabel.stringValue = self.toLanguage
+    }
+    
     //MARK: - IBAction
     @IBAction func chooseFileAction(_ sender: KMButton) {
+        
         let openPanel = NSOpenPanel()
         openPanel.canChooseDirectories = true
         openPanel.canChooseFiles = true
@@ -515,15 +646,21 @@ import Cocoa
                 let fileURL = openPanel.urls.first
                 let fileSize = self.getFileSize(atPath: fileURL!.path)
                 
-                if fileSize/(1024*1024) > 10 {
-                    self.fileSizeTipView.isHidden = false
-                    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 5) {
-                        self.fileSizeTipView.isHidden = true
-                    }
-                } else {
+                if self.configType == .translate {
                     self.filePath = fileURL!.path
                     self.fileEmptyTextView.string = ""
                     self.updateActionViewUI()
+                } else {
+                    if fileSize/(1024*1024) > 10 {
+                        self.fileSizeTipView.isHidden = false
+                        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 5) {
+                            self.fileSizeTipView.isHidden = true
+                        }
+                    } else {
+                        self.filePath = fileURL!.path
+                        self.fileEmptyTextView.string = ""
+                        self.updateActionViewUI()
+                    }
                 }
             }
         }
@@ -539,24 +676,12 @@ import Cocoa
         }
     }
     
-    @objc func menuItemClick(_ item: NSMenuItem) {
-        if item.tag < 2000 {
-            self.fromLanguage = item.title
-        } else {
-            self.toLanguage = item.title
-        }
-        self.fromLanguageLabel.stringValue = self.fromLanguage
-        self.toLanguageLabel.stringValue = self.toLanguage
-    }
-    
-    
     @IBAction func removePDFAction(_ sender: NSButton) {
         self.filePath = ""
         self.updateActionViewUI()
         self.updateResultViewUI()
     }
     
-    
     @IBAction func startAIFunction(_ sender: KMButton) {
         
         let newStatus: Bool = KMCloudServer.isConnectionAvailable()
@@ -569,27 +694,109 @@ import Cocoa
         }
         
         if self.configType == .summarize {
-            if FileManager.default.fileExists(atPath: self.filePath) {
-                self.aiResultTextView.string = ""
-                self.addWaingView(self.resultBGView)
-                self.enableActionView(false)
+            self.aiSummarize()
+            
+        } else if self.configType == .reWriting {
+            self.aiReWriting()
+            
+        } else if self.configType == .proofreading {
+            self.aiProofreading()
+            
+        } else if self.configType == .translate {
+            self.aiResultTextView.string = ""
+            self.addWaingView(self.resultBGView)
+            self.enableActionView(false)
+            self.translateFinish = false
+            self.translateResultView.isHidden = true
+            self.updateResultViewUI()
+            
+            if self.filePath.count > 0 {
+                self.translateFile = true
                 self.removePDFBtn.isEnabled = false
                 self.aiConvertFinish = false
-//                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
-                KMAIRequestServerManager.defaultManager.aiAction(content: self.filePath, state: .extractSummaryFile) { wrapper in
+                self.cancelBtn.isEnabled = false
+                
+                KMAIRequestServerManager.defaultManager.aiAction(content: self.filePath,
+                                                                 state: .fileTranslate,
+                                                                 from: self.fromLanguage,
+                                                                 to: self.toLanguage) { wrapper in
                     DispatchQueue.main.async {
-                        self.aiConvertFinish = true
-                        self.removePDFBtn.isEnabled = true
-                        self.removeWaitingView(self.resultBGView)
-                        self.updateActionViewUI()
                         
-                        let success = wrapper.success
+                        var success = wrapper.success
+                        let resultStr = wrapper.content
+                        if success == false && resultStr == "501" {
+                            success = true
+                        }
                         if success {
-                            let resultStr = wrapper.content
-                            self.aiResultTextView.string = resultStr
-                            self.updateActionViewUI()
-                            self.updateResultViewUI()
+                            let translateTipWC = AITranslateTipWindowController.currentWC()
+                            
+                            let infoDict: NSDictionary = wrapper.result
+                            var credit: Int = 0
+                            if infoDict["credit"] != nil {
+                                credit = (infoDict["credit"] ?? "0") as! Int
+                            }
+                            
+                            var charCount: Int = 0
+                            if infoDict["charCount"] != nil {
+                                charCount = (infoDict["charCount"] ?? "0") as! Int
+                            }
+                            
+                            translateTipWC.creditValid = true
+                            if resultStr == "501" {
+                                translateTipWC.creditValid = false
+                            }
+                            translateTipWC.spendCredits = credit
+                            translateTipWC.totalChart = charCount
+                            translateTipWC.actionHandle = {[weak self] wc, result in
+                                if result == true {
+                                    self?.window?.endSheet(wc.window!)
+                                    KMAIRequestServerManager.defaultManager.aiTranslationFileTranslateHandle(fileKey: resultStr,
+                                                                                                             from: self!.fromLanguage,
+                                                                                                             to: self!.toLanguage) { wrapper in
+                                        let success = wrapper.success
+                                        
+                                        if success {
+                                            DispatchQueue.main.async {
+                                                self?.aiTranslateFinish()
+                                                self?.cancelBtn.isEnabled = true
+                                                
+                                                self!.translateFinish = true
+                                                self!.translateResultView.isHidden = false
+                                                
+                                                
+                                                let resultStr = wrapper.content
+                                                self!.translateResultPath = resultStr
+                                                self!.updateActionViewUI()
+                                                self!.updateResultViewUI()
+                                            }
+                                        } else {
+                                            DispatchQueue.main.async {
+                                                self?.aiTranslateFinish()
+                                                self?.cancelBtn.isEnabled = true
+                                                
+                                                let alert = NSAlert()
+                                                alert.alertStyle = .critical
+                                                alert.messageText = wrapper.content
+                                                alert.runModal()
+                                            }
+                                            return
+                                        }
+                                    }
+                                } else {
+                                    self?.cancelBtn.isEnabled = true
+                                    self?.aiTranslateFinish()
+                                    self?.window?.endSheet(wc.window!)
+                                }
+                            }
+                            self.window?.beginSheet(translateTipWC.window!)
+                            translateTipWC.reloadData()
                         } else {
+                            self.cancelBtn.isEnabled = true
+                            self.aiConvertFinish = true
+                            self.removePDFBtn.isEnabled = true
+                            self.removeWaitingView(self.resultBGView)
+                            self.updateActionViewUI()
+                            
                             let alert = NSAlert()
                             alert.alertStyle = .critical
                             alert.messageText = wrapper.content
@@ -597,145 +804,44 @@ import Cocoa
                             return
                         }
                     }
-                }
-            }
-        } else if self.configType == .reWriting {
-            self.aiResultTextView.string = ""
-            self.addWaingView(self.resultBGView)
-            self.enableActionView(false)
-            self.removePDFBtn.isEnabled = false
-            self.aiConvertFinish = false
-//            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
-            KMAIRequestServerManager.defaultManager.aiAction(content: self.fileEmptyTextView.string,
-                                                             state: .rewrite) { wrapper in
-                DispatchQueue.main.async {
-                    self.aiConvertFinish = true
-                    self.removePDFBtn.isEnabled = true
-                    self.removeWaitingView(self.resultBGView)
-                    self.updateActionViewUI()
-                    
-                    let success = wrapper.success
-                    if success {
-                        let resultStr = wrapper.content
-                        self.aiResultTextView.string = resultStr
-                        self.updateActionViewUI()
-                        self.updateResultViewUI()
-                    } else {
-                        let alert = NSAlert()
-                        alert.alertStyle = .critical
-                        alert.messageText = wrapper.content
-                        alert.runModal()
-                        return
-                    }
-                }
-            }
-        } else if self.configType == .proofreading {
-            self.aiResultTextView.string = ""
-            self.addWaingView(self.resultBGView)
-            self.enableActionView(false)
-            self.removePDFBtn.isEnabled = false
-            self.aiConvertFinish = false
-//            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
-            KMAIRequestServerManager.defaultManager.aiAction(content: self.fileEmptyTextView.string,
-                                                             state: .correctTypos) { wrapper in
-                DispatchQueue.main.async {
-                    self.aiConvertFinish = true
-                    self.removePDFBtn.isEnabled = true
-                    self.removeWaitingView(self.resultBGView)
-                    self.updateActionViewUI()
-                    
-                    let success = wrapper.success
-                    if success {
-                        let resultStr = wrapper.content
-                        self.aiResultTextView.string = resultStr
-                        self.updateActionViewUI()
-                        self.updateResultViewUI()
-                    } else {
-                        let alert = NSAlert()
-                        alert.alertStyle = .critical
-                        alert.messageText = wrapper.content
-                        alert.runModal()
-                        return
-                    }
-                }
-            }
-        } else if self.configType == .translate {
-            self.aiResultTextView.string = ""
-            self.addWaingView(self.resultBGView)
-            self.enableActionView(false)
-            self.translateFinish = false
-            self.translateResultView.isHidden = true
-//            if self.filePath.count > 0 {
-                self.translateFile = true
+                };
+            } else {
+                self.translateFile = false
                 self.removePDFBtn.isEnabled = false
                 self.aiConvertFinish = false
-                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
-//                KMAIRequestServerManager.defaultManager.aiAction(content: self.filePath,
-//                                                                 state: .fileTranslate,
-//                                                                 from: self.fromLanguage,
-//                                                                 to: self.toLanguage) { wrapper in
+//                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
+                KMAIRequestServerManager.defaultManager.aiAction(content: self.fileEmptyTextView.string,
+                                                                 state: .textTranslate,
+                                                                 from: self.fromLanguage,
+                                                                 to: self.toLanguage) { wrapper in
                     DispatchQueue.main.async {
                         self.aiConvertFinish = true
                         self.removePDFBtn.isEnabled = true
                         self.removeWaitingView(self.resultBGView)
                         self.updateActionViewUI()
                         
-//                        let success = wrapper.success
-//                        if success {
+                        let success = wrapper.success
+                        if success {
                             self.translateFinish = true
                             self.translateResultView.isHidden = false
-//                        let resultStr = wrapper.content
-                        let resultStr = "wrapper.content"
-
-                            self.translateResultPath = resultStr
+                            
+                            let resultStr = wrapper.content
+                            self.aiResultTextView.string = resultStr
+                            
                             self.updateActionViewUI()
                             self.updateResultViewUI()
-//                        } else {
-//                            let alert = NSAlert()
-//                            alert.alertStyle = .critical
-//                            alert.messageText = wrapper.content
-//                            alert.runModal()
-//                            return
-//                        }
+                        } else {
+                            let alert = NSAlert()
+                            alert.alertStyle = .critical
+                            alert.messageText = wrapper.content
+                            alert.runModal()
+                            
+                            self.updateResultViewUI()
+                            return
+                        }
                     }
                 };
-//            } else {
-//            self.translateFile = false
-//                self.removePDFBtn.isEnabled = false
-//                self.aiConvertFinish = false
-////                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
-//                KMAIRequestServerManager.defaultManager.aiAction(content: self.fileEmptyTextView.string,
-//                                                                 state: .textTranslate,
-//                                                                 from: self.fromLanguage,
-//                                                                 to: self.toLanguage) { wrapper in
-//                    DispatchQueue.main.async {
-//                        self.aiConvertFinish = true
-//                        self.removePDFBtn.isEnabled = true
-//                        self.removeWaitingView(self.resultBGView)
-//                        self.updateActionViewUI()
-//                        
-//                        let success = wrapper.success
-//                        if success {
-//                            self.translateFinish = true
-//                            self.translateResultView.isHidden = false
-//                            
-//                            let resultStr = wrapper.content
-//                            self.aiResultTextView.string = resultStr
-//                            
-//                            self.updateActionViewUI()
-//                            self.updateResultViewUI()
-//                        } else {
-//                            let alert = NSAlert()
-//                            alert.alertStyle = .critical
-//                            alert.messageText = wrapper.content
-//                            alert.runModal()
-//                            
-//                            self.updateResultViewUI()
-//                            return
-//                        }
-//                    }
-//                };
-//            }
+            }
             
         }
     }

+ 141 - 0
PDF Office/PDF Master/Class/AIInfo/AITranslateTipWindowController/AITranslateTipWindowController.swift

@@ -0,0 +1,141 @@
+//
+//  AITranslateTipWindowController.swift
+//  PDF Reader Pro Edition
+//
+//  Created by Niehaoyu on 2024/2/29.
+//
+
+import Cocoa
+
+class AITranslateTipWindowController: NSWindowController {
+
+    @IBOutlet weak var contendView: NSView!
+    @IBOutlet weak var titleLabel1: NSTextField!
+    @IBOutlet weak var titleBox: KMBox!
+    @IBOutlet weak var creditsLabel: NSTextField!
+    @IBOutlet weak var charactersLabel: NSTextField!
+    
+    @IBOutlet weak var creditTipLabel: NSTextField!
+    
+    @IBOutlet weak var errorTipImage: NSImageView!
+    @IBOutlet weak var errorTipLabel: NSTextField!
+    
+    @IBOutlet weak var cancelBtn: NSButton!
+    @IBOutlet weak var confirmBtn: NSButton!
+    
+    var creditValid: Bool = false
+    var spendCredits: Int = 0
+    var totalChart: Int = 0
+    
+    var actionHandle: ((_ wc: AITranslateTipWindowController, _ confirm: Bool) -> Void)?
+    
+    static var currentWindowController: AITranslateTipWindowController!
+    
+    
+    deinit {
+        DistributedNotificationCenter.default.removeObserver(self)
+    }
+    
+    @objc static func currentWC() -> AITranslateTipWindowController {
+        if currentWindowController != nil {
+            return currentWindowController
+        } else {
+            let configWC: AITranslateTipWindowController = AITranslateTipWindowController.init(windowNibName: "AITranslateTipWindowController")
+            currentWindowController = configWC;
+            return currentWindowController
+        }
+    }
+    
+    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.titleLabel1.font = NSFont.SFProTextRegularFont(13)
+        self.creditsLabel.font = NSFont.SFProTextRegularFont(13)
+        self.charactersLabel.font = NSFont.SFProTextRegularFont(13)
+        self.creditTipLabel.font = NSFont.SFProTextRegularFont(13)
+        
+        self.titleLabel1.stringValue = NSLocalizedString("You will cost:", comment: "")
+                
+        self.creditTipLabel.stringValue = NSLocalizedString("1 credit for every 10,000 characters", comment: "")
+        self.errorTipLabel.stringValue = NSLocalizedString("Insufficient credit", comment: "")
+        
+        self.cancelBtn.title = NSLocalizedString("Cancel", comment: "")
+        self.confirmBtn.title = NSLocalizedString("Translate", comment: "")
+        
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChange), name: NSNotification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+        self.updateViewColor()
+        self.reloadData()
+        
+    }
+    
+    func reloadData() {
+        if self.creditValid == true {
+            self.errorTipImage.isHidden = true
+            self.errorTipLabel.isHidden = true
+            self.confirmBtn.isEnabled = true
+            
+        } else {
+            self.errorTipImage.isHidden = false
+            self.errorTipLabel.isHidden = false
+            self.confirmBtn.isEnabled = false
+        }
+        
+        self.creditsLabel.stringValue = String(format: NSLocalizedString("%@ credits", comment: ""), String(format: "%d", self.spendCredits))
+        self.charactersLabel.stringValue = String(format: NSLocalizedString("(Total %@ characters)", comment: ""), String(format: "%d", self.totalChart))
+    }
+    
+    func updateViewColor() {
+        self.titleBox.wantsLayer = true
+        self.titleBox.layer!.borderWidth = 1
+        
+        if KMAppearance.isDarkMode() {
+            self.titleLabel1.textColor = NSColor.white.withAlphaComponent(0.85)
+            self.creditsLabel.textColor = NSColor.white.withAlphaComponent(0.85)
+            self.charactersLabel.textColor = NSColor.white.withAlphaComponent(0.5)
+            self.creditTipLabel.textColor = NSColor.white.withAlphaComponent(0.85)
+            
+            self.titleBox.fillColor = KMAppearance.KMColor_Layout_L1()
+            self.titleBox.layer!.borderColor = NSColor.white.withAlphaComponent(0.1).cgColor
+        } else {
+            self.titleLabel1.textColor = NSColor.black.withAlphaComponent(0.85)
+            self.creditsLabel.textColor = NSColor.black.withAlphaComponent(0.85)
+            self.charactersLabel.textColor = NSColor.black.withAlphaComponent(0.5)
+            self.creditTipLabel.textColor = NSColor.black.withAlphaComponent(0.85)
+            
+            self.titleBox.fillColor = KMAppearance.KMColor_Layout_L1()
+            self.titleBox.layer!.borderColor = NSColor.black.withAlphaComponent(0.1).cgColor
+            
+        }
+        self.titleBox.cornerRadius = 2
+        self.titleBox.layer?.cornerRadius = 2
+        
+        self.errorTipLabel.textColor = KMAppearance.KMColor_Status_Err()
+        
+    }
+    
+    //MARK: IBAction
+    @IBAction func cancelAction(_ sender: NSButton) {
+        guard let callBack = self.actionHandle else {
+            return
+        }
+        callBack(self, false)
+    }
+    
+    @IBAction func confirmAction(_ sender: NSButton) {
+        guard let callBack = self.actionHandle else {
+            return
+        }
+        callBack(self, true)
+    }
+    
+    
+    @objc func themeChange() {
+       DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
+           self.updateViewColor()
+       }
+   }
+    
+    
+}

+ 192 - 0
PDF Office/PDF Master/Class/AIInfo/AITranslateTipWindowController/AITranslateTipWindowController.xib

@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="AITranslateTipWindowController" customModule="PDF_Reader_Pro" customModuleProvider="target">
+            <connections>
+                <outlet property="cancelBtn" destination="WKG-Fa-3Qh" id="GTf-ov-Kkg"/>
+                <outlet property="charactersLabel" destination="6oZ-4Y-3Bl" id="SsU-f6-kOb"/>
+                <outlet property="confirmBtn" destination="ocZ-qZ-LWg" id="oz8-AW-oOh"/>
+                <outlet property="contendView" destination="fJP-XA-WTg" id="DkW-Zh-DyM"/>
+                <outlet property="creditTipLabel" destination="gzM-va-bsC" id="d4l-HA-bgt"/>
+                <outlet property="creditsLabel" destination="NFc-Td-mzB" id="eqX-yh-jAK"/>
+                <outlet property="errorTipImage" destination="QjK-nk-ZWg" id="QYS-yr-B4D"/>
+                <outlet property="errorTipLabel" destination="VJR-C4-JHW" id="meF-4Z-Kct"/>
+                <outlet property="titleBox" destination="eMR-Ws-S0h" id="c3n-PZ-G80"/>
+                <outlet property="titleLabel1" destination="411-t6-94V" id="aEK-qw-Kxn"/>
+                <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="438" height="140"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
+            <view key="contentView" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="438" height="140"/>
+                <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="fJP-XA-WTg">
+                        <rect key="frame" x="0.0" y="0.0" width="438" height="140"/>
+                        <subviews>
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="411-t6-94V">
+                                <rect key="frame" x="18" y="100" width="121" height="16"/>
+                                <textFieldCell key="cell" lineBreakMode="clipping" title="You need to spend:" id="fXL-ec-qqJ">
+                                    <font key="font" usesAppearanceFont="YES"/>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <box boxType="custom" borderType="none" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="eMR-Ws-S0h" customClass="KMBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                <rect key="frame" x="145" y="96" width="70" height="24"/>
+                                <view key="contentView" id="Sxc-Gx-wyD">
+                                    <rect key="frame" x="0.0" y="0.0" width="70" height="24"/>
+                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                    <subviews>
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NFc-Td-mzB">
+                                            <rect key="frame" x="2" y="4" width="67" height="16"/>
+                                            <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="2 Credits" id="hYX-th-yfv">
+                                                <font key="font" metaFont="systemBold"/>
+                                                <color key="textColor" red="0.99999600649999998" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                            </textFieldCell>
+                                        </textField>
+                                        <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QDV-Zy-eZ6" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                            <rect key="frame" x="0.0" y="0.0" width="70" height="24"/>
+                                            <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="CCa-im-GS2">
+                                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                                <font key="font" metaFont="system"/>
+                                            </buttonCell>
+                                        </button>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="QDV-Zy-eZ6" firstAttribute="leading" secondItem="Sxc-Gx-wyD" secondAttribute="leading" id="9WA-oc-OdQ"/>
+                                        <constraint firstAttribute="trailing" secondItem="QDV-Zy-eZ6" secondAttribute="trailing" id="O93-Ud-HGB"/>
+                                        <constraint firstItem="QDV-Zy-eZ6" firstAttribute="top" secondItem="Sxc-Gx-wyD" secondAttribute="top" id="VrQ-2n-Zwn"/>
+                                        <constraint firstAttribute="bottom" secondItem="QDV-Zy-eZ6" secondAttribute="bottom" id="YdF-8V-sJp"/>
+                                        <constraint firstItem="NFc-Td-mzB" firstAttribute="centerX" secondItem="Sxc-Gx-wyD" secondAttribute="centerX" id="kwb-o8-5yK"/>
+                                        <constraint firstItem="NFc-Td-mzB" firstAttribute="centerY" secondItem="Sxc-Gx-wyD" secondAttribute="centerY" id="nve-ez-JTY"/>
+                                    </constraints>
+                                </view>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="70" id="0aa-HA-59p"/>
+                                    <constraint firstAttribute="height" constant="24" id="5XG-ek-cFv"/>
+                                </constraints>
+                                <color key="fillColor" red="1" green="0.36862745099999999" blue="0.17254901959999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                            </box>
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6oZ-4Y-3Bl">
+                                <rect key="frame" x="221" y="100" width="148" height="16"/>
+                                <textFieldCell key="cell" lineBreakMode="clipping" title="(Total 2483 characters)" id="aoy-fX-jNZ">
+                                    <font key="font" usesAppearanceFont="YES"/>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qBF-tK-YXN" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                <rect key="frame" x="20" y="58" width="20" height="20"/>
+                                <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="ic_else_info_large" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="AFs-at-l9l">
+                                    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                    <font key="font" metaFont="system"/>
+                                </buttonCell>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="20" id="PM1-TA-SwJ"/>
+                                    <constraint firstAttribute="width" constant="20" id="t7m-C0-0D8"/>
+                                </constraints>
+                            </button>
+                            <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="QjK-nk-ZWg">
+                                <rect key="frame" x="20" y="22" width="20" height="20"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="20" id="1Ew-Pj-pdx"/>
+                                    <constraint firstAttribute="height" constant="20" id="FWm-gk-yXh"/>
+                                </constraints>
+                                <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="creditNoTip" id="g5n-QE-CtD"/>
+                            </imageView>
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VJR-C4-JHW">
+                                <rect key="frame" x="42" y="24" width="113" height="16"/>
+                                <textFieldCell key="cell" lineBreakMode="clipping" title="Insufficient Credit" id="HdW-1R-8Zy">
+                                    <font key="font" usesAppearanceFont="YES"/>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WKG-Fa-3Qh">
+                                <rect key="frame" x="263" y="13" width="76" height="32"/>
+                                <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="rYQ-dD-Whe">
+                                    <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="cancelAction:" target="-2" id="xBX-4V-XnJ"/>
+                                </connections>
+                            </button>
+                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ocZ-qZ-LWg">
+                                <rect key="frame" x="333" y="13" width="90" height="32"/>
+                                <buttonCell key="cell" type="push" title="Translate" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="kmU-tG-waG">
+                                    <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="confirmAction:" target="-2" id="30z-Il-co6"/>
+                                </connections>
+                            </button>
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gzM-va-bsC">
+                                <rect key="frame" x="42" y="60" width="261" height="16"/>
+                                <textFieldCell key="cell" lineBreakMode="clipping" title="1 Credit is consumed per 1000 characters." id="f3j-ca-xWR">
+                                    <font key="font" usesAppearanceFont="YES"/>
+                                    <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                </textFieldCell>
+                            </textField>
+                        </subviews>
+                        <constraints>
+                            <constraint firstItem="QjK-nk-ZWg" firstAttribute="leading" secondItem="fJP-XA-WTg" secondAttribute="leading" constant="20" id="24R-CC-i7v"/>
+                            <constraint firstItem="eMR-Ws-S0h" firstAttribute="leading" secondItem="411-t6-94V" secondAttribute="trailing" constant="8" id="5aX-Bh-zc1"/>
+                            <constraint firstItem="eMR-Ws-S0h" firstAttribute="centerY" secondItem="411-t6-94V" secondAttribute="centerY" id="723-w8-u9Q"/>
+                            <constraint firstAttribute="trailing" secondItem="ocZ-qZ-LWg" secondAttribute="trailing" constant="22" id="Grj-C6-Dex"/>
+                            <constraint firstItem="VJR-C4-JHW" firstAttribute="top" secondItem="gzM-va-bsC" secondAttribute="bottom" constant="20" id="Klh-hb-c3X"/>
+                            <constraint firstItem="6oZ-4Y-3Bl" firstAttribute="centerY" secondItem="eMR-Ws-S0h" secondAttribute="centerY" id="QO8-ap-WOT"/>
+                            <constraint firstItem="VJR-C4-JHW" firstAttribute="centerY" secondItem="QjK-nk-ZWg" secondAttribute="centerY" id="SzI-v4-q3u"/>
+                            <constraint firstItem="VJR-C4-JHW" firstAttribute="leading" secondItem="QjK-nk-ZWg" secondAttribute="trailing" constant="4" id="U8Z-ge-EOi"/>
+                            <constraint firstItem="411-t6-94V" firstAttribute="leading" secondItem="fJP-XA-WTg" secondAttribute="leading" constant="20" id="WuA-Yc-IEx"/>
+                            <constraint firstItem="eMR-Ws-S0h" firstAttribute="top" secondItem="fJP-XA-WTg" secondAttribute="top" constant="20" id="ZV0-zF-8FR"/>
+                            <constraint firstItem="ocZ-qZ-LWg" firstAttribute="leading" secondItem="WKG-Fa-3Qh" secondAttribute="trailing" constant="8" id="gj4-pk-943"/>
+                            <constraint firstItem="6oZ-4Y-3Bl" firstAttribute="leading" secondItem="eMR-Ws-S0h" secondAttribute="trailing" constant="8" id="h9Q-ZN-SYJ"/>
+                            <constraint firstItem="gzM-va-bsC" firstAttribute="top" secondItem="eMR-Ws-S0h" secondAttribute="bottom" constant="20" id="hYR-rs-cLl"/>
+                            <constraint firstItem="qBF-tK-YXN" firstAttribute="leading" secondItem="fJP-XA-WTg" secondAttribute="leading" constant="20" id="iRf-ku-SRv"/>
+                            <constraint firstItem="gzM-va-bsC" firstAttribute="leading" secondItem="qBF-tK-YXN" secondAttribute="trailing" constant="4" id="o2F-Qq-Ga1"/>
+                            <constraint firstAttribute="bottom" secondItem="ocZ-qZ-LWg" secondAttribute="bottom" constant="20" id="oI7-fI-ycp"/>
+                            <constraint firstAttribute="bottom" secondItem="WKG-Fa-3Qh" secondAttribute="bottom" constant="20" id="rGd-eP-fnq"/>
+                            <constraint firstItem="gzM-va-bsC" firstAttribute="centerY" secondItem="qBF-tK-YXN" secondAttribute="centerY" id="yLX-QJ-X6z"/>
+                        </constraints>
+                    </customView>
+                </subviews>
+                <constraints>
+                    <constraint firstAttribute="trailing" secondItem="fJP-XA-WTg" secondAttribute="trailing" id="7MW-Zo-l7l"/>
+                    <constraint firstItem="fJP-XA-WTg" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" id="OfI-of-Nmf"/>
+                    <constraint firstAttribute="bottom" secondItem="fJP-XA-WTg" secondAttribute="bottom" id="Tjw-Fn-aqK"/>
+                    <constraint firstItem="fJP-XA-WTg" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="tWs-Go-RLC"/>
+                </constraints>
+            </view>
+            <connections>
+                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
+            </connections>
+            <point key="canvasLocation" x="-68" y="238"/>
+        </window>
+    </objects>
+    <resources>
+        <image name="creditNoTip" width="14" height="15"/>
+        <image name="ic_else_info_large" width="14" height="14"/>
+    </resources>
+</document>

+ 43 - 11
PDF Office/PDF Master/Class/AIInfo/KMAIRequestServerManager.swift

@@ -11,7 +11,7 @@ import AFNetworking
 @objcMembers
 class ResultWrapper: NSObject {
     var success: Bool = false
-//    var result: NSDictionary = [:]
+    var result: NSDictionary = [:]
 //    var message: String = ""
 //    var code : Int = 200
 //    var error: NSError?
@@ -29,6 +29,13 @@ class ResultWrapper: NSObject {
     init(success: Bool, content: String) {
         self.success = success
         self.content = content
+        self.result = NSDictionary.init()
+    }
+    
+    init(success: Bool, resultData: NSDictionary) {
+        self.success = success
+        self.content = ""
+        self.result = resultData
     }
 }
 
@@ -66,9 +73,11 @@ class ResultWrapper: NSObject {
                 let success: Bool = wrapper.success
                 let fileKey = wrapper.content
                 if success {
-                    aiTranslationFileTranslateHandle(fileKey: fileKey, from: languageAbbreviation(from), to: languageAbbreviation(to), complete: complete)
+                    let fileData = wrapper.result
+                    complete(wrapper)
+//                    aiTranslationFileTranslateHandle(fileKey: fileKey, from: languageAbbreviation(from), to: languageAbbreviation(to), complete: complete)
                 } else {
-                    complete(ResultWrapper(success: success, content: fileKey))
+                    complete(wrapper)
                 }
             })
         } else if state == .textTranslate { // 文本翻译
@@ -225,7 +234,8 @@ class ResultWrapper: NSObject {
         let params: [String: Any] = ["file": fileData,
                                      "uuid": uuid(),
                                      "platform": platform(),
-                                     "app_name": app_name()]
+                                     "app_name": app_name(),
+                                     "calculate":"1"]
         KMAIRequestServer.requestServer.uploadFile(urlString: urlString, params: params) { formData in
             let fileURL = URL(fileURLWithPath: file)
             try? formData.appendPart(withFileURL: fileURL, name: "file", fileName: fileURL.lastPathComponent, mimeType: "application/octet-stream")
@@ -234,7 +244,14 @@ class ResultWrapper: NSObject {
         } completion: { task, responseObject, error in
             if responseObject != nil {
                 let data: NSDictionary = responseObject!["data"] as? NSDictionary ?? [:]
-                let code: String = responseObject!["code"] as? String ?? "06005"
+                var code: String = responseObject!["code"] as? String ?? "06005"
+                if code == "06005" {
+                    let tempCode: Int = responseObject!["code"] as? Int ?? 0
+                    if tempCode == 501 {
+                        code = "501"
+                    }
+                }
+                
                 let message: String = responseObject!["message"] as? String ?? "unknown error"
                 let error = NSError(domain: message, code: Int(code)!)
 //                let result = ResultWrapper(success: true, result: data, message: message, code: Int(code)!, error: error, state: .uploadTranslate)
@@ -246,9 +263,17 @@ class ResultWrapper: NSObject {
 //                    complete(result)
 //                }
                 if Int(code)! == 200 {
-                    complete(ResultWrapper(success: true, content: data["fileKey"] as! String))
+                    let wrapper = ResultWrapper(success: true, resultData: data)
+                    wrapper.content = data["fileKey"] as! String
+                    complete(wrapper)
                 } else {
-                    complete(ResultWrapper(success: false, content: message))
+                    let wrapper = ResultWrapper(success: false, resultData: data)
+                    if Int(code)! == 501 {
+                        wrapper.content = "501"
+                    } else {
+                        wrapper.content = message
+                    }
+                    complete(wrapper)
                 }
             } else {
 //                let error = NSError(domain: "unknown error", code: 404)
@@ -265,15 +290,15 @@ class ResultWrapper: NSObject {
      @param from 初始语言
      @param to 结束语言
      */
-    private func aiTranslationFileTranslateHandle(fileKey: String, from: String, to: String, complete: @escaping KMRequestServerComplete) {
+    func aiTranslationFileTranslateHandle(fileKey: String, from: String, to: String, complete: @escaping KMRequestServerComplete) {
         
         let infoDictionary = Bundle .main.infoDictionary!
         let urlString = AIInfoConfig().aiActionURL + "/api/AI/fileTranslate"
         var semaphore = DispatchSemaphore (value: 0)
 
         let paraDict = ["fileKey": fileKey,
-                        "from": from,
-                        "to": to,
+                        "from": languageAbbreviation(from),
+                        "to": languageAbbreviation(to),
                         "uuid": uuid(),
                         "platform": platform(),
                         "app_name": app_name()]
@@ -389,7 +414,14 @@ class ResultWrapper: NSObject {
 //                    complete(result)
 //                }
                 if Int(code)! == 200 {
-                    complete(ResultWrapper(success: true, content: data1["dst"] as! String))
+                    var resultStr = data1["dst"] as! String
+                    if resultStr.contains("\\n") || resultStr.contains("\\r") {
+                        resultStr = resultStr.replacingOccurrences(of: "\\n", with: "\n")
+                        resultStr = resultStr.replacingOccurrences(of: "\\r", with: "\r")
+                    } else if q.contains("\u{2028}") {
+                        
+                    }
+                    complete(ResultWrapper(success: true, content: resultStr))
                 } else {
                     complete(ResultWrapper(success: false, content: message))
                 }

+ 7 - 5
PDF Office/PDF Master/Class/DigtalSignature/DSignatureApperanceManager.swift

@@ -61,7 +61,7 @@ class DSignatureApperanceManager: NSObject {
         var verItem: CPDFSignatureConfigItem!
         
         for item in contens {
-            if (item as! CPDFSignatureConfigItem).key == kNAME_KEY {
+            if (item as! CPDFSignatureConfigItem).key == NAME_KEY {
                 nameItem = item as? CPDFSignatureConfigItem
             } else if (item as! CPDFSignatureConfigItem).key == DN_KEY {
                 dnItem = item as? CPDFSignatureConfigItem
@@ -187,7 +187,7 @@ class DSignatureApperanceManager: NSObject {
 #endif
         
         let nameItem = CPDFSignatureConfigItem.init()
-        nameItem.key = kNAME_KEY
+        nameItem.key = NAME_KEY
         nameItem.value = NSLocalizedString("<your common name here>", comment: "")
         
         let dateItem = CPDFSignatureConfigItem.init()
@@ -216,7 +216,9 @@ class DSignatureApperanceManager: NSObject {
         var contents = Array<Any>.init()
         for key in dic.allKeys {
             if key as! String == ISDRAWLOGO_KEY {
-                config.isDrawLogo = (dic[ISDRAWLOGO_KEY] != nil)
+                if let isDrawLogo = dic[ISDRAWLOGO_KEY] as? Bool {
+                    config.isDrawLogo = isDrawLogo
+                }
             } else if key as! String == ISDRAW_KEY {
                 config.isDrawKey = (dic[ISDRAW_KEY] != nil)
             } else if key as! String == ISCONTENTALGINLEGF_KEY {
@@ -242,7 +244,7 @@ class DSignatureApperanceManager: NSObject {
             }
         }
         
-        if config.isDrawLogo {
+//        if config.isDrawLogo {
 #if VERSION_FREE
 #if VERSION_DMG
         config.logo = NSImage(named: "PDF Reader Pro")
@@ -253,7 +255,7 @@ class DSignatureApperanceManager: NSObject {
 #else
         config.logo = NSImage(named: "PDF Reader Pro Edition")
 #endif
-        }
+//        }
         config.contents = self.sortContens(contents as NSArray) as? [CPDFSignatureConfigItem]
         return config
     }

+ 24 - 0
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -4070,6 +4070,12 @@
 		BB90E4F62AF3B71800B04B9F /* KMPDFWatermarkData.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB90E4F52AF3B71800B04B9F /* KMPDFWatermarkData.swift */; };
 		BB90E4F72AF3B71800B04B9F /* KMPDFWatermarkData.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB90E4F52AF3B71800B04B9F /* KMPDFWatermarkData.swift */; };
 		BB90E4F82AF3B71800B04B9F /* KMPDFWatermarkData.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB90E4F52AF3B71800B04B9F /* KMPDFWatermarkData.swift */; };
+		BB93C3162B9EFC9800A926E6 /* AITranslateTipWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB93C3142B9EFC9800A926E6 /* AITranslateTipWindowController.swift */; };
+		BB93C3172B9EFC9800A926E6 /* AITranslateTipWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB93C3142B9EFC9800A926E6 /* AITranslateTipWindowController.swift */; };
+		BB93C3182B9EFC9800A926E6 /* AITranslateTipWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB93C3142B9EFC9800A926E6 /* AITranslateTipWindowController.swift */; };
+		BB93C3192B9EFC9800A926E6 /* AITranslateTipWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB93C3152B9EFC9800A926E6 /* AITranslateTipWindowController.xib */; };
+		BB93C31A2B9EFC9800A926E6 /* AITranslateTipWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB93C3152B9EFC9800A926E6 /* AITranslateTipWindowController.xib */; };
+		BB93C31B2B9EFC9800A926E6 /* AITranslateTipWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB93C3152B9EFC9800A926E6 /* AITranslateTipWindowController.xib */; };
 		BB93CDE52AE757A000B29C57 /* KMToolbarItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB93CDE42AE757A000B29C57 /* KMToolbarItemView.swift */; };
 		BB93CDE62AE757A000B29C57 /* KMToolbarItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB93CDE42AE757A000B29C57 /* KMToolbarItemView.swift */; };
 		BB93CDE72AE757A000B29C57 /* KMToolbarItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB93CDE42AE757A000B29C57 /* KMToolbarItemView.swift */; };
@@ -6789,6 +6795,8 @@
 		BB90E4ED2AF3546500B04B9F /* NSUserDefaultsController+KMExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSUserDefaultsController+KMExtension.swift"; sourceTree = "<group>"; };
 		BB90E4F12AF37F9F00B04B9F /* KMCustomViewButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCustomViewButton.swift; sourceTree = "<group>"; };
 		BB90E4F52AF3B71800B04B9F /* KMPDFWatermarkData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPDFWatermarkData.swift; sourceTree = "<group>"; };
+		BB93C3142B9EFC9800A926E6 /* AITranslateTipWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AITranslateTipWindowController.swift; sourceTree = "<group>"; };
+		BB93C3152B9EFC9800A926E6 /* AITranslateTipWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AITranslateTipWindowController.xib; sourceTree = "<group>"; };
 		BB93CDE42AE757A000B29C57 /* KMToolbarItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMToolbarItemView.swift; sourceTree = "<group>"; };
 		BB93CDE82AE7B6E100B29C57 /* KMToolbarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMToolbarView.swift; sourceTree = "<group>"; };
 		BB9599C22B31647B0062D346 /* KMRedactPropertiesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMRedactPropertiesWindowController.swift; sourceTree = "<group>"; };
@@ -10553,6 +10561,7 @@
 				BB0FE02A2B734DD1001E0F88 /* Resources */,
 				BB0FE02C2B734DD1001E0F88 /* AIPurchaseWindowController */,
 				BB0FE02F2B734DD1001E0F88 /* AIUserInfoController */,
+				BB93C3132B9EFC9800A926E6 /* AITranslateTipWindowController */,
 				BB0FE0322B734DD1001E0F88 /* KMAIRequestServerManager.swift */,
 			);
 			path = AIInfo;
@@ -12287,6 +12296,15 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		BB93C3132B9EFC9800A926E6 /* AITranslateTipWindowController */ = {
+			isa = PBXGroup;
+			children = (
+				BB93C3142B9EFC9800A926E6 /* AITranslateTipWindowController.swift */,
+				BB93C3152B9EFC9800A926E6 /* AITranslateTipWindowController.xib */,
+			);
+			path = AITranslateTipWindowController;
+			sourceTree = "<group>";
+		};
 		BB9695A529BDA3A800FD68D3 /* Property */ = {
 			isa = PBXGroup;
 			children = (
@@ -13764,6 +13782,7 @@
 				9F221ED229A85D3700978A59 /* KMDesignBase.xib in Resources */,
 				ADE86ABA2B0343F100414DFA /* KMWatermarkView.xib in Resources */,
 				9F853A052947137500DF644E /* newtab_h.pdf in Resources */,
+				BB93C3192B9EFC9800A926E6 /* AITranslateTipWindowController.xib in Resources */,
 				AD7D5CC62B9566E9006562CD /* KMBookmarkOutlineView.xib in Resources */,
 				AD3AAD8B2B10349600DE5FE7 /* KMHeaderFooterWindowController.xib in Resources */,
 				9F8539FC2947137500DF644E /* throbber_waiting.png in Resources */,
@@ -14590,6 +14609,7 @@
 				AD0FA50729A8E61B00EDEB50 /* KMLightMemberAlertView.xib in Resources */,
 				BB69C963299116FD0001A9B1 /* horizontal_line.pdf in Resources */,
 				BBFE6E612930809A00142C01 /* KMMergeCollectionPageViewItem.xib in Resources */,
+				BB93C31A2B9EFC9800A926E6 /* AITranslateTipWindowController.xib in Resources */,
 				BB10FAF32AFE23BE00F18D65 /* LineInspector.xib in Resources */,
 				ADD5AE5A2A64DD2600C14249 /* KMPurchaseAlertView.xib in Resources */,
 				BB89723E294B3C840045787C /* KMWatermarkPropertyController.xib in Resources */,
@@ -14799,6 +14819,7 @@
 				BB0B2CDA2B04AE560088FFD8 /* LeftSideView.xib in Resources */,
 				AD7D5CC82B9566E9006562CD /* KMBookmarkOutlineView.xib in Resources */,
 				BB9EA1552B1ECD0F00EAFD9B /* KMBatchOperateImageToPDFViewController.xib in Resources */,
+				BB93C31B2B9EFC9800A926E6 /* AITranslateTipWindowController.xib in Resources */,
 				9FA693AD2987C0590055488A /* KMStepperView.xib in Resources */,
 				BB89721D294AED6C0045787C /* KMWatermarkAdjectivePreViewBaseController.xib in Resources */,
 				AD2D74BB29F0D3A100EDC5E4 /* KMCancellationSuccessView.xib in Resources */,
@@ -15676,6 +15697,7 @@
 				BB6013842AD3A0DE00A76FB2 /* CPDFTextWidgetAnnotation+PDFListView.swift in Sources */,
 				9F8DDF2629237910006CDC73 /* Array+KMExtensions.swift in Sources */,
 				BB8F4560295AA39F0037EA22 /* KMHeaderFooterModel.swift in Sources */,
+				BB93C3162B9EFC9800A926E6 /* AITranslateTipWindowController.swift in Sources */,
 				BBB9B325299A5D6D004F3235 /* GTMKeychain_macOS.m in Sources */,
 				BB146FAE299DC0D100784A6A /* GTLRService.m in Sources */,
 				BB4A948D2B04726A00940F8B /* KMOCTool.m in Sources */,
@@ -17068,6 +17090,7 @@
 				AD3AAD3D2B0B7B2900DE5FE7 /* KMCompareTextView.swift in Sources */,
 				9F0CB52A298656C900007028 /* KMDesignToken+BorderWidthTop.swift in Sources */,
 				BB93CDEA2AE7B6E100B29C57 /* KMToolbarView.swift in Sources */,
+				BB93C3172B9EFC9800A926E6 /* AITranslateTipWindowController.swift in Sources */,
 				BBB612AA2AF48952000F3724 /* KMBackgroundObject.swift in Sources */,
 				BB4EEF492976504C003A3537 /* KMRedactColorView.swift in Sources */,
 				BBEC00E2295C410A00A26C98 /* KMBatesPrefixInfoView.swift in Sources */,
@@ -18135,6 +18158,7 @@
 				AD1CA3F92A05FCB60070541F /* KMAnnotationScreenViewController.swift in Sources */,
 				BBBAECFE2B57713F00266BD3 /* KMTransitionInfo.swift in Sources */,
 				9F1FE4EC29406E4700E952CA /* NSBezierPath+MCAdditions.m in Sources */,
+				BB93C3182B9EFC9800A926E6 /* AITranslateTipWindowController.swift in Sources */,
 				BB1B0AFA2B4FC6E900889528 /* KMOpenFileFunctionView.swift in Sources */,
 				9F5664892988B16F00020985 /* KMTextfieldVC.swift in Sources */,
 				ADAFDA3B2AE8EEFF00F084BC /* KMAdvertisementRequestServer.swift in Sources */,

+ 169 - 0
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -97,6 +97,36 @@
                   endingLineNumber = "1250"
                   offsetFromSymbolStart = "378">
                </Location>
+               <Location
+                  uuid = "4AA968F7-D1AD-4F10-A211-DD4DBC127E87 - 45ecdaf4581f4972"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "closure #1 (Swift.Bool, Swift.String) -&gt; () in closure #1 @Swift.MainActor () -&gt; () in closure #2 (__C.NSModalResponse) -&gt; () in PDF_Reader_Pro.KMLeftSideViewController.insertPDF(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Action.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1250"
+                  endingLineNumber = "1250"
+                  offsetFromSymbolStart = "640">
+               </Location>
+               <Location
+                  uuid = "4AA968F7-D1AD-4F10-A211-DD4DBC127E87 - 647d094c8e47ece6"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "closure #1 (Swift.Optional&lt;__C.CPDFDocument&gt;, Swift.Optional&lt;__C.NSString&gt;, Swift.Optional&lt;Swift.Array&lt;__C.CPDFPage&gt;&gt;, Swift.Int) -&gt; () in closure #1 (Swift.Bool, Swift.String) -&gt; () in closure #1 @Swift.MainActor () -&gt; () in closure #2 (__C.NSModalResponse) -&gt; () in PDF_Reader_Pro.KMLeftSideViewController.insertPDF(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Action.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1250"
+                  endingLineNumber = "1250"
+                  offsetFromSymbolStart = "400">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -176,6 +206,36 @@
                   endingLineNumber = "239"
                   offsetFromSymbolStart = "307">
                </Location>
+               <Location
+                  uuid = "C7C5E7EB-B0DF-4235-AF65-1600A9C47C37 - a1dd9d1b8830716a"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMHomeHistoryFileTableviewCell.historyFileDeleteAction(Swift.Array&lt;Foundation.URL&gt;) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "238"
+                  endingLineNumber = "238"
+                  offsetFromSymbolStart = "824">
+               </Location>
+               <Location
+                  uuid = "C7C5E7EB-B0DF-4235-AF65-1600A9C47C37 - 78b20d06475dc1cc"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "closure #1 @Swift.MainActor () -&gt; () in PDF_Reader_Pro.KMHomeHistoryFileTableviewCell.historyFileDeleteAction(Swift.Array&lt;Foundation.URL&gt;) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "238"
+                  endingLineNumber = "238"
+                  offsetFromSymbolStart = "360">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -193,6 +253,38 @@
             endingLineNumber = "368"
             landmarkName = "viewDidAppear()"
             landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "04E07B7E-6311-4531-B13B-1CF089F93B9A - 32d5577e3055e387"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMHomeHistoryFileViewController.viewDidAppear() -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "368"
+                  endingLineNumber = "368"
+                  offsetFromSymbolStart = "464">
+               </Location>
+               <Location
+                  uuid = "04E07B7E-6311-4531-B13B-1CF089F93B9A - 32d5577e3055e387"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMHomeHistoryFileViewController.viewDidAppear() -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "368"
+                  endingLineNumber = "368"
+                  offsetFromSymbolStart = "692">
+               </Location>
+            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -209,6 +301,38 @@
             endingLineNumber = "580"
             landmarkName = "deleteAction(_:)"
             landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "97F1A1F6-EA0A-4519-A518-F16347EBF2C5 - 44778aff718b7d0"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMHomeHistoryFileViewController.deleteAction(__C.NSButton) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "580"
+                  endingLineNumber = "580"
+                  offsetFromSymbolStart = "396">
+               </Location>
+               <Location
+                  uuid = "97F1A1F6-EA0A-4519-A518-F16347EBF2C5 - 44778aff718b7d0"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMHomeHistoryFileViewController.deleteAction(__C.NSButton) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "580"
+                  endingLineNumber = "580"
+                  offsetFromSymbolStart = "632">
+               </Location>
+            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -400,6 +524,21 @@
                   endingLineNumber = "92"
                   offsetFromSymbolStart = "653">
                </Location>
+               <Location
+                  uuid = "420D08E5-EF45-4277-8829-126645D63C25 - 655c4cef36e8ca1"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMProfileInfoWindowController.menuItemClicked_Edit(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "92"
+                  endingLineNumber = "92"
+                  offsetFromSymbolStart = "280">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -448,6 +587,21 @@
                   endingLineNumber = "107"
                   offsetFromSymbolStart = "523">
                </Location>
+               <Location
+                  uuid = "9D5FA5F4-0720-42EF-B7B2-1D04CEE324CD - 661d6e6c27ab6d21"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMProfileInfoWindowController.menuItemClicked_Add(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "107"
+                  endingLineNumber = "107"
+                  offsetFromSymbolStart = "144">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -656,6 +810,21 @@
                   endingLineNumber = "53"
                   offsetFromSymbolStart = "181">
                </Location>
+               <Location
+                  uuid = "44337E05-94FF-4B8A-8AB7-5A77E6B1BE81 - 85181671ee2934a3"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "__C.NSUserDefaults.setColor(_: __C.NSColor, forKey: Swift.String) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Common/Category/NSUserDefaults_KMExtension.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "53"
+                  endingLineNumber = "53"
+                  offsetFromSymbolStart = "88">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>