Ver Fonte

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

tangchao há 1 ano atrás
pai
commit
5d1ddad5cd
22 ficheiros alterados com 144 adições e 35 exclusões
  1. 11 9
      PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateLeftViewController.swift
  2. 2 1
      PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateWindowController.swift
  3. 3 1
      PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateCompressViewController.swift
  4. 2 1
      PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateConvertViewController.swift
  5. 3 1
      PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.swift
  6. 1 1
      PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateRemoveHeaderFooterViewController.swift
  7. 2 1
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/View/KMHeaderFooterView.swift
  8. 2 1
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/VC/KMBatchOperateAddHeaderFooterViewController.swift
  9. 2 1
      PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/WindowComtroller/KMHeaderFooterManagerWindowController.swift
  10. 3 1
      PDF Office/PDF Master/Class/PDFTools/AddPassword/VC/KMBatchOperateAddPasswordViewController.swift
  11. 42 4
      PDF Office/PDF Master/Class/PDFTools/AutoFlow/KMAotuFlowExtension.swift
  12. 2 1
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringSetting/View/KMCompareCoveringSettingView.swift
  13. 3 1
      PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/Save/View/KMCompareSaveView.swift
  14. 3 1
      PDF Office/PDF Master/Class/PDFTools/RemovePassword/VC/KMBatchOperateRemovePasswordViewController.swift
  15. 3 1
      PDF Office/PDF Master/Class/PDFTools/RemoveWatermark/VC/KMBatchOperateRemoveWatermarkViewController.swift
  16. 4 1
      PDF Office/PDF Master/Class/PDFTools/TTS/WindowController/KMTTSWindowController.swift
  17. 1 0
      PDF Office/PDF Master/Class/PDFTools/Tools/KMBaseXibView/KMBaseXibView.swift
  18. 3 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetAppearanceViewController.swift
  19. 2 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationFromViewController.swift
  20. 2 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationTextWidgetOptionsViewController.swift
  21. 44 4
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  22. 4 0
      PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseLimitWindowController.swift

+ 11 - 9
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateLeftViewController.swift

@@ -198,7 +198,7 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
                     FileManager.default.fileExists(atPath: filePath, isDirectory: &isDirectory)
                     if isDirectory.boolValue {
                         let containFiles = self.fetchAvailableFiles(in: filePath)
-                        addArray.add(containFiles)
+                        addArray.addObjects(from: containFiles)
                     } else {
                         
                         let typeIdentifier =
@@ -463,22 +463,24 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
         var pdfArray = NSMutableArray()
         for i in 0..<documentArray.count {
             let document = documentArray[i]
-            let path = document.fileURL?.path
-            let UTTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, path!.customPathExtension as CFString, nil)
-            let TypeCFString = UTTypeString as! CFString
-            if UTTypeConformsTo(TypeCFString, kUTTypePDF) {
+            let path: String = document.fileURL?.path ?? ""
+//            let UTTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, path!.customPathExtension as CFString, nil)
+            let UTTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, path.customPathExtension as CFString, nil)?.takeRetainedValue() as String?
+            let TypeCFString = UTTypeString as CFString?
+            if UTTypeConformsTo(TypeCFString!, kUTTypePDF) {
                 pdfArray.add(path as Any)
 //                UTTypeString?.release()
             } else {
 //                UTTypeString?.release()
             }
         }
-//        if !IAPProductsManager.defaultManager.isAvailableAllFunction() {
+//        if !IAPProductsManager.default().isAvailableAllFunction() {
             if self.files.count < 1 {
-                pdfArray = [pdfArray.first].compactMap { $0 } as! NSMutableArray
+//                pdfArray = [pdfArray.first].compactMap { $0 } as! NSMutableArray
+                pdfArray = NSMutableArray(array: [pdfArray.firstObject as Any])
             } else {
-//                KMPurchaseCompareWindowController.sharedInstance.showWindow(nil)
-//                return
+                KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+                return
             }
 //        }
         addFilesToList(addArray: pdfArray)

+ 2 - 1
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateWindowController.swift

@@ -393,7 +393,8 @@ final class KMBatchOperateWindowController: KMBatchOperateBaseWindowController,
         DispatchQueue.main.async {
             self.configuToolbar()
         }
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     @objc func themeChanged(notification: NSNotification) {
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {

+ 3 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateCompressViewController.swift

@@ -73,6 +73,7 @@ class KMBatchOperateCompressViewController: KMBatchOperateBaseViewController{
     
     deinit {
         NotificationCenter.default.removeObserver(self)
+        DistributedNotificationCenter.default().removeObserver(self)
     }
     
     override func viewDidLoad() {
@@ -80,7 +81,8 @@ class KMBatchOperateCompressViewController: KMBatchOperateBaseViewController{
         self.localizedLanguage()
         self.configuUI()
         
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     func localizedLanguage() {
         self.titleLabel.stringValue = NSLocalizedString("Optimization Options", comment: "")

+ 2 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateConvertViewController.swift

@@ -324,7 +324,8 @@ class KMBatchOperateConvertViewController: KMBatchOperateBaseViewController,NSCo
         NotificationCenter.default.addObserver(self, selector: #selector(batchFilesCountNotification(notification:)), name: Notification.Name(rawValue: "KMBatchFilesCountNotification"), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(IAPProductPurchasedNotification(notification:)), name: NSNotification.Name("KMIAPProductPurchasedNotification"), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(IAPProductRestoreFinishedNotification(notification:)), name: NSNotification.Name("KMIAPProductRestoreFinishedNotification"), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     @objc func batchFilesCountNotification(notification: NSNotification) {
         let arr: Array? = notification.object as? [KMBatchOperateFile]

+ 3 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.swift

@@ -71,6 +71,7 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
     
     deinit {
         NotificationCenter.default.removeObserver(self)
+        DistributedNotificationCenter.default().removeObserver(self)
     }
     
     override func viewDidLoad() {
@@ -81,7 +82,8 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
         NotificationCenter.default.addObserver(self, selector: #selector(OCRSelectedLanguagesChangeNotification(notification:)), name: NSNotification.Name("KMOCRSelectedLanguagesChangeNotification"), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(OCRSelectedPlanChangeNotification(notification:)), name: NSNotification.Name("KMOCRSelectedPlanChangeNotification"), object: nil)
         
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(batchFilesCountNotification(notification:)), name: NSNotification.Name("KMBatchFilesCountNotification"), object: nil)
     }
     func localizedLanguage() {

+ 1 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateRemoveHeaderFooterViewController.swift

@@ -16,7 +16,7 @@ class KMBatchOperateRemoveHeaderFooterViewController: KMBatchOperateBaseViewCont
 
     deinit {
         NotificationCenter.default.removeObserver(self)
-        
+        DistributedNotificationCenter.default().removeObserver(self)
         KMPrint("KMBatchOperateRemoveHeaderFooterViewController deinit.")
     }
     

+ 2 - 1
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/New/View/KMHeaderFooterView.swift

@@ -538,7 +538,8 @@ class KMHeaderFooterView: KMBaseXibView, NSTextViewDelegate, NSComboBoxDelegate
     
     override func addNotification() {
         NotificationCenter.default.addObserver(self, selector: #selector(pageChangeNotification), name: NSNotification.Name.CPDFViewPageChanged, object: self.pdfView)
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged), name: Notification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged), name: Notification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     func checkPageRangeValidate(pageRangeString: String) -> Bool {

+ 2 - 1
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/VC/KMBatchOperateAddHeaderFooterViewController.swift

@@ -70,7 +70,8 @@ class KMBatchOperateAddHeaderFooterViewController: KMBatchOperateBaseViewControl
         localizedLanguage()
         configuInterface()
         NotificationCenter.default.addObserver(self, selector: #selector(headerFootersNotification(notification:)), name: Notification.Name(rawValue: "KMBatchOperateHeaderFootersNotification"), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(batchFilesCountNotification(notification:)), name: NSNotification.Name("KMBatchFilesCountNotification"), object: nil)
     }
     func localizedLanguage() {

+ 2 - 1
PDF Office/PDF Master/Class/PDFTools/AddHeaderFooter/WindowComtroller/KMHeaderFooterManagerWindowController.swift

@@ -142,7 +142,8 @@ class KMHeaderFooterManagerWindowController: NSWindowController{
         configuUI()
         loadData()
         NotificationCenter.default.addObserver(self, selector: #selector(pageChangeNotification(notification:)), name: NSNotification.Name.CPDFViewPageChanged, object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     func configuUI() { 
         topLeftButton.wantsLayer = true

+ 3 - 1
PDF Office/PDF Master/Class/PDFTools/AddPassword/VC/KMBatchOperateAddPasswordViewController.swift

@@ -94,6 +94,7 @@ class KMBatchOperateAddPasswordViewController: KMBatchOperateBaseViewController,
     
     deinit {
         NotificationCenter.default.removeObserver(self)
+        DistributedNotificationCenter.default().removeObserver(self)
     }
     
     override func viewDidLoad() {
@@ -102,7 +103,8 @@ class KMBatchOperateAddPasswordViewController: KMBatchOperateBaseViewController,
         configuUI()
         prepareDelegate()
         NotificationCenter.default.addObserver(self, selector: #selector(batchFilesCountNotification(notification:)), name: Notification.Name(rawValue: "KMBatchFilesCountNotification"), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     func prepareDelegate() {

+ 42 - 4
PDF Office/PDF Master/Class/PDFTools/AutoFlow/KMAotuFlowExtension.swift

@@ -40,18 +40,18 @@ extension CPDFView {
     @objc func updateAutoFlow() {
         self.setDisplay(.singlePage)
         let jumpSpace = KMAutoFlowOptionsSheetController.jumpSpace()
-        if self.displayMode() == .singlePage || self.displayMode() == .twoUp {
+        if KMPreferenceManager.shared.viewPageDisplayType == .singlePage ||
+            KMPreferenceManager.shared.viewPageDisplayType == .twoUp {
             if canGoToNextPage() {
                 goToNextPage(nil)
             } else {
                 stopAutoFlow()
             }
         } else {
-            if let scrollView = documentView().enclosingScrollView {
+            if let scrollView = documentView() {
                 let clipView = scrollView.contentView
                 var newOrigin = clipView.bounds.origin
-                newOrigin.y = newOrigin.y - CGFloat(jumpSpace)
-
+                newOrigin.y = newOrigin.y + CGFloat(jumpSpace)
                 clipView.animator().setBoundsOrigin(newOrigin)
 
                 if newOrigin.y <= 0 {
@@ -139,3 +139,41 @@ extension CPDFView {
         }
     }
 }
+
+
+//extension CPDFView {
+//    func displayViewMode() -> CPDFDisplayViewMode {
+//        var displayViewMode: CPDFDisplayViewMode = .singlePage
+//        if self.displayMode() == .singlePage && self.displayDirection == .vertical {
+//            displayViewMode = .singlePageContinuous
+//        }
+//        
+//        if self.displayMode() == .twoUp  && self.displayDirection == .vertical {
+//            displayViewMode = .twoUpContinuous
+//        }
+//        return displayViewMode
+//    }
+//    
+//    func setDisplayViewMode(mode: CPDFDisplayViewMode) {
+//        switch mode {
+//        case .twoUpContinuous:
+//            self.displayTwoUp = true
+//            self.displaysAsBook = false
+//            self.displayDirection = .vertical
+//            break
+//        case .twoUp:
+//            self.displayTwoUp = true
+//            self.displaysAsBook = false
+//            self.displayDirection = .horizontal
+//            break
+//        case .singlePageContinuous:
+//            self.displayTwoUp = false
+//            self.displayDirection = .vertical
+//            break
+//        default:
+//            self.displayTwoUp = false
+//            self.displayDirection = .horizontal
+//            break
+//        }
+//    }
+//}

+ 2 - 1
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/CoveringSetting/View/KMCompareCoveringSettingView.swift

@@ -35,7 +35,8 @@ class KMCompareCoveringSettingView: KMBaseXibView {
         NSColorPanel.shared.showsAlpha = true
         separatorLine1.wantsLayer = true
         separatorLine2.wantsLayer = true
-        NotificationCenter.default.addObserver(self, selector: #selector(updateUI), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(updateUI), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(updateUI), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
         modelComboBox.isEditable = false
     }
     

+ 3 - 1
PDF Office/PDF Master/Class/PDFTools/Compare/ViewController/Save/View/KMCompareSaveView.swift

@@ -33,6 +33,7 @@ class KMCompareSaveView: KMBaseXibView {
     
     deinit {
         NotificationCenter.default.removeObserver(self)
+        DistributedNotificationCenter.default().removeObserver(self)
     }
     
     override func setup() {
@@ -42,7 +43,8 @@ class KMCompareSaveView: KMBaseXibView {
 
         refreshDocType()
 
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector:  #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     override func updateLanguage() {

+ 3 - 1
PDF Office/PDF Master/Class/PDFTools/RemovePassword/VC/KMBatchOperateRemovePasswordViewController.swift

@@ -51,13 +51,15 @@ class KMBatchOperateRemovePasswordViewController: KMBatchOperateBaseViewControll
     
     deinit {
         NotificationCenter.default.removeObserver(self)
+        DistributedNotificationCenter.default().removeObserver(self)
     }
     
     override func viewDidLoad() {
         super.viewDidLoad()
         localizedLanguage()
         configuUI()
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(batchFilesCountNotification(notification:)), name: Notification.Name(rawValue: "KMBatchFilesCountNotification"), object: nil)
     }
     @objc func themeChanged(notification: Notification) {

+ 3 - 1
PDF Office/PDF Master/Class/PDFTools/RemoveWatermark/VC/KMBatchOperateRemoveWatermarkViewController.swift

@@ -54,6 +54,7 @@ class KMBatchOperateRemoveWatermarkViewController: KMBatchOperateBaseViewControl
     
     deinit {
         NotificationCenter.default.removeObserver(self)
+        DistributedNotificationCenter.default().removeObserver(self)
     }
     
     override func viewDidLoad() {
@@ -61,7 +62,8 @@ class KMBatchOperateRemoveWatermarkViewController: KMBatchOperateBaseViewControl
         localizedLanguage()
         configuUI()
         NotificationCenter.default.addObserver(self, selector: #selector(batchFilesCountNotification(notification:)), name: Notification.Name(rawValue: "KMBatchFilesCountNotification"), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(notification:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(notification:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     @IBAction func buttonClicked_RemoveWatermark(_ sender: NSButton) {

+ 4 - 1
PDF Office/PDF Master/Class/PDFTools/TTS/WindowController/KMTTSWindowController.swift

@@ -49,7 +49,10 @@ class KMTTSWindowController: NSWindowController, KMTTSManagerDelegate, NSWindowD
     convenience init() {
         self.init(windowNibName: "KMTTSWindowController")
     }
-    
+    deinit {
+        DistributedNotificationCenter.default().removeObserver(self)
+        NotificationCenter.default.removeObserver(self)
+    }
     override func windowDidLoad() {
         super.windowDidLoad()
         self.speedStepper.minValue = Double(minSpeed)

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/Tools/KMBaseXibView/KMBaseXibView.swift

@@ -96,6 +96,7 @@ class KMBaseXibView: NSView {
     
     func removeNotification() {
         NotificationCenter.default.removeObserver(self)
+        DistributedNotificationCenter.default().removeObserver(self)
     }
     
     @objc func changeEffectiveAppearance() {

+ 3 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetAppearanceViewController.swift

@@ -111,8 +111,9 @@ private enum KMPDFAnnotationFontWeightType: Int {
             KMPropertiesViewPopController.defaultManager().showChangeColorDetailsView(colorPickerView.firstButton)
         }
         
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)),
-                                               name: Notification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)),
+//                                               name: Notification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     // MARK: Private Method

+ 2 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationFromViewController.swift

@@ -85,7 +85,8 @@ import Cocoa
             KMPropertiesViewPopController.defaultManager().showChangeColorDetailsView(colorPickerView.firstButton)
         }
 
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     // MARK: Get & Set

+ 2 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationTextWidgetOptionsViewController.swift

@@ -58,7 +58,8 @@ import Cocoa
         scrollLongTextButton.isHidden = true
         reloadData()
         
-        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     private func reloadData() {

+ 44 - 4
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -312,12 +312,44 @@ extension KMMainViewController {
         stypItem.submenu = NSSharingServicePicker.menu(forSharingItems: [string], subjectContext: "", withTarget: self, selector: #selector(shareFromService), serviceDelegate: nil)
         return stypItem
     }
+
+    func numberOfChars(_ str: String) -> (num: Int, indexN: Int) {
+        var number = 0
+        var indexN = 0
+        
+        guard str.count > 0 else {return (0, 0)}
+        
+        for i in 0...str.count - 1 {
+            let c: unichar = (str as NSString).character(at: i)
+            
+            if (c >= 0x4E00) {
+                number += 2
+            }else {
+                number += 1
+            }
+            if number > 56{
+                indexN = i
+                number = 100
+                break
+            }
+        }
+        return (number, indexN)
+    }
+    
     func setLookUpStype() -> NSMenuItem {
-        let str = String(format: "Look Up %@", listView?.currentSelection?.string() ?? "")
-        let stypItem = NSMenuItem(title: NSLocalizedString(str, comment: ""), action: #selector(lookUpAction), target: self)
+        let str = listView?.currentSelection?.string() ?? ""//String(format: "Look Up %@", listView?.currentSelection?.string() ?? "")
+        let dic = numberOfChars(str)
+        
+        var newStr = str
+        if dic.num == 100{
+            newStr = str.prefix(dic.indexN) + "..."
+        }
+        newStr = "Look Up " + newStr
+        let stypItem = NSMenuItem(title: NSLocalizedString(newStr, comment: ""), action: #selector(lookUpAction), target: self)
         
         return stypItem
     }
+    
     func setSearchBaiduStype() -> NSMenuItem {
         let stypItem = NSMenuItem(title: NSLocalizedString("Search with Baidu", comment: ""), action: #selector(searchBaiduAction), target: self)
         
@@ -380,8 +412,16 @@ extension KMMainViewController {
     }
     
     func setTranslateStype() -> NSMenuItem {
-        let str = String(format: "Translate %@", listView?.currentSelection?.string() ?? "")
-        let stypItem = NSMenuItem(title: NSLocalizedString(str, comment: ""), action: #selector(TranslateItemAction), target: self)
+        let str = listView?.currentSelection?.string() ?? ""//String(format: "Translate %@", listView?.currentSelection?.string() ?? "")
+        let dic = numberOfChars(str)
+        
+        var newStr = str
+        if dic.num == 100{
+            newStr = str.prefix(dic.indexN) + "..."
+        }
+        newStr = "Translate " + newStr
+
+        let stypItem = NSMenuItem(title: NSLocalizedString(newStr, comment: ""), action: #selector(TranslateItemAction), target: self)
         
         return stypItem
     }

+ 4 - 0
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseLimitWindowController.swift

@@ -46,6 +46,10 @@ class KMPurchaseLimitWindowController: NSWindowController {
         return nil
     }
     
+    deinit {
+        DistributedNotificationCenter.default().removeObserver(self)
+    }
+    
     override func windowDidLoad() {
         super.windowDidLoad()