Просмотр исходного кода

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

dinglingui 1 месяц назад
Родитель
Сommit
10a34a335f
39 измененных файлов с 411 добавлено и 142 удалено
  1. 12 6
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/GroupItem/ComponentGroup.swift
  2. 6 1
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/Select/ComponentSelect.swift
  3. 2 2
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/SideBar/SideBarItem/PageTurner/ComponentSidebarPageTurner.xib
  4. 1 2
      PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController+CreateFile.swift
  5. 9 1
      PDF Office/PDF Master/Class/KMDeviceBrowserWindowController/KMDeviceBrowserWindowController.swift
  6. 4 1
      PDF Office/PDF Master/Class/PDFTools/Compress/Manager/KMCompressManager.swift
  7. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+KeyEvent.m
  8. 7 5
      PDF Office/PDF Master/KMClass/Convert/Base/KMConvertBaseWindowController.swift
  9. 6 2
      PDF Office/PDF Master/KMClass/KMHomeViewController/HistoryFilesManager/KMFileThumbManager.swift
  10. 1 1
      PDF Office/PDF Master/KMClass/KMHomeViewController/KMURLCreatePDFWindowController/KMURLCreatePDFWindowController.xib
  11. 1 1
      PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/HistoryFilesItems/KMHistoryFileThumbItem.swift
  12. 44 32
      PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/KMHomeRightView.swift
  13. 4 4
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/KMBackgroundManager.swift
  14. 2 2
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/KMBackgroundModel.swift
  15. 11 4
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBackgroundPropertyController.swift
  16. 12 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/Views/KMBatesPropertyController.swift
  17. 10 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/Views/KMNWatermarkPropertyController.swift
  18. 7 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterController.swift
  19. 1 1
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterManager.swift
  20. 11 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHeaderPropertyController.swift
  21. 73 18
      PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift
  22. 16 16
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Pen/KMPenController.swift
  23. 6 8
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/CreateSignWindowController/KMCreateSignWindowController.swift
  24. 23 4
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/KMSignatureListController.swift
  25. 10 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/KMSignatureListController.xib
  26. 1 1
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/KMSignatureManager.swift
  27. 11 0
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/StampList/KMStampListController.swift
  28. 3 3
      PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/StampList/KMStampManager.swift
  29. 77 7
      PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift
  30. 5 5
      PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/Model/KMPDFToolbarManager.swift
  31. 13 4
      PDF Office/PDF Master/KMClass/NewBatch/Manager/KMBatchManager.swift
  32. 2 2
      PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/KMBatchProcessingTableView.swift
  33. 2 2
      PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/Views/Tableview/Views/KMBatchProcessingNameTableCell.xib
  34. 9 0
      PDF Office/PDF Master/KMClass/NewBatch/View/Setting/ImageToPDF/KMBatchImageToPDFView.swift
  35. 2 2
      PDF Office/PDF Master/KMClass/Settings/SettingsDisplayView.swift
  36. 1 0
      PDF Office/PDF Master/KMClass/Tools/Category/AppKit/NSDocumentController+KMExtension.swift
  37. 1 1
      PDF Office/PDF Master/KMClass/Tools/Category/Foundation/String+KMExtensions.swift
  38. 1 1
      PDF Office/PDF Master/KMClass/Tools/Category/NSWindowController+Extension/NSWindowController+Extension.swift
  39. 2 1
      PDF Office/PDF Master/KMClass/Tools/Tool/KMTools.swift

+ 12 - 6
PDF Office/KMComponentLibrary/KMComponentLibrary/View/GroupItem/ComponentGroup.swift

@@ -304,9 +304,8 @@ public class ComponentGroup: NSView, NibLoadable {
         point.x += CGRectGetWidth(itemView.contendBox.frame)
         point.y -= viewHeight
         point.y += CGRectGetHeight(itemView.contendBox.frame)
-        
-        print(point, NSDate())
-        guard let subView = itemView.view.window?.contentView else {
+         
+        guard let _ = itemView.view.window?.contentView else {
             return
         }
         subGroupView.showSubGroupWithPoint(point)
@@ -333,10 +332,17 @@ public class ComponentGroup: NSView, NibLoadable {
                     }
                 } else if event.type == .scrollWheel {
                     let point = self.convert(event.locationInWindow, from: nil)
+
+                    var subPoint = CGPointZero
+                    if let subview = self.subGroupView {
+                        subPoint = subview.convert(event.locationInWindow, from: nil)
+                    }
                     if CGRectContainsPoint(self.bounds, point) {
                         
+                    } else if let subView = self.subGroupView, CGRectContainsPoint(subView.bounds, subPoint) {
+                        
                     } else {
-                        self.leftMouseDownAction()
+                       
                     }
                 } else if event.type == .rightMouseDown {
                     let point = self.convert(event.locationInWindow, from: nil)
@@ -365,12 +371,12 @@ public class ComponentGroup: NSView, NibLoadable {
         }
     }
     
-    func leftMouseDownAction() {
-        
+    @objc func leftMouseDownAction() {
         groupDelegate?.componentGroupDidDismiss?(group: self)
         
         removeGroupView()
         
+        removeSubGroupView()
     }
 }
 

+ 6 - 1
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Select/ComponentSelect.swift

@@ -456,7 +456,12 @@ public class ComponentSelect: ComponentBaseXibView {
     
     public override func mouseDown(with event: NSEvent) {
         if properties.creatable == true {
-            super.mouseDown(with: event)
+            let point = convert(event.locationInWindow, from: nil)
+            if CGRectContainsPoint(rightIconImage.frame, point) {
+                
+            } else {
+                super.mouseDown(with: event)
+            }
         }
         delegate?.componentSelectDidMouseDown?(self, with: event)
     }

+ 2 - 2
PDF Office/KMComponentLibrary/KMComponentLibrary/View/SideBar/SideBarItem/PageTurner/ComponentSidebarPageTurner.xib

@@ -60,9 +60,9 @@
                                             <constraint firstAttribute="width" constant="32" id="pbU-yq-04a"/>
                                         </constraints>
                                     </customView>
-                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Pok-m4-wyK">
+                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Pok-m4-wyK">
                                         <rect key="frame" x="-2" y="0.0" width="36" height="16"/>
-                                        <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="/200" id="KVb-Ap-NSC">
+                                        <textFieldCell key="cell" lineBreakMode="truncatingTail" alignment="center" title="/200" id="KVb-Ap-NSC">
                                             <font key="font" usesAppearanceFont="YES"/>
                                             <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>

+ 1 - 2
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController+CreateFile.swift

@@ -73,8 +73,7 @@ extension KMBrowserWindowController {
         vc.importScannerFileCallback = { [weak self] (url: NSURL) -> Void in
             self?.openFile(withFilePath: url as URL)
         }
-        vc.showWindow(nil)
-        vc.window?.center()
+        vc.showWindowInCenter(nil)
     }
      
     //MARK: Batch

+ 9 - 1
PDF Office/PDF Master/Class/KMDeviceBrowserWindowController/KMDeviceBrowserWindowController.swift

@@ -46,13 +46,21 @@ class KMDeviceBrowserWindowController: NSWindowController {
         self.cameraDeviceView.downloadSelectedControlLabel = NSLocalizedString("Import", comment: "")
         self.cameraDeviceView.downloadAllControlLabel = NSLocalizedString("Import All", comment: "")
         self.window!.title = NSLocalizedString("Import", comment: "")
+        
+    }
+    
+    override func showWindow(_ sender: Any?) {
+        super.showWindow(sender)
+        
+        self.splitView.setPosition(200, ofDividerAt: 0)
+        
     }
     
 }
 
 extension KMDeviceBrowserWindowController: NSSplitViewDelegate {
     func splitView(_ splitView: NSSplitView, constrainMinCoordinate proposedMinimumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {
-        return 150.0
+        return 200
     }
     
     func splitView(_ splitView: NSSplitView, constrainMaxCoordinate proposedMaximumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {

+ 4 - 1
PDF Office/PDF Master/Class/PDFTools/Compress/Manager/KMCompressManager.swift

@@ -9,12 +9,14 @@ import Cocoa
 import ComPDFKit
 import KMComponentLibrary
 
+typealias KMCompressManagerCancelAction = () -> Void
+
 class KMCompressManager: NSObject {
     static let shared = KMCompressManager()
     
     var progressWindow: ComponentProgressWindowController?
-    
     var isCancelCompress = false
+    var cancelAction: KMCompressManagerCancelAction?
     
     func compress(documentURL: URL,
                   password: String = "",
@@ -233,5 +235,6 @@ extension KMCompressManager {
     
     @objc func closeProgress() {
         self.isCancelCompress = true
+        cancelAction?()
     }
 }

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+KeyEvent.m

@@ -188,9 +188,9 @@
             CGFloat defaultValue = [CPDFInkAnnotation defaultLineWidth];
             defaultValue = min(18, defaultValue+1);
             [CPDFInkAnnotation updateDefault_LineWidth:defaultValue];
-        } else if (theEvent.keyCode == 24 && isShiftPressed == YES) {
+        } else if (theEvent.keyCode == 27 && isShiftPressed == YES) {
             CGFloat defaultValue = [CPDFInkAnnotation defaultLineWidth];
-            defaultValue = max(0, defaultValue-1);
+            defaultValue = max(1, defaultValue-1);
             [CPDFInkAnnotation updateDefault_LineWidth:defaultValue];
         }
     }

+ 7 - 5
PDF Office/PDF Master/KMClass/Convert/Base/KMConvertBaseWindowController.swift

@@ -108,10 +108,11 @@ class KMConvertBaseWindowController: KMNBaseWindowController {
         convertButton_ = ComponentButton()
         convertBox.contentView = convertButton_
         convertButton_?.properties = ComponentButtonProperty(type: .primary,
-                                                          size: .s,
-                                                          state: .normal,
-                                                          isDisable: false,
-                                                          buttonText: KMLocalizedString("Convert"))
+                                                             size: .s,
+                                                             state: .normal,
+                                                             isDisable: false,
+                                                             buttonText: KMLocalizedString("Convert"),
+                                                             keepPressState: false)
         convertButton_?.setTarget(self, action: #selector(convertButtonAction))
         convertButton_?.keyEquivalent = KMKeyEquivalent.enter
         
@@ -223,10 +224,11 @@ class KMConvertBaseWindowController: KMNBaseWindowController {
     
     @objc func convertButtonAction() {
         window?.makeFirstResponder(nil)
+        settingView?.pageRangeItemView?.pageSizeVC?.textField.resignFirstResponder()
         if (pageRange == .custom) {
             let array = findSelectPage(pageRangeString: pageRangeString)
             if (array.count <= 0) {
-                window?.makeFirstResponder(settingView?.pageRangeItemView?.pageSizeVC?.textField)
+                settingView?.pageRangeItemView?.pageSizeVC?.textField.resignFirstResponder()
                 return
             }
         }

+ 6 - 2
PDF Office/PDF Master/KMClass/KMHomeViewController/HistoryFilesManager/KMFileThumbManager.swift

@@ -14,7 +14,7 @@ class KMFileThumbManager: NSObject {
     
     @objc public static let manager = KMFileThumbManager()
     
-    private var iconSize: CGSize = CGSizeMake(126*3, 168*3)
+    private var default_IconSize: CGSize = CGSizeMake(126*3, 168*3)
     
     override init() {
         super.init()
@@ -44,7 +44,7 @@ class KMFileThumbManager: NSObject {
             
             let resultPath = thumbFolderPath?.stringByAppendingPathComponent((fileName + ".png"))
             if (!FileManager.default.fileExists(atPath: resultPath!)) {
-                updateFile(url, iconSize)
+                updateFile(url, default_IconSize)
             }
             fileNames.append((fileName + ".png"))
         }
@@ -82,6 +82,10 @@ class KMFileThumbManager: NSObject {
         return thumbnail
     }
     
+    public func updateFile(_ fileURL: URL) {
+        self.updateFile(fileURL, default_IconSize)
+    }
+    
     public func updateFile(_ fileURL: URL, _ iconSize: CGSize) {
         let filePath = fileURL.path
         let fileName = filePath.getLastComponentDeleteExtension

+ 1 - 1
PDF Office/PDF Master/KMClass/KMHomeViewController/KMURLCreatePDFWindowController/KMURLCreatePDFWindowController.xib

@@ -24,7 +24,7 @@
         <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" titlebarAppearsTransparent="YES" titleVisibility="hidden" id="F0z-JX-Cv5">
-            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" fullSizeContentView="YES"/>
+            <windowStyleMask key="styleMask" titled="YES" fullSizeContentView="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="480" height="196"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>

+ 1 - 1
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/HistoryFilesItems/KMHistoryFileThumbItem.swift

@@ -52,7 +52,7 @@ class KMHistoryFileThumbItem: NSCollectionViewItem {
         
         cardFileItem.properties.state = self.isSelected ? .pressed : .normal
         cardFileItem.properties.icon = file.image
-        cardFileItem.properties.text = file.name
+        cardFileItem.properties.text = String.deletingPathExtension(file.name)
         cardFileItem.reloadData()
 
     }

+ 44 - 32
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/KMHomeRightView.swift

@@ -214,49 +214,61 @@ public class KMHomeRightView: BaseXibView {
     }
     
     func fileDeleteAction() {
-        if UserDefaults.standard.object(forKey: "HomeFilesDeleteConfirmKey") != nil {
-            var selects: [URL] = []
-            if HistoryFilesManager.manager.selectFiles.count > 0 {
-                for selecturl in HistoryFilesManager.manager.selectFiles {
-                    selects.append(selecturl)
+        if HistoryFilesManager.manager.selectFiles.count > 0 {
+            if UserDefaults.standard.object(forKey: "HomeFilesDeleteConfirmKey") != nil {
+                var selects: [URL] = []
+                if HistoryFilesManager.manager.selectFiles.count > 0 {
+                    for selecturl in HistoryFilesManager.manager.selectFiles {
+                        selects.append(selecturl)
+                    }
                 }
+                HistoryFilesManager.manager.historyFileDeleteAction(selects)
+                self.reloadData()
+                
+                return
             }
-            HistoryFilesManager.manager.historyFileDeleteAction(selects)
-            self.reloadData()
-            
-            return
-        }
-        let alert = NSAlert()
-        alert.alertStyle = .informational
-        if HistoryFilesManager.manager.selectFiles.count > 0 {
+            let alert = NSAlert()
+            alert.alertStyle = .informational
             alert.informativeText = KMLocalizedString("Remove Selected Files from your Recent Files?")
-        } else {
-            alert.informativeText = KMLocalizedString("Remove Files from your Recent Files?")
-        }
-        alert.messageText = KMLocalizedString("The file will disappear from the recent list.")
-        alert.addButton(withTitle: KMLocalizedString("Delete"))
-        alert.addButton(withTitle: KMLocalizedString("Cancel"))
-        alert.showsSuppressionButton = true
-        let response = alert.runModal()
-        if response.rawValue == 1000 {
-            var selects: [URL] = []
-            if HistoryFilesManager.manager.selectFiles.count > 0 {
+            alert.messageText = KMLocalizedString("The file will disappear from the recent list.")
+            alert.addButton(withTitle: KMLocalizedString("Delete"))
+            alert.addButton(withTitle: KMLocalizedString("Cancel"))
+            alert.showsSuppressionButton = true
+            let response = alert.runModal()
+            if response.rawValue == 1000 {
+                var selects: [URL] = []
                 for selecturl in HistoryFilesManager.manager.selectFiles {
                     selects.append(selecturl)
                 }
-            } else {
+                
+                HistoryFilesManager.manager.historyFileDeleteAction(selects)
+                self.reloadData()
+                
+                if alert.suppressionButton?.state == .on {
+                    UserDefaults.standard.set("YES", forKey: "HomeFilesDeleteConfirmKey")
+                    UserDefaults.standard.synchronize()
+                }
+            }
+        } else {
+            //删除所有文件
+            let alert = NSAlert()
+            alert.alertStyle = .informational
+            alert.informativeText = KMLocalizedString("Remove Files from your Recent Files?")
+            alert.messageText = KMLocalizedString("The file will disappear from the recent list.")
+            alert.addButton(withTitle: KMLocalizedString("Delete"))
+            alert.addButton(withTitle: KMLocalizedString("Cancel"))
+            let response = alert.runModal()
+            if response.rawValue == 1000 {
+                var selects: [URL] = []
                 for selecturl in HistoryFilesManager.manager.files {
                     selects.append(selecturl)
                 }
-            }
-            HistoryFilesManager.manager.historyFileDeleteAction(selects)
-            self.reloadData()
-            
-            if alert.suppressionButton?.state == .on {
-                UserDefaults.standard.set("YES", forKey: "HomeFilesDeleteConfirmKey")
-                UserDefaults.standard.synchronize()
+                HistoryFilesManager.manager.historyFileDeleteAction(selects)
+                self.reloadData()
+                
             }
         }
+        
     }
     
     //MARK: - MouseEvent

+ 4 - 4
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/KMBackgroundManager.swift

@@ -451,16 +451,16 @@ class KMBackgroundManager: NSObject  {
     
     //MARK: - Get
     func fetchAvailableBackgroundName() -> String {
-        var availableIndex = 0
+        var availableIndex = 1
         
         for item in datas {
-            if item.name.hasPrefix("Background") {
-                if let index = Int(item.name.dropFirst("Background".count)), index >= availableIndex {
+            if item.name.hasPrefix("Background-") {
+                if let index = Int(item.name.dropFirst("Background-".count)), index >= availableIndex {
                     availableIndex = index + 1
                 }
             }
         }
         
-        return "Background\(availableIndex)"
+        return "Background-\(availableIndex)"
     }
 }

+ 2 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/KMBackgroundModel.swift

@@ -40,7 +40,7 @@ import Cocoa
         self.verticalSpace = 0
         self.horizontalSpace = 0
         self.backgroundID = NSString.tagString()
-        self.name = "Background0"
+        self.name = "Background-1"
         
     }
      
@@ -129,7 +129,7 @@ import Cocoa
             
             let contextCenter = NSPoint(x: rect.midX, y: rect.midY)
             context.translateBy(x: contextCenter.x, y: contextCenter.y)
-            context.rotate(by: radian)
+            context.rotate(by: -radian)
             context.translateBy(x: -contextCenter.x, y: -contextCenter.y)
          
             var red: CGFloat = 0

+ 11 - 4
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBackgroundPropertyController.swift

@@ -249,10 +249,17 @@ class KMBackgroundPropertyController: NSViewController {
             saveTemplateBGView.isHidden = true
             templateButton.properties.icon = NSImage(named: "edit_save")
             
-            if backgroundData.type == .image {
-                if backgroundData.imagePath == nil {
-                    templateButton.properties.isDisabled = true
-                }
+            var isChanged = false
+            if let dict = self.originalDataDict {
+                isChanged = KMBackgroundManager.compareIsChangedModel(backgroundData, withDict: dict as NSDictionary)
+            }
+            
+            if isChanged == false {
+                templateButton.properties.isDisabled = true
+            }
+            
+            if backgroundData.type == .image && backgroundData.imagePath == nil {
+                templateButton.properties.isDisabled = true
             }
         }
         templateButton.reloadData()

+ 12 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Bates/Views/KMBatesPropertyController.swift

@@ -259,11 +259,23 @@ class KMBatesPropertyController: NSViewController {
         leftTopButton.isHidden = true
         saveTemplateBGView.isHidden = false
         templateButton.properties.icon = NSImage(named: "icon_wm_template")
+        templateButton.properties.isDisabled = false
+        
         if editSubType == .edit {
             titleLabel.stringValue = KMLocalizedString("Edit Bates")
             leftTopButton.isHidden = false
             saveTemplateBGView.isHidden = true
             templateButton.properties.icon = NSImage(named: "edit_save")
+            
+            var didChanged = false
+            if let dict = self.originalDataDict {
+                didChanged = KMBatesManager.compareIsChangedModel(batesModel, withDict: dict as NSDictionary)
+            }
+            if didChanged == true {
+                templateButton.properties.isDisabled = false
+            } else {
+                templateButton.properties.isDisabled = true
+            }
         }
         templateButton.reloadData()
         

+ 10 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Watermark/Views/KMNWatermarkPropertyController.swift

@@ -325,6 +325,7 @@ class KMNWatermarkPropertyController: NSViewController {
         titleLabel.stringValue = KMLocalizedString("Add Watermark")
         leftTopButton.isHidden = true
         saveTemplateBGView.isHidden = false
+        templateButton.properties.isDisabled = false
         templateButton.properties.icon = NSImage(named: "icon_wm_template")
         typeTabsBGView.isHidden = false
         infoScrollTopConst.constant = 56
@@ -337,6 +338,15 @@ class KMNWatermarkPropertyController: NSViewController {
             leftTopButton.isHidden = false
             saveTemplateBGView.isHidden = true
             templateButton.properties.icon = NSImage(named: "edit_save")
+            var isChanged = false
+            if let dict = self.originalDataDict {
+                isChanged = KMWatermarkManager.compareIsChangedModel(watermarkData, withDict: dict as NSDictionary)
+            }
+            if isChanged {
+                templateButton.properties.isDisabled = false
+            } else {
+                templateButton.properties.isDisabled = true
+            }
         }
         templateButton.reloadData()
         

+ 7 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterController.swift

@@ -172,6 +172,13 @@ extension KMHeaderFooterController: KMHeaderPropertyControllerDelegate {
     }
     
     func headerFooterPropertyControllerSaveTemplateSuccess(_ controller: KMHeaderPropertyController, _ data: KMHeaderFooterModel) {
+        saveTemplateMessage.frame = CGRectMake((CGRectGetWidth(self.view.frame) - saveTemplateMessage.properties.propertyInfo.viewWidth)/2,
+                                               CGRectGetHeight(self.view.frame) - saveTemplateMessage.properties.propertyInfo.viewHeight - 8,
+                                               saveTemplateMessage.properties.propertyInfo.viewWidth,
+                                               saveTemplateMessage.properties.propertyInfo.viewHeight)
+        saveTemplateMessage.reloadData()
+        saveTemplateMessage.show(inView: self.view, autoHideSeconde: 2)
+        
         editSubType = .template
         resetUI()
         delegate?.kmHeaderFooterControllerDidUpdateModeType?(self)

+ 1 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/KMHeaderFooterManager.swift

@@ -262,7 +262,7 @@ class KMHeaderFooterManager: NSObject {
     
     //MARK: - Get
     func fetchHeaderFooterAvailableName() -> String {
-        var availableIndex = 0
+        var availableIndex = 1
         for item in headFooterObjects {
             if item.name.hasPrefix("HeaderFooter-") {
                 if let index = Int(item.name.dropFirst("HeaderFooter-".count)), index >= availableIndex {

+ 11 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/HeaderFooter/Views/KMHeaderPropertyController.swift

@@ -264,11 +264,22 @@ class KMHeaderPropertyController: NSViewController {
         leftTopButton.isHidden = true
         saveTemplateBGView.isHidden = false
         templateButton.properties.icon = NSImage(named: "icon_wm_template")
+        templateButton.properties.isDisabled = false
+
         if editSubType == .edit {
             titleLabel.stringValue = KMLocalizedString("Edit Header & Footer")
             leftTopButton.isHidden = false
             saveTemplateBGView.isHidden = true
             templateButton.properties.icon = NSImage(named: "edit_save")
+            var isChanged = false
+            if let dict = self.originalDataDict {
+                isChanged = KMHeaderFooterManager.compareIsChangedModel(headerFooterModel, withDict: dict as NSDictionary)
+            }
+            if isChanged == true {
+                templateButton.properties.isDisabled = false
+            } else {
+                templateButton.properties.isDisabled = true
+            }
         }
         templateButton.reloadData()
          

+ 73 - 18
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -139,6 +139,8 @@ struct KMNMWCFlags {
     
     var removeAllAnnotationsStore = KMPDFViewRemoveAllAnnotationsStore()
     
+    var componentMessageView: ComponentMessage = ComponentMessage()
+    
     private var _needSave = false
     var needSave: Bool {
         set {
@@ -729,10 +731,14 @@ struct KMNMWCFlags {
                 //密文
                 listView.annotationType = .redact
                 listView.toolMode = .CRedactToolMode
+                
+                self.enterRedactAlert()
             } else if subToolMode == .Digital_Sign {
                 //数字签名
                 listView.annotationType = .digitalSign
                 listView.toolMode = .CDigitalSignToolMode
+                
+                self.enterDigitalSignature()
             }
             
             
@@ -1125,14 +1131,13 @@ struct KMNMWCFlags {
         
         view.window?.makeFirstResponder(listView)
         
-        let readModeMessage: ComponentMessage = ComponentMessage()
-        readModeMessage.properties = ComponentMessageProperty(messageType: .normal_custom, title: KMLocalizedString("Read Mode On"))
-        readModeMessage.frame = CGRectMake((CGRectGetWidth(self.view.frame) - readModeMessage.properties.propertyInfo.viewWidth)/2,
-                                           CGRectGetHeight(self.view.frame) - readModeMessage.properties.propertyInfo.viewHeight - 8,
-                                           readModeMessage.properties.propertyInfo.viewWidth,
-                                           readModeMessage.properties.propertyInfo.viewHeight)
-        readModeMessage.reloadData()
-        readModeMessage.show(inView: self.view, autoHideSeconde: 2)
+        self.componentMessageView.properties = ComponentMessageProperty(messageType: .normal_custom, title: KMLocalizedString("Read Mode On"))
+        self.componentMessageView.frame = CGRectMake((CGRectGetWidth(self.view.frame) - self.componentMessageView.properties.propertyInfo.viewWidth)/2,
+                                                     CGRectGetHeight(self.view.frame) - self.componentMessageView.properties.propertyInfo.viewHeight - 8,
+                                                     self.componentMessageView.properties.propertyInfo.viewWidth,
+                                                     self.componentMessageView.properties.propertyInfo.viewHeight)
+        self.componentMessageView.reloadData()
+        self.componentMessageView.show(inView: self.view, autoHideSeconde: 2)
         
         setUpPDFPageNumberToolbar()
         
@@ -1164,14 +1169,13 @@ struct KMNMWCFlags {
         reloadPDFPageNumberToolbar()
         
         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
-            let readModeMessage: ComponentMessage = ComponentMessage()
-            readModeMessage.properties = ComponentMessageProperty(messageType: .normal_custom, title: KMLocalizedString("Read Mode Off"))
-            readModeMessage.frame = CGRectMake((CGRectGetWidth(self.infoSplitCenterView.frame) - readModeMessage.properties.propertyInfo.viewWidth)/2,
-                                               CGRectGetHeight(self.infoSplitCenterView.frame) - readModeMessage.properties.propertyInfo.viewHeight - 8,
-                                               readModeMessage.properties.propertyInfo.viewWidth,
-                                               readModeMessage.properties.propertyInfo.viewHeight)
-            readModeMessage.reloadData()
-            readModeMessage.show(inView: self.infoSplitCenterView, autoHideSeconde: 2)
+            self.componentMessageView.properties = ComponentMessageProperty(messageType: .normal_custom, title: KMLocalizedString("Read Mode Off"))
+            self.componentMessageView.frame = CGRectMake((CGRectGetWidth(self.infoSplitCenterView.frame) - self.componentMessageView.properties.propertyInfo.viewWidth)/2,
+                                               CGRectGetHeight(self.infoSplitCenterView.frame) - self.componentMessageView.properties.propertyInfo.viewHeight - 8,
+                                                         self.componentMessageView.properties.propertyInfo.viewWidth,
+                                                         self.componentMessageView.properties.propertyInfo.viewHeight)
+            self.componentMessageView.reloadData()
+            self.componentMessageView.show(inView: self.infoSplitCenterView, autoHideSeconde: 2)
         }
     }
     
@@ -1533,6 +1537,24 @@ struct KMNMWCFlags {
         signaturestateVC.reloadData()
     }
     
+    func enterDigitalSignature() {
+        if UserDefaults.standard.object(forKey: "kDigitalSignature") != nil {
+            return
+        }
+        let alert = NSAlert()
+        alert.alertStyle = .informational
+        alert.messageText = KMLocalizedString("Using your mouse, click and drag to draw the area where you would like the signature to appear. Once you finish dragging out the desired area, you will be taken to the next step of the signing process. ")
+        alert.addButton(withTitle: KMLocalizedString("OK"))
+        alert.showsSuppressionButton = true
+        let response = alert.runModal()
+        if response.rawValue == 1000 {
+            if alert.suppressionButton?.state == .on {
+                UserDefaults.standard.set("YES", forKey: "kDigitalSignature")
+                UserDefaults.standard.synchronize()
+            }
+        }
+    }
+    
     
     // MARK: - 显示合并窗口
     public func showMergeWindow(url: URL? = nil, _ password: String?) {
@@ -3490,6 +3512,8 @@ extension KMMainViewController {
                     self.showCompress(model: model)
                 }
             }
+        } else {
+            self.showCompress(model: model)
         }
     }
     
@@ -3598,16 +3622,21 @@ extension KMMainViewController {
     
     //OCR
     func convertOCRScanFile(window: KMOCRSettingWindowController, document: CPDFDocument, model: KMOCRModel) {
-        window.beginLoading()
+//        window.beginLoading()
         
+        KMCompressManager.shared.showLoadingWindow(window: window.window)
+        KMCompressManager.shared.cancelAction = {
+            KMOCRManager.manager.cancelRecognition()
+        }
         //当前页面需要提前设置
         if model.pageRangeType == .current {
             model.pageRange = [self.listView.currentPageIndex]
         }
         
         KMOCRManager.manager.convertScanFile(document: document, model: model, progress: { progress in
-            
+            KMCompressManager.shared.updateLoadingProgress(value: progress)
         }) { [weak self] document, text, error in
+            KMCompressManager.shared.dismissLoadiingWindow(window: window.window)
             window.endLoading()
             window.km_quick_endSheet()
             if !model.saveAsPDF {
@@ -3946,6 +3975,8 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
                 viewManager.showRightSide = false
             } else if SettingsManager.sharedInstance.autoExpandPropertyPanel == true {
                 viewManager.showRightSide = true
+            } else if viewManager.subToolMode == .Stamp || viewManager.subToolMode == .Sign {
+                viewManager.showRightSide = true
             }
             self.refreshToolbarRightViewInfo()
             
@@ -7340,6 +7371,30 @@ extension KMMainViewController {
         }
     }
     
+    func enterRedactAlert() {
+        if UserDefaults.standard.object(forKey: "kRedact") != nil {
+            return
+        }
+        let alert = NSAlert()
+        alert.alertStyle = .informational
+        alert.informativeText = KMLocalizedString("Redaction allows you to permanently mask and remove sensitive content.")
+        alert.messageText = KMLocalizedString("""
+                                              Redaction requires two steps:
+                                              1. Mark for Redaction
+                                              2. Apply Redactions
+
+                                              Note: Redactions are not applied permanently until you select Apply Redactions.
+                                              """)
+        alert.addButton(withTitle: KMLocalizedString("OK"))
+        alert.showsSuppressionButton = true
+        let response = alert.runModal()
+        if response.rawValue == 1000 {
+            if alert.suppressionButton?.state == .on {
+                UserDefaults.standard.set("YES", forKey: "kRedact")
+                UserDefaults.standard.synchronize()
+            }
+        }
+    }
     
     // MARK: - 保存文档
     internal func needSaveDocument() -> Bool {

+ 16 - 16
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Pen/KMPenController.swift

@@ -181,7 +181,7 @@ class KMPenController: NSViewController {
             }
             lineTypeSelector.reloadData()
             
-            let percent = border.lineWidth/18
+            let percent = (border.lineWidth - 1)/17
             lineWidthSlider.properties.percent = percent
             lineWidthSlider.reloadData()
             
@@ -199,7 +199,7 @@ class KMPenController: NSViewController {
                         break
                     }
                 }
-                let percent: CGFloat = CGFloat(dash)/18
+                let percent: CGFloat = (CGFloat(dash) - 1)/17
                 lineDashSlider.properties.percent = percent
                 lineDashSlider.reloadData()
                 
@@ -229,7 +229,7 @@ class KMPenController: NSViewController {
             }
             lineTypeSelector.reloadData()
             
-            let percent = border.lineWidth/18
+            let percent = (border.lineWidth - 1)/17
             lineWidthSlider.properties.percent = percent
             lineWidthSlider.reloadData()
             
@@ -247,7 +247,7 @@ class KMPenController: NSViewController {
                         break
                     }
                 }
-                let percent: CGFloat = CGFloat(dash)/18
+                let percent: CGFloat = (CGFloat(dash) - 1)/17
                 lineDashSlider.properties.percent = percent
                 lineDashSlider.reloadData()
                 
@@ -324,7 +324,7 @@ class KMPenController: NSViewController {
                 } else {
                     let border: CPDFBorder = annotation.border ?? CPDFBorder()
                     
-                    let percent = border.lineWidth/18
+                    let percent = (border.lineWidth - 1)/17
                     lineWidthSlider.properties.percent = percent
                     lineWidthSlider.reloadData()
                     
@@ -349,7 +349,7 @@ class KMPenController: NSViewController {
                         }
                     }
                     
-                    let percent = dashA/18
+                    let percent = (dashA - 1)/17
                     lineDashSlider.properties.percent = percent
                     lineDashSlider.reloadData()
                     
@@ -398,12 +398,12 @@ extension KMPenController: ComponentSliderDelegate {
             CPDFInkAnnotation.updateDefault_Opacity(opacity)
             
         } else if view == lineWidthSlider {
-            let value = view.properties.percent * 18
+            let value = view.properties.percent * 17 + 1
             CPDFAnnotation.updateAnnotations(annotations, newLineWidth: value, withPDFView: pdfView)
             CPDFInkAnnotation.updateDefault_LineWidth(value)
             
         } else if view == lineDashSlider {
-            let value = view.properties.percent * 18
+            let value = view.properties.percent * 17 + 1
             CPDFAnnotation.updateAnnotations(annotations, newDashPattern: value, withPDFView: pdfView)
             CPDFInkAnnotation.updateDefault_DashPattern(value)
             
@@ -425,8 +425,8 @@ extension KMPenController: ComponentSelectDelegate {
                 var value = result.stringToCGFloat()
                 if value > 18 {
                     value = 18
-                } else if value < 0 {
-                    value = 0
+                } else if value < 1 {
+                    value = 1
                 }
                 CPDFAnnotation.updateAnnotations(annotations, newLineWidth: value, withPDFView: pdfView)
                 CPDFInkAnnotation.updateDefault_LineWidth(value)
@@ -435,8 +435,8 @@ extension KMPenController: ComponentSelectDelegate {
                 var value = result.stringToCGFloat()
                 if value > 18 {
                     value = 18
-                } else if value < 0 {
-                    value = 0
+                } else if value < 1 {
+                    value = 1
                 }
                 CPDFAnnotation.updateAnnotations(annotations, newDashPattern: value, withPDFView: pdfView)
                 CPDFInkAnnotation.updateDefault_DashPattern(value)
@@ -459,8 +459,8 @@ extension KMPenController: ComponentSelectDelegate {
                 var value = result.stringToCGFloat()
                 if value > 18 {
                     value = 18
-                } else if value < 0 {
-                    value = 0
+                } else if value < 1 {
+                    value = 1
                 }
                 CPDFAnnotation.updateAnnotations(annotations, newLineWidth: value, withPDFView: pdfView)
                 CPDFInkAnnotation.updateDefault_LineWidth(value)
@@ -469,8 +469,8 @@ extension KMPenController: ComponentSelectDelegate {
                 var value = result.stringToCGFloat()
                 if value > 18 {
                     value = 18
-                } else if value < 0 {
-                    value = 0
+                } else if value < 1 {
+                    value = 1
                 }
                 CPDFAnnotation.updateAnnotations(annotations, newDashPattern: value, withPDFView: pdfView)
                 CPDFInkAnnotation.updateDefault_DashPattern(value)

+ 6 - 8
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/CreateSignWindowController/KMCreateSignWindowController.swift

@@ -188,7 +188,11 @@ class KMCreateSignWindowController: KMNBaseWindowController {
             clear()
         } else if button == createButton {
             if let value = self.createSignature() {
+                KMSignatureManager.manager.addSignature(value)
+                KMSignatureManager.manager.saveSingaturesToFile()
+                
                 delegate?.kmCreateSignWindowControllerDidCreate?(self, value)
+                
             }
             clear()
         }
@@ -208,10 +212,7 @@ class KMCreateSignWindowController: KMNBaseWindowController {
             
             signature.pathsImage = image
             signature.signatureType = .text
-            
-            KMSignatureManager.manager.addSignature(signature)
-            KMSignatureManager.manager.saveSingaturesToFile()
-            
+             
         } else if self.signType == .image {
             guard let image = self.signImageView?.resultImage else {
                 let alert = NSAlert()
@@ -222,7 +223,7 @@ class KMCreateSignWindowController: KMNBaseWindowController {
             }
             signature.pathsImage = image
             signature.signatureType = .image
-            
+             
         } else if self.signType == .ink {
             guard let image = self.signDrawView?.resultImage else {
                 let alert = NSAlert()
@@ -237,9 +238,6 @@ class KMCreateSignWindowController: KMNBaseWindowController {
             signature.signatureType = .ink
             signature.signatureColor = self.signDrawView?.drawView?.drawColor ?? NSColor.black
             signature.pathsImage = image
-             
-            KMSignatureManager.manager.addSignature(signature)
-            KMSignatureManager.manager.saveSingaturesToFile()
             
         }
         return signature

+ 23 - 4
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/KMSignatureListController.swift

@@ -13,6 +13,7 @@ class KMSignatureListController: NSViewController {
     @IBOutlet var scrollView: NSScrollView!
     @IBOutlet var collectionView: NSCollectionView!
    
+    @IBOutlet var emptyView: ComponentEmpty!
     private var createSignWC: KMCreateSignWindowController = KMCreateSignWindowController(windowNibName: "KMCreateSignWindowController")
     
     private var allObjects: [KMSignature] = []
@@ -43,8 +44,10 @@ class KMSignatureListController: NSViewController {
         reloadData()
     }
      
-    func setupProperty() {
- 
+    func setupProperty() { 
+       emptyView.properties = ComponentEmptyProperty(emptyType: .noSign,
+                                                     text: KMLocalizedString("No Signature"),
+                                                     subText: KMLocalizedString("Here is the description."))
     }
     
     func reloadUI() {
@@ -60,8 +63,16 @@ class KMSignatureListController: NSViewController {
         for signature in KMSignatureManager.manager.signatureList {
             self.allObjects.append(signature)
         }
-      
-        self.collectionView.reloadData()
+        
+        if self.allObjects.count == 0 {
+            self.scrollView.isHidden = true
+            self.emptyView.isHidden = false
+        } else {
+            self.scrollView.isHidden = false
+            self.emptyView.isHidden = true
+            
+            self.collectionView.reloadData()
+        }
     }
     
     private func collectionViewSelectedChanged() {
@@ -148,6 +159,14 @@ extension KMSignatureListController: KMCreateSignWindowControllerDelegate {
         
         self.selectedObject = signature
         
+        if self.allObjects.isEmpty == false {
+            let indexpath = IndexPath(item: 0, section: 0)
+            var set = Set<IndexPath>()
+            set.insert(indexpath)
+            self.collectionView.selectItems(at: set, scrollPosition: .top)
+            
+            self.collectionViewSelectedChanged()
+        }
     }
 }
 

+ 10 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/KMSignatureListController.xib

@@ -9,6 +9,7 @@
         <customObject id="-2" userLabel="File's Owner" customClass="KMSignatureListController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="collectionView" destination="OLK-21-odJ" id="pwi-dH-pBY"/>
+                <outlet property="emptyView" destination="bEi-EB-0Mg" id="bUY-5A-tur"/>
                 <outlet property="scrollView" destination="0Ot-qZ-lNC" id="EuP-vp-0nv"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
             </connections>
@@ -50,9 +51,18 @@
                                         <autoresizingMask key="autoresizingMask"/>
                                     </scroller>
                                 </scrollView>
+                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="bEi-EB-0Mg" customClass="ComponentEmpty" customModule="KMComponentLibrary">
+                                    <rect key="frame" x="96" y="141" width="232" height="184"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="184" id="p36-Vv-l2g"/>
+                                        <constraint firstAttribute="width" constant="232" id="tub-Ve-ayS"/>
+                                    </constraints>
+                                </customView>
                             </subviews>
                             <constraints>
                                 <constraint firstItem="0Ot-qZ-lNC" firstAttribute="top" secondItem="RgJ-CA-Q5a" secondAttribute="top" id="7Xj-5W-piO"/>
+                                <constraint firstItem="bEi-EB-0Mg" firstAttribute="centerX" secondItem="RgJ-CA-Q5a" secondAttribute="centerX" id="9sz-iB-v53"/>
+                                <constraint firstItem="bEi-EB-0Mg" firstAttribute="centerY" secondItem="RgJ-CA-Q5a" secondAttribute="centerY" id="B5O-xc-Akg"/>
                                 <constraint firstAttribute="trailing" secondItem="0Ot-qZ-lNC" secondAttribute="trailing" id="b1F-oU-uX8"/>
                                 <constraint firstAttribute="bottom" secondItem="0Ot-qZ-lNC" secondAttribute="bottom" id="d6F-WF-BPx"/>
                                 <constraint firstItem="0Ot-qZ-lNC" firstAttribute="leading" secondItem="RgJ-CA-Q5a" secondAttribute="leading" id="yvt-QY-NX8"/>

+ 1 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Signature/KMSignatureManager.swift

@@ -61,7 +61,7 @@ import Foundation
     }
     
     @objc func addSignature(_ signature: KMSignature) {
-        signatureList.append(signature)
+        signatureList.insert(signature, at: 0)
         
         saveSingaturesToFile()
     }

+ 11 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/StampList/KMStampListController.swift

@@ -48,6 +48,17 @@ class KMStampListController: NSViewController {
         
         createStampWC.infoUpdateCallback = { [weak self] update in
             self?.reloadData()
+            
+            if update {
+                if self?.stampObjects.isEmpty == false {
+                    let indexpath = IndexPath(item: 0, section: 0)
+                    var set = Set<IndexPath>()
+                    set.insert(indexpath)
+                    self?.collectionView.selectItems(at: set, scrollPosition: .top)
+                    
+                    self?.collectionViewSelectedChanged()
+                }
+            }
         }
         
         reloadUI()

+ 3 - 3
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/StampList/KMStampManager.swift

@@ -504,7 +504,7 @@ struct KMPDFAnnotationSignatureType: OptionSet {
         
         if (newDictionary as NSDictionary).write(toFile: kStampPlistPath.path, atomically: true), let stamp = stamp {
             stamp.stampKey = tag
-            stamps.append(stamp)
+            stamps.insert(stamp, at: 0)
             return true
         }
         
@@ -554,7 +554,7 @@ struct KMPDFAnnotationSignatureType: OptionSet {
                     
                     if (newDictionary as NSDictionary).write(toFile: kStampPlistPath.path, atomically: true) {
                         stamp.stampKey = tag
-                        stamps.append(stamp)
+                        stamps.insert(stamp, at: 0)
                         return true
                     }
                 } else {
@@ -574,7 +574,7 @@ struct KMPDFAnnotationSignatureType: OptionSet {
                     
                     if (newDictionary as NSDictionary).write(toFile: kStampPlistPath.path, atomically: true) {
                         stamp.stampKey = tag
-                        stamps.append(stamp)
+                        stamps.insert(stamp, at: 0)
                         return true
                     }
                 }

+ 77 - 7
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift

@@ -933,7 +933,14 @@ extension KMPDFToolbarController: ComponentDropdownToolDelegate {
                 viewManager.viewToolsType = .AreaZoom
             }
             if viewManager.viewToolsType != .Select {
-                viewManager.toolMode = .None
+                if viewManager.toolMode != .None {
+                    cancelSelectedSecondToolbarItems(viewManager.toolMode)
+                    
+                    viewManager.toolMode = .None
+                    viewManager.subToolMode = .None
+                    
+                    delegate?.kmPDFToolbarControllerDidToolModeChanged?(self)
+                }
                 
                 reloadToolbarTabsView()
             }
@@ -1286,14 +1293,17 @@ extension KMPDFToolbarController: KMRedactToolbarControllerDelegate {
             delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Property_Identifier)
             
         } else if buttonIndex == 2 {
-            viewManager?.subToolMode = .None
-            cancelSelectedSecondToolbarItems(.Protect)
-            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Apply_Identifier)
+            self.applyRedactAlert()
+            
+//            viewManager?.subToolMode = .None
+//            cancelSelectedSecondToolbarItems(.Protect)
+//            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Apply_Identifier)
             
         } else if buttonIndex == 3 {
-            viewManager?.subToolMode = .None
-            cancelSelectedSecondToolbarItems(.Protect)
-            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
+            self.exitRedactAlert()
+//            viewManager?.subToolMode = .None
+//            cancelSelectedSecondToolbarItems(.Protect)
+//            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
             
         }
         
@@ -1301,4 +1311,64 @@ extension KMPDFToolbarController: KMRedactToolbarControllerDelegate {
         
         
     }
+    
+    func exitRedactAlert() {
+        if UserDefaults.standard.object(forKey: "kExitRedactAlert") != nil {
+            return
+        }
+        let alert = NSAlert()
+        alert.alertStyle = .informational
+//        alert.informativeText = KMLocalizedString("Redaction allows you to permanently mask and remove sensitive content.")
+        alert.messageText = KMLocalizedString("""
+                                              There are unapplied redactions in this file. Any content associated with them will not be redacted until applied.
+                                              """)
+        alert.addButton(withTitle: KMLocalizedString("Exit"))
+        alert.addButton(withTitle: KMLocalizedString("Cancel"))
+        alert.showsSuppressionButton = true
+        let response = alert.runModal()
+        if response.rawValue == 1000 {
+            if alert.suppressionButton?.state == .on {
+                UserDefaults.standard.set("YES", forKey: "kExitRedactAlert")
+                UserDefaults.standard.synchronize()
+            }
+            
+            //退出
+            viewManager?.subToolMode = .None
+            cancelSelectedSecondToolbarItems(.Protect)
+            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
+        } else if response.rawValue == 1001 {
+            //取消
+            
+        }
+    }
+    
+    func applyRedactAlert() {
+        if UserDefaults.standard.object(forKey: "kApplyRedactAlert") != nil {
+            return
+        }
+        let alert = NSAlert()
+        alert.alertStyle = .informational
+        alert.messageText = KMLocalizedString("This action will permanently remove the redacted information from this document.")
+        alert.informativeText = KMLocalizedString("""
+                                              After you save this document, you will not be able to retrieve the redacted information.
+                                              """)
+        alert.addButton(withTitle: KMLocalizedString("Apply"))
+        alert.addButton(withTitle: KMLocalizedString("Cancel"))
+        alert.showsSuppressionButton = true
+        let response = alert.runModal()
+        if response.rawValue == 1000 {
+            if alert.suppressionButton?.state == .on {
+                UserDefaults.standard.set("YES", forKey: "kApplyRedactAlert")
+                UserDefaults.standard.synchronize()
+            }
+            
+            //应用
+            viewManager?.subToolMode = .None
+            cancelSelectedSecondToolbarItems(.Protect)
+            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Apply_Identifier)
+        } else if response.rawValue == 1001 {
+            //取消
+            
+        }
+    }
 }

+ 5 - 5
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/Model/KMPDFToolbarManager.swift

@@ -186,7 +186,7 @@ class KMPDFToolbarManager: NSObject {
     
     let convert_imageToPDF_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("Image to PDF"), icon: NSImage(named: "convert_imageToPdf"), keepPressState: false,identifier: KMPDFToolbar_convert_imageToPDF_Identifier)
     
-    let convert_ocr_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("OCR"), icon: NSImage(named: "convert_ocr"), identifier: KMPDFToolbar_convert_ocr_Identifier)
+//    let convert_ocr_Property = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, showLeftIcon: true, buttonText: KMLocalizedString("OCR"), icon: NSImage(named: "convert_ocr"), identifier: KMPDFToolbar_convert_ocr_Identifier)
     
     var convert_RTF_property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "convert_rtf"), keyEquivalent: nil, text: KMLocalizedString("To RTF"), identifier: KMPDFToolbar_convert_RTF_Identifier)
     var convert_CSV_property: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, lefticon: NSImage(named: "convert_csv"), keyEquivalent: nil, text: KMLocalizedString("To CSV"), identifier: KMPDFToolbar_convert_CSV_Identifier)
@@ -393,8 +393,8 @@ class KMPDFToolbarManager: NSObject {
                                     convert_excel_Property.identifier,
                                     convert_ppt_Property.identifier,
                                     convert_image_Property.identifier,
-                                    convert_imageToPDF_Property.identifier,
-                                    convert_ocr_Property.identifier])
+                                    convert_imageToPDF_Property.identifier
+                                    /*,convert_ocr_Property.identifier*/])
             
         } else if mainIdentify == KMPDFToolbar_Protect_Identifier {
             ids.append(contentsOf: [KMPDFToolbar_protect_redact_Property_Identifier, 
@@ -513,8 +513,8 @@ class KMPDFToolbarManager: NSObject {
                 convert_others_Property.menuItemArr = menuItemArr
             }
             return [convert_word_Property, convert_excel_Property, convert_ppt_Property, convert_image_Property,
-                    convert_others_Property, dividerProperty, convert_imageToPDF_Property, dividerProperty,
-                    convert_ocr_Property]
+                    convert_others_Property, dividerProperty, convert_imageToPDF_Property/*, dividerProperty,
+                    convert_ocr_Property*/]
             
         } else if modeType == .Protect {
             return [protect_redact_Property, protect_security_Property, protect_removeSecurity_Property, protect_digitalSign_Property]

+ 13 - 4
PDF Office/PDF Master/KMClass/NewBatch/Manager/KMBatchManager.swift

@@ -716,13 +716,22 @@ extension KMBatchManager {
                     processFile(at: 0, outputFolderPath: outputFolderPath, data: data)
                 }
             } else {
-                var fileName = data.selectFilePath.deletingPathExtension.lastPathComponent
-                let path = self.fetchFilePath(type: .imageToPDF, filePath: data.selectFilePath, outputFolderPath: outputFolderPath)
+                let selectFilePath = data.selectFilePath
+                if selectFilePath.count == 0 {
+                    let alert = NSAlert()
+                    alert.alertStyle = .critical
+                    alert.messageText = KMLocalizedString("文件未选择")
+                    alert.runModal()
+                    return
+                }
+                
+                var fileName = selectFilePath.deletingPathExtension.lastPathComponent
+                let path = self.fetchFilePath(type: .imageToPDF, filePath: selectFilePath, outputFolderPath: outputFolderPath)
                 
-                var pdfDocument = CPDFDocument(url: NSURL(fileURLWithPath: data.selectFilePath) as URL)
+                var pdfDocument = CPDFDocument(url: NSURL(fileURLWithPath: selectFilePath) as URL)
                 let count: Int = Int(pdfDocument?.pageCount ?? 0)
                 for item in filesData {
-                    pdfDocument?.km_insert(image: item.image, at: pdfDocument?.pageCount ?? 0)
+                    pdfDocument?.km_insert(image: item.image, at: UInt(count))
                 }
                 
                 if data.isOCR {

+ 2 - 2
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/KMBatchProcessingTableView.swift

@@ -567,7 +567,7 @@ extension KMBatchProcessingTableView {
         menus.popUp(positioning: nil, at: point, in: view)
     }
     
-    @objc func showInFinder(sender: KMBatchProcessingTableRowView) {
+    @objc func showInFinder() {
         if self.selectModels.count != 0 {
             for model in self.selectModels {
                 if FileManager.default.fileExists(atPath: model.filePath) {
@@ -577,7 +577,7 @@ extension KMBatchProcessingTableView {
         }
     }
     
-    @objc func removeItem(sender: KMBatchProcessingTableRowView) {
+    @objc func removeItem() {
         self.presenter.deleteData(models: self.selectModels)
     }
 }

+ 2 - 2
PDF Office/PDF Master/KMClass/NewBatch/View/KMBatchProcessingView/Tableview/Views/Tableview/Views/KMBatchProcessingNameTableCell.xib

@@ -26,7 +26,7 @@
                     <constraints>
                         <constraint firstAttribute="height" constant="20" id="H0s-Nl-EiE"/>
                     </constraints>
-                    <textFieldCell key="cell" lineBreakMode="truncatingTail" enabled="NO" title="文件名.png" id="duv-uD-WWq">
+                    <textFieldCell key="cell" lineBreakMode="truncatingMiddle" enabled="NO" title="文件名.png" id="duv-uD-WWq">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -61,7 +61,7 @@
                 <constraint firstItem="5ya-vD-YSW" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="dp9-du-KDu"/>
                 <constraint firstItem="5ya-vD-YSW" firstAttribute="leading" secondItem="9BP-LK-TK6" secondAttribute="trailing" constant="4" id="gKw-Mg-2Xr"/>
                 <constraint firstItem="9BP-LK-TK6" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="56" id="ga0-4I-Vkl"/>
-                <constraint firstItem="9BP-LK-TK6" firstAttribute="width" relation="lessThanOrEqual" secondItem="c22-O7-iKe" secondAttribute="width" multiplier="0.8" id="gbo-oe-34t"/>
+                <constraint firstItem="9BP-LK-TK6" firstAttribute="width" relation="lessThanOrEqual" secondItem="c22-O7-iKe" secondAttribute="width" multiplier="0.7" id="gbo-oe-34t"/>
                 <constraint firstItem="c1u-iG-YM2" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="jug-b2-4DS"/>
             </constraints>
             <point key="canvasLocation" x="-109" y="190"/>

+ 9 - 0
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/ImageToPDF/KMBatchImageToPDFView.swift

@@ -284,6 +284,15 @@ extension KMBatchImageToPDFView {
     @objc func saveButtonClicked(_ sender: ComponentButton) {
         self.model.selectFilePath = self.selectFileInputButton.properties.text
         
+        let selectFilePath = self.model.selectFilePath
+        if selectFilePath.count == 0 {
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = KMLocalizedString("文件未选择")
+            alert.runModal()
+            return
+        }
+        
         guard let callBack = self.batchExport else { return }
         
         callBack(self, model)

+ 2 - 2
PDF Office/PDF Master/KMClass/Settings/SettingsDisplayView.swift

@@ -261,12 +261,12 @@ class SettingsDisplayView: BaseXibView {
         autoExpandPropertyPanelCheckbox.properties = ComponentCheckBoxProperty(size: .s,
                                                                  state: .normal,
                                                                  isDisabled: false,
-                                                                 showhelp: false,
+                                                                 showhelp: true,
                                                                  text: KMLocalizedString("Automatically expand the properties panel"),
                                                                  checkboxType: SettingsManager.sharedInstance.showQuickActionBar ? .selected : .normal)
         autoExpandPropertyPanelCheckbox.setTarget(self, action: #selector(propertyPanelAction(_:)))
+        autoExpandPropertyPanelCheckbox.toolTip = KMLocalizedString("If you don't want the automatic expansion mode to interfere with your immersive reading experience, you can turn this option off. You can still click the \"Properties\" icon to expand the panel when you need it (⌥⌘0).")
         propertyPanelWidthConst.constant = autoExpandPropertyPanelCheckbox.properties.propertyInfo.viewWidth
-    
         
         showQuickCheckbox.properties = ComponentCheckBoxProperty(size: .s,
                                                                  state: .normal,

+ 1 - 0
PDF Office/PDF Master/KMClass/Tools/Category/AppKit/NSDocumentController+KMExtension.swift

@@ -31,6 +31,7 @@ extension NSDocumentController {
             }
             completionHandler(document, isOpened, error)
         }
+        KMFileThumbManager.manager.updateFile(url)
     }
     
     func alreadyOpenDocument(url: URL) -> Bool{

+ 1 - 1
PDF Office/PDF Master/KMClass/Tools/Category/Foundation/String+KMExtensions.swift

@@ -128,7 +128,7 @@ extension String {
         return true
     }
     
-    
+    // MARK: 移除文件后缀名
     static func deletingPathExtension(_ string: String) -> String {
         return NSString(string: string).deletingPathExtension
     }

+ 1 - 1
PDF Office/PDF Master/KMClass/Tools/Category/NSWindowController+Extension/NSWindowController+Extension.swift

@@ -10,7 +10,7 @@ import Foundation
 extension NSWindowController {
      
     //MARK: - show方法,确保居中显示
-    func showKMWindow(_ sender: Any?) {
+    func showWindowInCenter(_ sender: Any?) {
         self.window?.center()
         
         self.showWindow(sender)

+ 2 - 1
PDF Office/PDF Master/KMClass/Tools/Tool/KMTools.swift

@@ -334,7 +334,7 @@ let APP_Terms_Of_Service_URL = NSLocalizedString("https://www.pdfreaderpro.com/t
 extension KMTools {
     // 打开 [快速教学]
     @objc class func openQuickStartStudy() {
-        var fileName = NSLocalizedString("Quick Start Guide.pdf", comment: "")
+        var fileName = KMLocalizedString("Quick Start Guide.pdf")
         let fileType = "pdf"
         
         let path = Bundle.main.path(forResource: fileName, ofType: "")
@@ -342,6 +342,7 @@ extension KMTools {
             KMTools.openURL(url: URL(string: "https://www.pdfreaderpro.com/help"))
             return
         }
+        fileName = String.deletingPathExtension(fileName)
         
         let version = KMTools.getAppVersion()
         fileName.append(" v\(version).\(fileType)")