Browse Source

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

jiajie 1 year ago
parent
commit
dd702ef637
24 changed files with 811 additions and 765 deletions
  1. 8 24
      PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  2. 41 18
      PDF Office/PDF Master/Class/Common/Category/NSView+KMExtension.swift
  3. 8 2
      PDF Office/PDF Master/Class/Common/Category/NSWindow+KMExtension.swift
  4. 54 136
      PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Cell/KMHomeHistoryCollectionItem.swift
  5. 29 27
      PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Cell/KMHomeHistoryCollectionItem.xib
  6. 29 7
      PDF Office/PDF Master/Class/Home/View/HomeContentView/History/KMHomeHistoryListView.swift
  7. 1 1
      PDF Office/PDF Master/Class/Home/View/HomeContentView/History/KMHomeHistoryListView.xib
  8. 112 1
      PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Model/KMHomeHistoryListViewModel.swift
  9. 67 17
      PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift
  10. 31 17
      PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.xib
  11. 76 7
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift
  12. 9 0
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/Model/KMQucikToolsModel.swift
  13. 27 7
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift
  14. 11 28
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift
  15. 0 116
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+UI.swift
  16. 31 91
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift
  17. 35 35
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.xib
  18. 31 5
      PDF Office/PDF Master/Class/KMAdvertisement/View/Tableview/Cell/KMAdvertisementCollectionViewItem.swift
  19. 3 0
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarController.swift
  20. 129 218
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift
  21. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarView.swift
  22. 60 3
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift
  23. 8 2
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/PublicKey.swift
  24. 10 2
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

+ 8 - 24
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -244,34 +244,34 @@
             landmarkType = "7">
             <Locations>
                <Location
-                  uuid = "4AA5DDA9-7119-40D7-89B4-F368372F819A - 12bb4aebd717cd8"
+                  uuid = "4AA5DDA9-7119-40D7-89B4-F368372F819A - 844f8b9c5ebe0774"
                   shouldBeEnabled = "Yes"
                   ignoreCount = "0"
                   continueAfterRunningActions = "No"
-                  symbolName = "function signature specialization &lt;Arg[1] = Dead&gt; of PDF_Master_DMG.KMEditPDFTextManager.setFontAlignment(alignment: __C.NSTextAlignment) -&gt; ()"
-                  moduleName = "PDF Master DMG"
+                  symbolName = "PDF_Master.KMEditPDFTextManager.setFontAlignment(alignment: __C.NSTextAlignment) -&gt; ()"
+                  moduleName = "PDF Master"
                   usesParentBreakpointCondition = "Yes"
                   urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/RightSide/EditPDF/Manager/KMEditPDFTextManager.swift"
                   startingColumnNumber = "9223372036854775807"
                   endingColumnNumber = "9223372036854775807"
                   startingLineNumber = "332"
                   endingLineNumber = "332"
-                  offsetFromSymbolStart = "81">
+                  offsetFromSymbolStart = "186">
                </Location>
                <Location
-                  uuid = "4AA5DDA9-7119-40D7-89B4-F368372F819A - 12bb4aebd717cd8"
+                  uuid = "4AA5DDA9-7119-40D7-89B4-F368372F819A - 844f8b9c5ebe0774"
                   shouldBeEnabled = "Yes"
                   ignoreCount = "0"
                   continueAfterRunningActions = "No"
-                  symbolName = "function signature specialization &lt;Arg[1] = Dead&gt; of PDF_Master_DMG.KMEditPDFTextManager.setFontAlignment(alignment: __C.NSTextAlignment) -&gt; ()"
-                  moduleName = "PDF Master DMG"
+                  symbolName = "PDF_Master.KMEditPDFTextManager.setFontAlignment(alignment: __C.NSTextAlignment) -&gt; ()"
+                  moduleName = "PDF Master"
                   usesParentBreakpointCondition = "Yes"
                   urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/RightSide/EditPDF/Manager/KMEditPDFTextManager.swift"
                   startingColumnNumber = "9223372036854775807"
                   endingColumnNumber = "9223372036854775807"
                   startingLineNumber = "332"
                   endingLineNumber = "332"
-                  offsetFromSymbolStart = "114">
+                  offsetFromSymbolStart = "299">
                </Location>
             </Locations>
          </BreakpointContent>
@@ -340,22 +340,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "BA35DAFD-2DD8-4E4C-9E39-70FC85E0D7C4"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/Toolbar/KMToolbarView.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "113"
-            endingLineNumber = "113"
-            landmarkName = "_moreButtonAction()"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent

+ 41 - 18
PDF Office/PDF Master/Class/Common/Category/NSView+KMExtension.swift

@@ -117,6 +117,25 @@ extension NSView {
     }
 }
 
+// MARK: - KMExtension
+
+extension NSView {
+    func isElderView(to sv: NSView?) -> Bool {
+        guard let _sv = sv else {
+            return false
+        }
+        
+        var ev = _sv.superview
+        while let _ev = ev {
+            if _ev.isEqual(to: self) {
+                return true
+            }
+            ev = _ev.superview
+        }
+        return false
+    }
+}
+
 // MARK: - layout code
 
 extension NSView {
@@ -180,54 +199,42 @@ extension NSView {
     
     public func km_add_leading_constraint_r(equalTo targetV: NSView? = nil, attribute a: NSLayoutConstraint.Attribute = .leading, constant c: CGFloat = 0) -> NSLayoutConstraint? {
         let constraint = self.km_leading_constraint(equalTo: targetV, attribute: a, constant: c)
-        if let _constraint = constraint {
-            self.superview?.addConstraint(_constraint)
-        }
+        self._addConstraint(constraint, to: targetV)
         
         return constraint
     }
     
     public func km_add_trailing_constraint_r(equalTo targetV: NSView? = nil, attribute a: NSLayoutConstraint.Attribute = .trailing, constant c: CGFloat = 0) -> NSLayoutConstraint? {
         let constraint = self.km_trailing_constraint(equalTo: targetV, attribute: a, constant: c)
-        if let _constraint = constraint {
-            self.superview?.addConstraint(_constraint)
-        }
+        self._addConstraint(constraint, to: targetV)
         
         return constraint
     }
     
     public func km_add_left_constraint_r(equalTo targetV: NSView? = nil, attribute a: NSLayoutConstraint.Attribute = .left, constant c: CGFloat = 0) -> NSLayoutConstraint? {
         let constraint = self.km_left_constraint(equalTo: targetV, attribute: a, constant: c)
-        if let _constraint = constraint {
-            self.superview?.addConstraint(_constraint)
-        }
+        self._addConstraint(constraint, to: targetV)
         
         return constraint
     }
     
     public func km_add_right_constraint_r(equalTo targetV: NSView? = nil, attribute a: NSLayoutConstraint.Attribute = .right, constant c: CGFloat = 0) -> NSLayoutConstraint? {
         let constraint = self.km_right_constraint(equalTo: targetV, attribute: a, constant: c)
-        if let _constraint = constraint {
-            self.superview?.addConstraint(_constraint)
-        }
+        self._addConstraint(constraint, to: targetV)
         
         return constraint
     }
     
     public func km_add_top_constraint_r(equalTo targetV: NSView? = nil, attribute a: NSLayoutConstraint.Attribute = .top, constant c: CGFloat = 0) -> NSLayoutConstraint? {
         let constraint = self.km_top_constraint(equalTo: targetV, attribute: a, constant: c)
-        if let _constraint = constraint {
-            self.superview?.addConstraint(_constraint)
-        }
+        self._addConstraint(constraint, to: targetV)
 
         return constraint
     }
     
     public func km_add_bottom_constraint_r(equalTo targetV: NSView? = nil, attribute a: NSLayoutConstraint.Attribute = .bottom, constant c: CGFloat = 0) -> NSLayoutConstraint? {
         let constraint = self.km_bottom_constraint(equalTo: targetV, attribute: a, constant: c)
-        if let _constraint = constraint {
-            self.superview?.addConstraint(_constraint)
-        }
+        self._addConstraint(constraint, to: targetV)
         
         return constraint
     }
@@ -625,5 +632,21 @@ extension NSView {
         }
         return false
     }
+    
+    private func _addConstraint(_ c: NSLayoutConstraint?, to targetV: NSView?) {
+        guard let _constraint = c else {
+            Swift.debugPrint("addConstraint failure, c == nil")
+            return
+        }
+        if let _targetV = targetV {
+            if _targetV.isElderView(to: self) { /// 是否为长辈视图(父类,父类的父类......)
+                _targetV.addConstraint(_constraint)
+            } else {
+                self.superview?.addConstraint(_constraint)
+            }
+        } else {
+            self.superview?.addConstraint(_constraint)
+        }
+    }
 }
 

+ 8 - 2
PDF Office/PDF Master/Class/Common/Category/NSWindow+KMExtension.swift

@@ -35,8 +35,14 @@ extension NSWindow {
         super.mouseMoved(with: event)
         
         let point = event.locationInWindow
-        if let data = event.window?.isKind(of: NSClassFromString("_NSPopoverWindow")!), data {
-            if (CGRectContainsPoint(self.sourcesRect, point)) {
+        var need = true
+        if let data = event.window?.isKind(of: NSClassFromString("_NSPopoverWindow")!) {
+            need = !data
+        } else {
+            need = true
+        }
+        if (need) {
+            if (CGRectContainsPoint(self.sourcesRect, point) == false) {
                 if self.popover != nil {
                     NotificationCenter.default.post(name: Notification.Name("KMPopOverClosedByWindowNotification"), object: self.popover!)
                     self.popover?.close()

+ 54 - 136
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Cell/KMHomeHistoryCollectionItem.swift

@@ -8,10 +8,10 @@
 import Cocoa
 
 
-typealias KMHomeHistoryCollectionItemShowPathAction = (_ view: KMHomeHistoryCollectionItem) -> Void
-typealias KMHomeHistoryCollectionItemRemovePathAction = (_ view: KMHomeHistoryCollectionItem) -> Void
-typealias KMHomeHistoryCollectionItemMouseMoveAction = (_ view: KMHomeHistoryCollectionItem, _ enter: Bool) -> Void
-typealias KMHomeHistoryCollectionItemMouseDobleClickAction = (_ view: KMHomeHistoryCollectionItem, _ url: URL) -> Void
+typealias KMHomeHistoryCollectionItemShowPathAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeHistoryCollectionItemRemovePathAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMHomeHistoryListViewModel) -> Void
+//typealias KMHomeHistoryCollectionItemMouseMoveAction = (_ view: KMHomeHistoryCollectionItem, _ enter: Bool) -> Void
+typealias KMHomeHistoryCollectionItemMouseDobleClickAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMHomeHistoryListViewModel) -> Void
 
 class KMHomeHistoryCollectionItem: NSCollectionViewItem {
 
@@ -32,7 +32,7 @@ class KMHomeHistoryCollectionItem: NSCollectionViewItem {
     @IBOutlet weak var verticalTitleLabel: NSTextField!
     @IBOutlet weak var showImageView: NSImageView!
     
-    var url: URL? {
+    var model: KMHomeHistoryListViewModel? {
         didSet {
             self.reloadData()
         }
@@ -45,7 +45,7 @@ class KMHomeHistoryCollectionItem: NSCollectionViewItem {
 
     var showPathAction: KMHomeHistoryCollectionItemShowPathAction?
     var removeAction: KMHomeHistoryCollectionItemRemovePathAction?
-    var mouseMoveAction: KMHomeHistoryCollectionItemMouseMoveAction?
+//    var mouseMoveAction: KMHomeHistoryCollectionItemMouseMoveAction?
     var mouseDobleClickAction: KMHomeHistoryCollectionItemMouseDobleClickAction?
     
     
@@ -53,7 +53,7 @@ class KMHomeHistoryCollectionItem: NSCollectionViewItem {
         super.viewDidLoad()
         // Do view setup here.
         // 使用自动布局设置 item 宽度等于父视图的宽度
-       view.translatesAutoresizingMaskIntoConstraints = false
+//       view.translatesAutoresizingMaskIntoConstraints = false
         
         self.setup()
     }
@@ -64,7 +64,31 @@ class KMHomeHistoryCollectionItem: NSCollectionViewItem {
     
     func setup() {
         self.view.wantsLayer = true;
-        self.view.layer?.cornerRadius = 4.0
+        
+        self.iconImageView.backgroundColor(NSColor.red)
+        
+        self.contentBox.border(NSColor.clear, 0, 8)
+        self.contentBox.moveCallback = { [unowned self] mouseEntered, mouseBox in
+            if mouseEntered {
+                if self.showType == .horizontal {
+                    self.handleView.isHidden = false
+                    self.contentBox.fillColor = KMAppearance.Status.hovColor()
+                } else {
+                    self.showImageView.border(KMAppearance.Interactive.a0Color(), 1, 4)
+                    self.verticalTitleLabel.backgroundColor(KMAppearance.Interactive.a0Color())
+                    self.verticalTitleLabel.textColor = KMAppearance.Layout.w0Color()
+                }
+            } else {
+                if self.showType == .horizontal {
+                    self.handleView.isHidden = true
+                    self.contentBox.fillColor = NSColor.clear
+                } else {
+                    self.showImageView.border(NSColor.clear, 1, 4)
+                    self.verticalTitleLabel.backgroundColor(NSColor.clear)
+                    self.verticalTitleLabel.textColor = KMAppearance.Layout.h0Color()
+                }
+            }
+        }
         
         showPathButton.toolTip = NSLocalizedString("Show in Finder", comment: "")
         removePathButton.toolTip = NSLocalizedString("Remove from Recents", comment: "")
@@ -97,9 +121,16 @@ class KMHomeHistoryCollectionItem: NSCollectionViewItem {
                 removePathButton.image = NSImage(named: "KMImageNameUXIconHomeRemoveNor")
             }
         }
+        
+        //vertical
+        self.showImageView.border(NSColor.clear, 1, 4)
+        self.verticalTitleLabel.backgroundColor(NSColor.clear)
+        self.verticalTitleLabel.textColor = KMAppearance.Layout.h0Color()
     }
     
     func reloadData() {
+        self.contentBox.updateTrackingAreas()
+        
         self.updateTypeData()
         self.updateFilesData()
     }
@@ -126,123 +157,22 @@ extension KMHomeHistoryCollectionItem {
     }
     
     func updateFilesData() -> Void {
-        guard let fileUrl = url else { return }
+        guard let model = model else { return }
         
-        let attrib = try? FileManager.default.attributesOfItem(atPath: fileUrl.path) as? Dictionary<FileAttributeKey , Any>
-        if attrib != nil {
-            let dateFormatter: DateFormatter = DateFormatter.init()
-            let fileDate: Date = attrib![FileAttributeKey(rawValue: "NSFileModificationDate")] as! Date
-            var fileTime: String = ""
-            if fileDate.isToday() {
-                dateFormatter.dateFormat = "HH:mm"
-            } else if self.isDateInCurrentWeek(fileDate) {
-                dateFormatter.dateFormat = "EEE, HH:mm"
-            } else {
-                dateFormatter.dateFormat = "MMM d, yyyy"
-            }
+        horizontalTitleLabel.stringValue = model.fileName
+        verticalTitleLabel.stringValue = model.fileName
+        pathLabel.stringValue = model.showPath
             
-            let fileName = fileUrl.lastPathComponent
-//            let fileType = url.pathExtension.isEmpty ? "" : url.pathExtension
-            let fileType = ""
-            let sizeFloat: Float = attrib![FileAttributeKey(rawValue: "NSFileSize")] as? Float ?? 0.0
-            let fileSize = fileSizeString(sizeFloat).isEmpty ? "" : fileSizeString(sizeFloat)
-            let lastTime = dateFormatter.string(from: fileDate)
-            if fileDate.isToday() {
-                fileTime = String(format: "%@, %@", NSLocalizedString("Today", comment: ""), lastTime)
-            } else if isDateInCurrentWeek(fileDate) {
-                fileTime = lastTime
-            } else {
-                fileTime = lastTime
-            }
-
-            let paragraphStyle = NSMutableParagraphStyle()
-            paragraphStyle.lineSpacing = 22.0
-            horizontalTitleLabel.stringValue = fileName
-            verticalTitleLabel.stringValue = fileName
-            
-            //path
-            let array = fileUrl.path
-                .deletingLastPathComponent
-                .components(separatedBy: "/")
-            let string = NSMutableString()
+        let paragraphStyle = NSMutableParagraphStyle()
+        paragraphStyle.lineSpacing = 22.0
+        sizeLabel.attributedStringValue = NSAttributedString(string: model.fileSize, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
+        timeLabel.attributedStringValue = NSAttributedString(string: model.modificationTime, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
 
-            if array.count > 4 {
-                string.append(".../")
-                string.append(array[array.count - 3])
-                string.append("/")
-                string.append(array[array.count - 2])
-                string.append("/")
-                string.append(array[array.count - 1])
-            } else {
-                string.setString(fileUrl.path.deletingLastPathComponent)
-            }
+        
+        showImageView.image = model.iconImage
+        
+        self.view.toolTip = model.fileName
 
-            pathLabel.stringValue = string as String
-            
-    //        documentName.attributedStringValue = NSAttributedString(string: fileName, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
-//            documentType.attributedStringValue = NSAttributedString(string: fileType, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
-            sizeLabel.attributedStringValue = NSAttributedString(string: fileSize, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
-            timeLabel.attributedStringValue = NSAttributedString(string: fileTime, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
-//            mainBox.toolTip = fileName
-//            
-//            if selectUrls.contains(fileUrl) {
-//                isSelect = true
-//                mainBox.fillColor = NSColor.km_init(hex: "#CED0D4", alpha: 0.6)
-//                mainBox.borderWidth = 1.0
-//                mainBox.borderColor = NSColor.km_init(hex: "#CED0D4")
-//                mainBox.cornerRadius = 4.0
-//            } else {
-//                isSelect = false
-//                mainBox.fillColor = .clear
-//                mainBox.borderWidth = 0.0
-//                mainBox.cornerRadius = 0.0
-//            }
-//            documentName.backgroundColor = .clear
-//            documentName.textColor = NSColor.km_init(hex: "#252629")
-//            documentName.font = NSFont(name: "SFProText-Regular", size: 14)
-//            documentType.textColor = NSColor.km_init(hex: "#94989C")
-//            documentSize.textColor = NSColor.km_init(hex: "#94989C")
-//            documentName.backgroundColor = .clear
-//            lastModificationTime.textColor = NSColor.km_init(hex: "#94989C")
-//            lastModificationTime.backgroundColor = .clear
-//            moreButton.image = NSImage(named: "KMHomeMoreTools")
-            let image: NSImage = NSImage.previewForFile(path: fileUrl, ofSize: self.view.bounds.size, asIcon: true) ?? NSImage()
-            showImageView.image = image
-        }
-    }
-    
-    func fileSizeString(_ fSize: Float) -> String {
-        let fileSize = fSize / 1024
-        let size = fileSize >= 1024 ? (fileSize < 1048576 ? fileSize/1024 : fileSize/1048576.0) : fileSize
-        let unit = fileSize >= 1024 ? (fileSize < 1048576 ? "M" : "G") : "K"
-        return String(format: "%0.1f %@", size, unit)
-    }
-    
-    func isSameWeek (withDate date: Date) -> Bool {
-        let currentWeekOfYear = getWeekOfYear(date: Date.init())
-        let targetWeekOfYear = getWeekOfYear(date: date)
-        if targetWeekOfYear == currentWeekOfYear {
-            return false
-        } else {
-            return true
-        }
-    }
-    
-    func isDateInCurrentWeek(_ date: Date) -> Bool {
-        let calendar = Calendar.current
-        // 获取当前日期的星期几
-        let weekday = calendar.component(.weekday, from: Date())
-        // 获取一周的第一天(周日)的日期
-        let firstDayOfWeek = calendar.date(byAdding: .day, value: -weekday, to: Date())!
-        // 获取一周的最后一天(下周的第一天)的日期
-        let lastDayOfWeek = calendar.date(byAdding: .day, value: 7, to: firstDayOfWeek)!
-        // 判断日期是否在当前周的范围内
-        return date > firstDayOfWeek && date < lastDayOfWeek
-    }
-     
-    func getWeekOfYear(date: Date) -> Int {
-        let components = Calendar.current.dateComponents([Calendar.Component.weekOfYear], from: date)
-        return components.weekOfYear ?? 0
     }
 }
                      
@@ -250,34 +180,22 @@ extension KMHomeHistoryCollectionItem {
     @objc @IBAction func showPathButtonAction(_ sender: Any) {
         guard let callBack = showPathAction else { return }
         
-        callBack(self)
+        callBack(self, model!)
     }
     
     @objc @IBAction func removePathButtonAction(_ sender: Any) {
         guard let callBack = removeAction else { return }
         
-        callBack(self)
+        callBack(self, model!)
     }
 }
 
 extension KMHomeHistoryCollectionItem {
-    override func mouseEntered(with event: NSEvent) {
-        guard let callBack = mouseMoveAction else { return }
-        
-        callBack(self, true)
-    }
-    
-    override func mouseExited(with event: NSEvent) {
-        guard let callBack = mouseMoveAction else { return }
-        
-        callBack(self, false)
-    }
-    
     override func mouseDown(with event: NSEvent) {
         if event.clickCount == 2 {
             // 处理双击操作
             guard let callBack = mouseDobleClickAction else { return }
-            callBack(self, self.url!)
+            callBack(self, self.model!)
         } else {
             super.mouseDown(with: event)
         }

+ 29 - 27
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Cell/KMHomeHistoryCollectionItem.xib

@@ -28,24 +28,27 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView translatesAutoresizingMaskIntoConstraints="NO" id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="618" height="88"/>
+            <rect key="frame" x="0.0" y="0.0" width="594" height="258"/>
             <subviews>
                 <box boxType="custom" borderWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="gvc-kj-Yeo" customClass="KMBox" customModule="PDF_Master" customModuleProvider="target">
-                    <rect key="frame" x="16" y="16" width="586" height="56"/>
+                    <rect key="frame" x="0.0" y="0.0" width="594" height="258"/>
                     <view key="contentView" id="KgU-86-iwk">
-                        <rect key="frame" x="0.0" y="0.0" width="586" height="56"/>
+                        <rect key="frame" x="0.0" y="0.0" width="594" height="258"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                     </view>
                 </box>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="oc7-Ul-iDs">
-                    <rect key="frame" x="0.0" y="0.0" width="618" height="88"/>
+                    <rect key="frame" x="0.0" y="0.0" width="594" height="258"/>
                     <subviews>
                         <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="dbA-sb-Xfk">
-                            <rect key="frame" x="0.0" y="40" width="618" height="48"/>
+                            <rect key="frame" x="0.0" y="82" width="594" height="176"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="176" id="fUn-kK-60Z"/>
+                            </constraints>
                             <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="bdV-B5-oJm"/>
                         </imageView>
                         <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mZL-RM-KzQ">
-                            <rect key="frame" x="14" y="16" width="590" height="16"/>
+                            <rect key="frame" x="293" y="58" width="8" height="16"/>
                             <textFieldCell key="cell" alignment="center" id="Nso-Kd-6li">
                                 <font key="font" metaFont="system"/>
                                 <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -54,29 +57,28 @@
                         </textField>
                     </subviews>
                     <constraints>
-                        <constraint firstItem="mZL-RM-KzQ" firstAttribute="leading" secondItem="oc7-Ul-iDs" secondAttribute="leading" constant="16" id="7fg-gh-Ipe"/>
-                        <constraint firstAttribute="trailing" secondItem="dbA-sb-Xfk" secondAttribute="trailing" id="HWM-9v-2Rd"/>
-                        <constraint firstItem="dbA-sb-Xfk" firstAttribute="top" secondItem="oc7-Ul-iDs" secondAttribute="top" id="Sv1-jj-Bfg"/>
-                        <constraint firstItem="mZL-RM-KzQ" firstAttribute="centerX" secondItem="oc7-Ul-iDs" secondAttribute="centerX" id="U8s-bU-U33"/>
-                        <constraint firstAttribute="trailing" secondItem="mZL-RM-KzQ" secondAttribute="trailing" constant="16" id="hy9-aF-hPG"/>
-                        <constraint firstItem="mZL-RM-KzQ" firstAttribute="top" secondItem="dbA-sb-Xfk" secondAttribute="bottom" constant="8" id="jfz-kY-uGx"/>
-                        <constraint firstAttribute="bottom" secondItem="dbA-sb-Xfk" secondAttribute="bottom" constant="40" id="lD8-TX-JUg"/>
-                        <constraint firstItem="dbA-sb-Xfk" firstAttribute="leading" secondItem="oc7-Ul-iDs" secondAttribute="leading" id="xP3-Qp-EQE"/>
+                        <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="mZL-RM-KzQ" secondAttribute="trailing" id="7BD-64-evH"/>
+                        <constraint firstAttribute="trailing" secondItem="dbA-sb-Xfk" secondAttribute="trailing" id="80h-2r-yMV"/>
+                        <constraint firstItem="mZL-RM-KzQ" firstAttribute="top" secondItem="dbA-sb-Xfk" secondAttribute="bottom" constant="8" id="9qi-k0-iQ9"/>
+                        <constraint firstItem="dbA-sb-Xfk" firstAttribute="top" secondItem="oc7-Ul-iDs" secondAttribute="top" id="CxI-HI-LqK"/>
+                        <constraint firstItem="mZL-RM-KzQ" firstAttribute="centerX" secondItem="oc7-Ul-iDs" secondAttribute="centerX" id="Ex9-nS-fp9"/>
+                        <constraint firstItem="mZL-RM-KzQ" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="oc7-Ul-iDs" secondAttribute="leading" id="Xlz-5a-Mld"/>
+                        <constraint firstItem="dbA-sb-Xfk" firstAttribute="leading" secondItem="oc7-Ul-iDs" secondAttribute="leading" id="aLi-Lu-w7p"/>
                     </constraints>
                 </customView>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="7sk-7M-lCI">
-                    <rect key="frame" x="0.0" y="0.0" width="618" height="88"/>
+                    <rect key="frame" x="0.0" y="0.0" width="594" height="258"/>
                     <subviews>
                         <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0Mh-Sf-3a2">
-                            <rect key="frame" x="16" y="28" width="32" height="32"/>
+                            <rect key="frame" x="16" y="109" width="32" height="40"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="32" id="Hwu-re-UBO"/>
-                                <constraint firstAttribute="height" constant="32" id="Wiy-fe-sgF"/>
+                                <constraint firstAttribute="height" constant="40" id="Wiy-fe-sgF"/>
                             </constraints>
                             <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="KMImageNameUXIconPropertybarFilePdf" id="eLO-Yq-M3q"/>
                         </imageView>
                         <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ddV-aD-Yah">
-                            <rect key="frame" x="54" y="43" width="40" height="17"/>
+                            <rect key="frame" x="54" y="132" width="40" height="17"/>
                             <textFieldCell key="cell" lineBreakMode="truncatingMiddle" alignment="left" title="Label" id="AYN-Fy-tcy">
                                 <font key="font" metaFont="system" size="14"/>
                                 <color key="textColor" name="KMGray6Color"/>
@@ -84,7 +86,7 @@
                             </textFieldCell>
                         </textField>
                         <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WUP-W3-okM">
-                            <rect key="frame" x="495" y="37" width="109" height="15"/>
+                            <rect key="frame" x="471" y="122" width="109" height="15"/>
                             <textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="2020-08-01 12:39" id="PEF-8C-QEE">
                                 <font key="font" metaFont="cellTitle"/>
                                 <color key="textColor" name="KMGray5Color"/>
@@ -92,7 +94,7 @@
                             </textFieldCell>
                         </textField>
                         <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Der-Qi-aoW">
-                            <rect key="frame" x="93" y="28" width="35" height="15"/>
+                            <rect key="frame" x="93" y="109" width="35" height="15"/>
                             <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="2AB-HF-4Ox">
                                 <font key="font" metaFont="cellTitle"/>
                                 <color key="textColor" red="0.39607843139999999" green="0.41176470590000003" blue="0.43921568630000002" alpha="1" colorSpace="calibratedRGB"/>
@@ -100,7 +102,7 @@
                             </textFieldCell>
                         </textField>
                         <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wId-sm-qtO">
-                            <rect key="frame" x="54" y="28" width="35" height="15"/>
+                            <rect key="frame" x="54" y="109" width="35" height="15"/>
                             <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="Pbe-3u-seE">
                                 <font key="font" metaFont="cellTitle"/>
                                 <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -108,7 +110,7 @@
                             </textFieldCell>
                         </textField>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="seD-7E-dp2">
-                            <rect key="frame" x="373" y="24" width="100" height="40"/>
+                            <rect key="frame" x="349" y="109" width="100" height="40"/>
                             <subviews>
                                 <button translatesAutoresizingMaskIntoConstraints="NO" id="HSD-uO-oml" customClass="KMButton" customModule="PDF_Master" customModuleProvider="target">
                                     <rect key="frame" x="20" y="10" width="20" height="20"/>
@@ -168,18 +170,18 @@
             <constraints>
                 <constraint firstAttribute="bottom" secondItem="7sk-7M-lCI" secondAttribute="bottom" id="1xu-Eu-Gpw"/>
                 <constraint firstItem="oc7-Ul-iDs" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="3mN-ui-HOd"/>
-                <constraint firstAttribute="trailing" secondItem="gvc-kj-Yeo" secondAttribute="trailing" constant="16" id="MQ9-mG-dvf"/>
-                <constraint firstItem="gvc-kj-Yeo" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="16" id="QNY-R7-aCn"/>
+                <constraint firstAttribute="trailing" secondItem="gvc-kj-Yeo" secondAttribute="trailing" id="MQ9-mG-dvf"/>
+                <constraint firstItem="gvc-kj-Yeo" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="QNY-R7-aCn"/>
                 <constraint firstAttribute="trailing" secondItem="oc7-Ul-iDs" secondAttribute="trailing" id="ZvQ-Yb-83f"/>
-                <constraint firstItem="gvc-kj-Yeo" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="16" id="c3K-iJ-GsK"/>
+                <constraint firstItem="gvc-kj-Yeo" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="c3K-iJ-GsK"/>
                 <constraint firstAttribute="trailing" secondItem="7sk-7M-lCI" secondAttribute="trailing" id="cqh-JA-THy"/>
                 <constraint firstItem="7sk-7M-lCI" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="e4i-JT-Slb"/>
                 <constraint firstItem="7sk-7M-lCI" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="ooa-BQ-VTr"/>
-                <constraint firstAttribute="bottom" secondItem="gvc-kj-Yeo" secondAttribute="bottom" constant="16" id="pQn-cm-GgU"/>
+                <constraint firstAttribute="bottom" secondItem="gvc-kj-Yeo" secondAttribute="bottom" id="pQn-cm-GgU"/>
                 <constraint firstAttribute="bottom" secondItem="oc7-Ul-iDs" secondAttribute="bottom" id="pjN-VI-SK1"/>
                 <constraint firstItem="oc7-Ul-iDs" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="tTF-yE-4ER"/>
             </constraints>
-            <point key="canvasLocation" x="-67" y="194"/>
+            <point key="canvasLocation" x="-526" y="331"/>
         </customView>
     </objects>
     <resources>

+ 29 - 7
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/KMHomeHistoryListView.swift

@@ -13,15 +13,25 @@ enum KMHomeHistoryListViewShowType: Int {
     case vertical //纵
 }
 
-typealias KMHomeHistoryListViewItemDidSelect = (_ view: KMHomeHistoryListView, _ url: URL) -> Void
+typealias KMHomeHistoryListViewItemDidSelect = (_ view: KMHomeHistoryListView, _ item: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeHistoryListViewItemShowPathAction = (_ view: KMHomeHistoryListView, _ item: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeHistoryListViewItemRemovePathAction = (_ view: KMHomeHistoryListView, _ item: KMHomeHistoryListViewModel) -> Void
+
 class KMHomeHistoryListView: KMBaseXibView {
     @IBOutlet weak var collectionView: NSCollectionView!
     
     var didSelect: KMHomeHistoryListViewItemDidSelect?
-    var data:[URL] = []
+    var showPathAction: KMHomeHistoryListViewItemShowPathAction?
+    var removeFileAction: KMHomeHistoryListViewItemRemovePathAction?
+    
+    var data:[KMHomeHistoryListViewModel] = []
     var showType:KMHomeHistoryListViewShowType = .horizontal {
         didSet {
             self.collectionView.reloadData()
+            //item的大小不刷新 暂时处理为刷新两次
+            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
+                self.collectionView.reloadData()
+            }
         }
     }
     
@@ -49,7 +59,7 @@ class KMHomeHistoryListView: KMBaseXibView {
         self.data.removeAll()
         for url in NSDocumentController.shared.recentDocumentURLs {
             if FileManager.default.fileExists(atPath: url.path) {
-                self.data.append(url)
+                self.data.append(KMHomeHistoryListViewModel.init(filePath: url))
             }
         }
 
@@ -97,13 +107,25 @@ extension KMHomeHistoryListView: NSCollectionViewDataSource {
         let view = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMHomeHistoryCollectionItem"), for: indexPath) as! KMHomeHistoryCollectionItem
         view.showType = self.showType
         if self.data.count > indexPath.item {
-            view.url = self.data[indexPath.item]
+            view.model = self.data[indexPath.item]
         }
     
-        view.mouseDobleClickAction = {[unowned self] view, url in
+        view.mouseDobleClickAction = {[unowned self] view, item in
             guard let callBack = didSelect else { return }
             
-            callBack(self, url)
+            callBack(self, item)
+        }
+        
+        view.showPathAction = {[unowned self] view, item in
+            guard let callBack = showPathAction else { return }
+            
+            callBack(self, item)
+        }
+        
+        view.removeAction = {[unowned self] view, item in
+            guard let callBack = removeFileAction else { return }
+            
+            callBack(self, item)
         }
         return view
     }
@@ -123,7 +145,7 @@ extension KMHomeHistoryListView: NSCollectionViewDelegateFlowLayout {
         if showType == .horizontal {
             return NSEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
         } else {
-            return NSEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
+            return NSEdgeInsets(top: 10, left: 0, bottom: 10, right: 10)
         }
     }
 }

+ 1 - 1
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/KMHomeHistoryListView.xib

@@ -23,7 +23,7 @@
                         <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <collectionView id="2YZ-04-yn6">
+                            <collectionView translatesAutoresizingMaskIntoConstraints="NO" id="2YZ-04-yn6">
                                 <rect key="frame" x="0.0" y="0.0" width="480" height="158"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
                                 <collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" id="nLD-SM-dF9">

+ 112 - 1
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Model/KMHomeHistoryListViewModel.swift

@@ -8,5 +8,116 @@
 import Cocoa
 
 class KMHomeHistoryListViewModel: NSObject {
-
+    init(filePath: URL) {
+        super.init()
+        self.filePath = filePath
+        self.dealData(filePath: filePath)
+    }
+    
+    var filePath: URL? {
+        didSet {
+            self.dealData(filePath: filePath!)
+        }
+    }
+    
+    var showPath: String = ""
+    
+    var fileName: String = ""
+    
+    var fileSize: String = ""
+    
+    var modificationTime: String = ""
+    
+    var attributesOfItem: [FileAttributeKey : Any]?
+    
+    var iconImage: NSImage?
+    
+    
+    func dealData(filePath: URL) {
+        let attrib = try? FileManager.default.attributesOfItem(atPath: filePath.path) as? Dictionary<FileAttributeKey , Any>
+            if attrib != nil {
+                let dateFormatter: DateFormatter = DateFormatter.init()
+                let fileDate: Date = attrib![FileAttributeKey(rawValue: "NSFileModificationDate")] as! Date
+                var fileTime: String = ""
+                if fileDate.isToday() {
+                    dateFormatter.dateFormat = "HH:mm"
+                } else if self.isDateInCurrentWeek(fileDate) {
+                    dateFormatter.dateFormat = "EEE, HH:mm"
+                } else {
+                    dateFormatter.dateFormat = "MMM d, yyyy"
+                }
+    
+    //            let fileType = url.pathExtension.isEmpty ? "" : url.pathExtension
+                let fileType = ""
+                let sizeFloat: Float = attrib![FileAttributeKey(rawValue: "NSFileSize")] as? Float ?? 0.0
+                let fileSize = fileSizeString(sizeFloat).isEmpty ? "" : fileSizeString(sizeFloat)
+                let lastTime = dateFormatter.string(from: fileDate)
+                if fileDate.isToday() {
+                    fileTime = String(format: "%@, %@", NSLocalizedString("Today", comment: ""), lastTime)
+                } else if isDateInCurrentWeek(fileDate) {
+                    fileTime = lastTime
+                } else {
+                    fileTime = lastTime
+                }
+    
+                //path
+                let array = filePath.path
+                    .deletingLastPathComponent
+                    .components(separatedBy: "/")
+                let string = NSMutableString()
+    
+                if array.count > 4 {
+                    string.append(".../")
+                    string.append(array[array.count - 3])
+                    string.append("/")
+                    string.append(array[array.count - 2])
+                    string.append("/")
+                    string.append(array[array.count - 1])
+                } else {
+                    string.setString(filePath.path.deletingLastPathComponent)
+                }
+    
+                let image: NSImage = NSImage.previewForFile(path: filePath, ofSize: CGSizeMake(136, 214), asIcon: true) ?? NSImage()
+                
+                attributesOfItem = attrib
+                showPath = string.description
+                modificationTime = fileTime
+                iconImage = image
+                fileName = filePath.lastPathComponent
+            }
+        }
+            
+        func fileSizeString(_ fSize: Float) -> String {
+            let fileSize = fSize / 1024
+            let size = fileSize >= 1024 ? (fileSize < 1048576 ? fileSize/1024 : fileSize/1048576.0) : fileSize
+            let unit = fileSize >= 1024 ? (fileSize < 1048576 ? "M" : "G") : "K"
+            return String(format: "%0.1f %@", size, unit)
+        }
+        
+        func isSameWeek (withDate date: Date) -> Bool {
+            let currentWeekOfYear = getWeekOfYear(date: Date.init())
+            let targetWeekOfYear = getWeekOfYear(date: date)
+            if targetWeekOfYear == currentWeekOfYear {
+                return false
+            } else {
+                return true
+            }
+        }
+        
+        func isDateInCurrentWeek(_ date: Date) -> Bool {
+            let calendar = Calendar.current
+            // 获取当前日期的星期几
+            let weekday = calendar.component(.weekday, from: Date())
+            // 获取一周的第一天(周日)的日期
+            let firstDayOfWeek = calendar.date(byAdding: .day, value: -weekday, to: Date())!
+            // 获取一周的最后一天(下周的第一天)的日期
+            let lastDayOfWeek = calendar.date(byAdding: .day, value: 7, to: firstDayOfWeek)!
+            // 判断日期是否在当前周的范围内
+            return date > firstDayOfWeek && date < lastDayOfWeek
+        }
+         
+        func getWeekOfYear(date: Date) -> Int {
+            let components = Calendar.current.dateComponents([Calendar.Component.weekOfYear], from: date)
+            return components.weekOfYear ?? 0
+        }
 }

+ 67 - 17
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift

@@ -7,12 +7,20 @@
 
 import Cocoa
 
-typealias KMHomeContentViewHistoryDidSelect = (_ view: KMHomeContentView, _ url: URL) -> Void
+typealias KMHomeContentViewHistoryDidSelect = (_ view: KMHomeContentView, _ url: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeContentViewHistoryShowPathAction = (_ view: KMHomeContentView, _ url: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeContentViewHistoryrRemoveFileAction = (_ view: KMHomeContentView, _ url: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeContentViewHistoryrRemoveAllFileAction = (_ view: KMHomeContentView) -> Void
+
+typealias KMHomeContentViewQucikToolsDidSelect = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
+typealias KMHomeContentViewQucikToolsAddAction = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
+typealias KMHomeContentViewQucikToolsRemoveAction = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
 
 class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var qucikToolsLabel: NSTextField!
     @IBOutlet weak var qucikToolsView: KMQucikToolsView!
     @IBOutlet weak var leftButton: NSButton!
+    @IBOutlet weak var pageLabel: NSTextField!
     @IBOutlet weak var rightButton: NSButton!
     @IBOutlet weak var moreButton: KMButton!
     
@@ -24,6 +32,13 @@ class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var cleanButton: KMButton!
     
     var historyDidSelect: KMHomeContentViewHistoryDidSelect?
+    var historyShowPathAction: KMHomeContentViewHistoryShowPathAction?
+    var historyRemoveFileAction: KMHomeContentViewHistoryrRemoveFileAction?
+    var historyRemoveAllFileAction: KMHomeContentViewHistoryrRemoveAllFileAction?
+    
+    var qucikToolsDidSelect: KMHomeContentViewQucikToolsDidSelect?
+    var qucikToolsAddAction: KMHomeContentViewQucikToolsAddAction?
+    var qucikToolsRemoveAction: KMHomeContentViewQucikToolsRemoveAction?
     
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
@@ -33,40 +48,73 @@ class KMHomeContentView: KMBaseXibView {
     }
     
     override func setup() {
-        self.historyListViewSetup()
+        self.pageLabel.textColor = KMAppearance.Layout.h0Color()
+        self.qucikToolsView.didSelect = { [unowned self] view, item in
+            guard let callBack = qucikToolsDidSelect else { return }
+            
+            callBack(self, item)
+        }
+        
+        self.qucikToolsView.pageChange = { [unowned self] view in
+            self.updatePageLabel()
+        }
+        
+        self.qucikToolsView.addAction = { [unowned self] view, item in
+            self.qucikToolsAddAction?(self, item)
+        }
+        
+        self.qucikToolsView.removeAction = { [unowned self] view, item in
+            self.qucikToolsRemoveAction?(self, item)
+        }
+        
+        self.historyListView.didSelect = { [unowned self] view, item in
+            guard let callBack = historyDidSelect else { return }
+            
+            callBack(self, item)
+        }
+        
+        self.historyListView.removeFileAction = { [unowned self] view, item in
+            guard let callBack = historyRemoveFileAction else { return }
+            
+            callBack(self, item)
+        }
+        
+        self.historyListView.showPathAction = { [unowned self] view, item in
+            guard let callBack = historyShowPathAction else { return }
+            
+            callBack(self, item)
+        }
+        
+        
+        
+        self.updatePageLabel()
     }
+    
+    func updatePageLabel() {
+        self.pageLabel.stringValue = "\(qucikToolsView.currentPage()) / \(qucikToolsView.pageCount())"
+    }
+    
 }
 
+//MARK: Action
 extension KMHomeContentView {
     @IBAction func leftButtonAction(_ sender: Any) {
-        
+        self.qucikToolsView.previousPage()
     }
     
     @IBAction func rightButtonAction(_ sender: Any) {
-        
+        self.qucikToolsView.nextPage()
     }
     
     @IBAction func moreButtonAction(_ sender: Any) {
         let homeQuickToolsWindowController: KMHomeQuickToolsWindowController = KMHomeQuickToolsWindowController.sharedHomeQuickTools
         homeQuickToolsWindowController.window?.center()
-//        homeQuickToolsWindowController.window?.orderFront(sender)
         NSWindow.currentWindow().addChildWindow(homeQuickToolsWindowController.window!, ordered: NSWindow.OrderingMode.above)
-//        NSWindow.currentWindow().beginSheet(homeQuickToolsWindowController.window!)
+
         homeQuickToolsWindowController.dataChange = { [unowned self] controller in
             self.qucikToolsView.reloadData()
         }
     }
-}
-
-extension KMHomeContentView {
-    func historyListViewSetup() {
-        self.historyListView.didSelect = { [unowned self] view, url in
-            guard let callBack = historyDidSelect else { return }
-            
-            callBack(self, url)
-        }
-        
-    }
     
     @IBAction func horizontalButtonAction(_ sender: Any) {
         self.historyListView.showType = .horizontal
@@ -77,6 +125,8 @@ extension KMHomeContentView {
     }
     
     @IBAction func cleanButtonAction(_ sender: Any) {
+        guard let callBack = historyRemoveAllFileAction else { return }
         
+        callBack(self)
     }
 }

+ 31 - 17
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.xib

@@ -11,12 +11,13 @@
                 <outlet property="cleanButton" destination="2pe-eQ-jim" id="NzZ-si-Lah"/>
                 <outlet property="historyListView" destination="wMw-AS-5yG" id="HHc-lb-Uau"/>
                 <outlet property="horizontalButton" destination="f8L-dW-OV5" id="2bQ-AH-t3U"/>
-                <outlet property="leftButton" destination="PwG-OP-iJ7" id="eZg-FR-Kro"/>
+                <outlet property="leftButton" destination="WXY-wn-hPk" id="hp6-fa-w4J"/>
                 <outlet property="moreButton" destination="YVh-aT-yWA" id="M54-rm-tnw"/>
+                <outlet property="pageLabel" destination="AZq-VF-EUc" id="CCP-bH-lFT"/>
                 <outlet property="qucikToolsLabel" destination="FaJ-2q-2cQ" id="q0S-ez-pED"/>
                 <outlet property="qucikToolsView" destination="ynU-RA-kWD" id="t4n-b1-mpf"/>
                 <outlet property="recentlyLabel" destination="Jq6-Hl-amd" id="cL6-5Q-9jC"/>
-                <outlet property="rightButton" destination="WPD-Y0-yC2" id="ZEL-I1-FmC"/>
+                <outlet property="rightButton" destination="34n-6o-x3z" id="qKh-a6-NQL"/>
                 <outlet property="verticalButton" destination="oce-zR-GCX" id="DXr-S4-r67"/>
             </connections>
         </customObject>
@@ -60,45 +61,58 @@
                                                             <action selector="moreButtonAction:" target="-2" id="4JY-gV-CUq"/>
                                                         </connections>
                                                     </button>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WPD-Y0-yC2">
+                                                    <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AZq-VF-EUc">
+                                                        <rect key="frame" x="526" y="4" width="25" height="16"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="height" constant="16" id="ysy-ux-uwA"/>
+                                                        </constraints>
+                                                        <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="1/2" id="VoQ-Tz-nCY">
+                                                            <font key="font" metaFont="cellTitle"/>
+                                                            <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.84705882349999995" colorSpace="calibratedRGB"/>
+                                                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                        </textFieldCell>
+                                                    </textField>
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="34n-6o-x3z">
                                                         <rect key="frame" x="557" y="2" width="16" height="21"/>
-                                                        <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSTouchBarGoForwardTemplate" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="mRw-z9-Pze">
+                                                        <buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSTouchBarGoForwardTemplate" imagePosition="overlaps" alignment="center" imageScaling="proportionallyDown" inset="2" id="vf1-qw-7He">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                             <font key="font" metaFont="system"/>
                                                         </buttonCell>
                                                         <constraints>
-                                                            <constraint firstAttribute="width" constant="16" id="ASJ-At-7qY"/>
-                                                            <constraint firstAttribute="height" constant="16" id="x37-9K-xk3"/>
+                                                            <constraint firstAttribute="width" constant="16" id="k4Q-hn-f2N"/>
+                                                            <constraint firstAttribute="height" constant="16" id="yiF-N3-Zwz"/>
                                                         </constraints>
                                                         <connections>
-                                                            <action selector="rightButtonAction:" target="-2" id="noR-iP-jsC"/>
+                                                            <action selector="rightButtonAction:" target="-2" id="SCM-qa-djR"/>
                                                         </connections>
                                                     </button>
-                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PwG-OP-iJ7">
-                                                        <rect key="frame" x="509" y="2" width="16" height="21"/>
-                                                        <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="NSTouchBarGoBackTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="bil-yH-Akb">
+                                                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WXY-wn-hPk">
+                                                        <rect key="frame" x="504" y="2" width="16" height="21"/>
+                                                        <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="NSTouchBarGoBackTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="his-Ac-2Du">
                                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                             <font key="font" metaFont="system"/>
                                                         </buttonCell>
                                                         <constraints>
-                                                            <constraint firstAttribute="height" constant="16" id="Dw9-LS-jOQ"/>
-                                                            <constraint firstAttribute="width" constant="16" id="Wzf-Iv-uw7"/>
+                                                            <constraint firstAttribute="height" constant="16" id="07e-1r-Vje"/>
+                                                            <constraint firstAttribute="width" constant="16" id="CGy-dK-xkf"/>
                                                         </constraints>
                                                         <connections>
-                                                            <action selector="leftButtonAction:" target="-2" id="U2S-eX-FI8"/>
+                                                            <action selector="leftButtonAction:" target="-2" id="Ic9-Y6-q8s"/>
                                                         </connections>
                                                     </button>
                                                 </subviews>
                                                 <constraints>
-                                                    <constraint firstItem="WPD-Y0-yC2" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="1mQ-di-yW2"/>
-                                                    <constraint firstItem="WPD-Y0-yC2" firstAttribute="leading" secondItem="PwG-OP-iJ7" secondAttribute="trailing" constant="32" id="2o2-jt-hDj"/>
+                                                    <constraint firstItem="34n-6o-x3z" firstAttribute="leading" secondItem="AZq-VF-EUc" secondAttribute="trailing" constant="8" id="5b1-3H-yqn"/>
                                                     <constraint firstAttribute="trailing" secondItem="YVh-aT-yWA" secondAttribute="trailing" id="C9W-JG-W8s"/>
+                                                    <constraint firstItem="34n-6o-x3z" firstAttribute="centerY" secondItem="WXY-wn-hPk" secondAttribute="centerY" id="HqR-w0-aOA"/>
                                                     <constraint firstItem="FaJ-2q-2cQ" firstAttribute="leading" secondItem="69z-SV-dL5" secondAttribute="leading" id="UZc-nM-Aqt"/>
                                                     <constraint firstAttribute="height" constant="24" id="VF5-NT-Dua"/>
                                                     <constraint firstItem="FaJ-2q-2cQ" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="e4G-eL-brO"/>
-                                                    <constraint firstItem="YVh-aT-yWA" firstAttribute="leading" secondItem="WPD-Y0-yC2" secondAttribute="trailing" constant="16" id="sIP-zf-cQy"/>
+                                                    <constraint firstItem="AZq-VF-EUc" firstAttribute="leading" secondItem="WXY-wn-hPk" secondAttribute="trailing" constant="8" id="epd-Mx-BL8"/>
+                                                    <constraint firstItem="AZq-VF-EUc" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="fCt-K0-F68"/>
+                                                    <constraint firstItem="AZq-VF-EUc" firstAttribute="centerY" secondItem="WXY-wn-hPk" secondAttribute="centerY" id="hgj-vL-sIT"/>
                                                     <constraint firstItem="YVh-aT-yWA" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="u3H-Ys-UG6"/>
-                                                    <constraint firstItem="PwG-OP-iJ7" firstAttribute="centerY" secondItem="69z-SV-dL5" secondAttribute="centerY" id="ygX-nH-XYo"/>
+                                                    <constraint firstItem="YVh-aT-yWA" firstAttribute="leading" secondItem="34n-6o-x3z" secondAttribute="trailing" constant="16" id="wW8-yX-vAt"/>
                                                 </constraints>
                                             </customView>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="ynU-RA-kWD" customClass="KMQucikToolsView" customModule="PDF_Master" customModuleProvider="target">

+ 76 - 7
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift

@@ -7,10 +7,20 @@
 
 import Cocoa
 
+typealias KMQucikToolsViewDidSelect = (_ view: KMQucikToolsView, _ item: KMQucikToolsModel) -> Void
+typealias KMQucikToolsViewPageChange = (_ view: KMQucikToolsView) -> Void
+
 class KMQucikToolsView: KMBaseXibView {
     @IBOutlet weak var collectionView: NSCollectionView!
     
+    var addAction: KMQucikToolCollectionViewItemAddAction?
+    var removeAction: KMQucikToolCollectionViewItemRemoveAction?
+    
+    var didSelect: KMQucikToolsViewDidSelect?
+    var pageChange: KMQucikToolsViewPageChange?
+    
     var data: [KMQucikToolsModel] = []
+    
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
 
@@ -33,6 +43,7 @@ class KMQucikToolsView: KMBaseXibView {
         //注册cell
         self.collectionView.register(KMQucikToolCollectionViewItem.self, forItemWithIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMQucikToolCollectionViewItem"))
         
+        NotificationCenter.default.addObserver(self, selector: #selector(scrollViewDidScroll(notification:)), name: NSScrollView.didLiveScrollNotification, object: collectionView.enclosingScrollView)
 //        self.backgroundColor(KMAppearance.Layout.l0Color())
     }
     
@@ -46,24 +57,41 @@ class KMQucikToolsView: KMBaseXibView {
     }
 }
 
+//Notification
+extension KMQucikToolsView  {
+    @objc func scrollViewDidScroll(notification: Notification) {
+        // 处理滚动事件
+        if let scrollView = notification.object as? NSScrollView {
+            print("NSScrollView did scroll.")
+            // 获取滚动位置等信息
+            let contentOffset = scrollView.contentView.bounds.origin
+            print("Content Offset: \(contentOffset)")
+            
+        }
+        
+        guard let callBack = pageChange else { return }
+        callBack(self)
+    }
+}
+
 extension KMQucikToolsView: NSCollectionViewDelegate {
     //当item被选中
     public func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
         print("点击")
         let view = collectionView.item(at: indexPaths.first!) as! KMQucikToolCollectionViewItem
         
-//        let content = view.model
+        let content = view.model
         
-//        guard let callBack = didSelect else { return }
-//        
-//        content?.index = indexPaths.first!.item
-//        callBack(self, content!)
+        guard let callBack = didSelect else { return }
+        callBack(self, content!)
     }
     
    //当item取消选中
     public func collectionView(_ collectionView: NSCollectionView, didDeselectItemsAt indexPaths: Set<IndexPath>) {
         _ = collectionView.item(at: indexPaths.first!) as! KMQucikToolCollectionViewItem
     }
+    
+    
 }
 
 extension KMQucikToolsView: NSCollectionViewDataSource {
@@ -81,9 +109,17 @@ extension KMQucikToolsView: NSCollectionViewDataSource {
         if self.data.count > indexPath.item {
             view.model = self.data[indexPath.item]
         }
+        
+        view.addAction = { [unowned self] view, item in
+            self.addAction?(view, item)
+        }
+        
+        view.removeAction = { [unowned self] view, item in
+            self.removeAction?(view, item)
+        }
+        
         return view
     }
-    
 }
 
 extension KMQucikToolsView: NSCollectionViewDelegateFlowLayout {
@@ -93,6 +129,39 @@ extension KMQucikToolsView: NSCollectionViewDelegateFlowLayout {
     }
     
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, insetForSectionAt section: Int) -> NSEdgeInsets {
-        return NSEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
+        return NSEdgeInsets(top: 10, left: 0, bottom: 10, right: 10)
+    }
+}
+
+//Collection Page
+extension KMQucikToolsView {
+    func pageCount() -> Int {
+        return Int(ceilf(Float(self.collectionView.frame.size.width / self.collectionView.visibleRect.size.width)))
+    }
+    
+    func currentPage() -> Int {
+        return Int(ceilf(Float(self.collectionView.visibleRect.origin.x / self.collectionView.visibleRect.size.width))) + 1
+    }
+    
+    func nextPage() {
+        let currentPage = self.currentPage()
+        let pageCount = self.pageCount()
+        if currentPage < pageCount {
+            self.collectionView.scroll(CGPoint(x: Int(self.collectionView.visibleRect.size.width) * currentPage, y: 0))
+            
+            guard let callBack = pageChange else { return }
+            callBack(self)
+        }
+    }
+    
+    func previousPage() {
+        let currentPage = self.currentPage()
+        let pageCount = self.pageCount()
+        if currentPage > 1 {
+            self.collectionView.scroll(CGPoint(x: Int(self.collectionView.visibleRect.size.width) * (currentPage - 2), y: 0))
+            
+            guard let callBack = pageChange else { return }
+            callBack(self)
+        }
     }
 }

+ 9 - 0
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/Model/KMQucikToolsModel.swift

@@ -48,6 +48,14 @@ class KMQucikToolsModel: NSObject {
         UserDefaults.standard.synchronize()
     }
     
+    func canAdd() -> Bool {
+        let array: [DataNavigationViewButtonActionType] = [.Background, .BatesCode, .Watermark, .HeaderAndFooter, .Security]
+        return array.contains(self.type!)
+    }
+}
+
+//Data
+extension KMQucikToolsModel {
     func titleString() -> String {
         var string = ""
         
@@ -167,6 +175,7 @@ class KMQucikToolsModel: NSObject {
             
         return NSImage(named: string) ?? NSImage()
     }
+
 }
 
 

+ 27 - 7
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift

@@ -7,6 +7,9 @@
 
 import Cocoa
 
+typealias KMQucikToolCollectionViewItemAddAction = (_ view: KMQucikToolCollectionViewItem, _ item: KMQucikToolsModel) -> Void
+typealias KMQucikToolCollectionViewItemRemoveAction = (_ view: KMQucikToolCollectionViewItem, _ item: KMQucikToolsModel) -> Void
+
 class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     @IBOutlet weak var contentBox: KMBox!
     @IBOutlet weak var iconImageView: NSImageView!
@@ -23,6 +26,9 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     @IBOutlet weak var tagLabel: NSTextField!
     
     
+    var addAction: KMQucikToolCollectionViewItemAddAction?
+    var removeAction: KMQucikToolCollectionViewItemRemoveAction?
+    
     var model: KMQucikToolsModel? {
         didSet {
             self.reloadData()
@@ -41,7 +47,9 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     func setup() {
         self.tagView.isHidden = true
         
+        self.handleView.backgroundColor(KMAppearance.Interactive.a0Color())
         self.handleView.isHidden = true
+        
         self.addBox.borderColor = KMAppearance.Layout.w70Color()
         self.addBox.borderWidth = 1.0
         
@@ -78,13 +86,15 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
         self.contentBox.fillColor = KMAppearance.Layout.l1Color()
         self.contentBox.moveCallback = { [unowned self] mouseEntered, mouseBox in
             if (mouseEntered) {
-//                if (blockSelf.mouseMoveCallback) {
-//                    blockSelf.mouseMoveCallback(YES);
-//                }
+                self.contentBox.fillColor = KMAppearance.Interactive.a0Color()
+                self.titleLabel.textColor = KMAppearance.Layout.w0Color()
+                self.subTitleLabel.textColor = KMAppearance.Layout.w70Color()
+                self.iconImageView.image = model?.iconImage(true)
             } else {
-//                if (blockSelf.mouseMoveCallback) {
-//                    blockSelf.mouseMoveCallback(NO);
-//                }
+                self.contentBox.fillColor = KMAppearance.Layout.l1Color()
+                self.titleLabel.textColor = KMAppearance.Layout.h0Color()
+                self.subTitleLabel.textColor = KMAppearance.Layout.h1Color()
+                self.iconImageView.image = model?.iconImage(false)
             }
         }
         
@@ -99,14 +109,18 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
         self.titleLabel.stringValue = model.titleString()
         self.subTitleLabel.stringValue = model.subTitleString()
         self.iconImageView.image = model.iconImage()
-        
     }
     
     @IBAction func removeButtonAction(_ sender: Any) {
+        guard let callBack = removeAction else { return }
         
+        callBack(self, model!)
     }
+    
     @IBAction func addButtonAction(_ sender: Any) {
+        guard let callBack = addAction else { return }
         
+        callBack(self, model!)
     }
     
 }
@@ -114,10 +128,16 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
 extension KMQucikToolCollectionViewItem {
     override func mouseEntered(with event: NSEvent) {
         self.view.backgroundColor(NSColor.green)
+        
+        
+        guard let model = self.model else { return }
+        self.handleView.isHidden = !model.canAdd()
     }
     
     override func mouseExited(with event: NSEvent) {
         self.view.backgroundColor(NSColor.red)
+        
+        self.handleView.isHidden = true
     }
     
 }

+ 11 - 28
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -242,31 +242,6 @@ extension KMHomeViewController {
         refreshRightBoxUI(.CloudDocuments)
     }
     
-    // 产品推广
-    func productPromotionFoldOrUnfold(_ sender: NSButton) {
-        var arr1: [NSString] = []
-        var arr2: [NSString] = []
-//        if sender.isEqual(to: pdfSeriesButtonVC.button) {
-//            if self.pdfProSeriesBoxHeightConstraint.constant == 0 {
-//                arr1 = self.productPromotionPDFProSeries as! [NSString]
-//            }
-//            if self.othersBoxHeightConstraint.constant > 0 {
-//                arr2 = self.productPromotionOthers as! [NSString]
-//            }
-//        }
-//        if sender.isEqual(to: self.pdfOthersButtonVC.button) {
-//            if self.pdfProSeriesBoxHeightConstraint.constant > 0 {
-//                arr1 = self.productPromotionPDFProSeries as! [NSString]
-//            }
-//            if self.othersBoxHeightConstraint.constant == 0 {
-//                arr2 = self.productPromotionOthers as! [NSString]
-//            }
-//        }
-        self.productPromotionShow(arr1 as NSArray, withOthers: arr2 as NSArray, isInitialize: false)
-        
-        refreshProductActiveSpacing()
-    }
-    
     func productPromotionClickAction(_ name: NSString) {
         var httpString: NSString = ""
         if name.isEqual(to: "Windows") {
@@ -326,8 +301,10 @@ extension KMHomeViewController {
                     NSDocumentController.shared.noteNewRecentDocumentURL(url)
                 }
             }
+            
+            self.homeContentView.historyListView.reloadData()
         }
-        historyFileViewController.reloadData()
+//        historyFileViewController.reloadData()
     }
     
     func openHistoryFilePath(url: URL) -> Void {
@@ -336,7 +313,8 @@ extension KMHomeViewController {
             alert.alertStyle = .critical
             alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
             alert.beginSheetModal(for: view.window!) { [unowned self] result in
-                self.historyFileViewController.reloadData()
+                self.homeContentView.historyListView.reloadData()
+//                self.historyFileViewController.reloadData()
             }
             return
         }
@@ -396,7 +374,8 @@ extension KMHomeViewController {
                 alert.alertStyle = .critical
                 alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
                 alert.beginSheetModal(for: view.window!) { [unowned self] result in
-                    self.historyFileViewController.reloadData()
+                    self.homeContentView.historyListView.reloadData()
+//                    self.historyFileViewController.reloadData()
                 }
             }
         } else {
@@ -451,6 +430,10 @@ extension KMHomeViewController {
             let savePath = fetchUniquePath(fileName.kUrlToPDFFolderPath() as String)
             openOfficeFile(url: path)
         }
+        
+        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
+            self.homeContentView.historyListView.reloadData()
+        }
     }
     
     func openImageFile(url: URL) -> Void {

+ 0 - 116
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+UI.swift

@@ -9,119 +9,6 @@ import Foundation
 
 extension KMHomeViewController {
     
-    // MARK: Private Methods
-    func productPromotionShow(_ pdfProSeries: NSArray, withOthers others: NSArray, isInitialize initialize: Bool) {
-//        if pdfProSeries.count > 0 {
-//            if (self.pdfProSeriesBoxHeightConstraint.constant == 0.0) || initialize {
-//                var height = CGFloat(pdfProSeries.count) * 32.0
-//                for name in pdfProSeries {
-//                    height -= 32.0
-//
-//                    let dict: Dictionary = self.productPromotionData[name] as! Dictionary<NSString, NSString>
-//                    let subBox = KMBox(frame: CGRect(origin: CGPoint(x: 0, y: height), size: CGSize(width: self.pdfProSeriesBox.frame.width, height: 32.0)))
-//                    subBox.boxType = .custom
-//                    subBox.borderWidth = 0.0
-//                    self.pdfProSeriesBox.contentView?.addSubview(subBox)
-//                    subBox.downCallback = {(downEntered, mouseBox, event) -> Void in
-//                        if downEntered {
-//                            self.productPromotionClickAction(dict["Name"]!)
-//                        }
-//                    }
-//
-//                    let subImageView = NSImageView(frame: NSZeroRect)
-//                    subImageView.image = NSImage(named: dict["Image"]! as NSImage.Name)
-//                    subBox.addSubview(subImageView)
-//                    subImageView.mas_makeConstraints { (make) in
-//                        make?.width.height().equalTo()(16)
-//                        make?.centerY.equalTo()(0)
-//                        make?.left.equalTo()(18)
-//                    }
-//
-//                    let subLabel = NSTextField(frame: NSZeroRect)
-//                    subLabel.isBezeled = false
-//                    subLabel.isEditable = false
-//                    subLabel.backgroundColor = .clear
-//                    let paragraphStyle = NSMutableParagraphStyle()
-//                    paragraphStyle.lineSpacing = 22.0
-//                    subLabel.attributedStringValue = NSAttributedString(string: dict["Name"]! as String, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
-//                    subLabel.font = NSFont(name: "SFProText-Regular", size: 14)
-//                    subLabel.textColor = NSColor.km_init(hex: "#616469")
-//                    subLabel.sizeToFit()
-//                    subBox.addSubview(subLabel)
-//                    subLabel.mas_makeConstraints { (make) in
-//                        make?.left.equalTo()(subImageView.mas_right)?.offset()(10)
-//                        make?.centerY.equalTo()(0)
-//                    }
-//                }
-//
-//                pdfSeriesButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
-//                self.pdfProSeriesBoxHeightConstraint.constant = CGFloat(pdfProSeries.count) * 32.0
-//            }
-//        } else {
-//            pdfSeriesButtonVC.image = NSImage(named: "icon_btn_expand_lv2_right_false")!
-//            self.pdfProSeriesBox.contentView = NSView.init()
-//            self.pdfProSeriesBoxHeightConstraint.constant = 0.0
-//        }
-//
-//        if others.count > 0 {
-//            if (self.othersBoxHeightConstraint.constant == 0.0) || initialize {
-//                var height = CGFloat(others.count) * 32.0
-//                for name in others {
-//                    height -= 32.0
-//
-//                    let dict: Dictionary = self.productPromotionData[name] as! Dictionary<NSString, NSString>
-//                    let subBox = KMBox(frame: CGRect(x: 0, y: height, width: self.othersBox.frame.width, height: 32.0))
-//                    subBox.boxType = .custom
-//                    subBox.borderWidth = 0.0
-//                    self.othersBox.contentView?.addSubview(subBox)
-//                    subBox.downCallback = {(downEntered, mouseBox, event) -> Void in
-//                        if downEntered {
-//                            self.productPromotionClickAction(dict["Name"]!)
-//                        }
-//                    }
-//
-//                    let subImageView = NSImageView(frame: NSZeroRect)
-//                    subImageView.image = NSImage(named: dict["Image"]! as NSImage.Name)
-//                    subImageView.imageScaling = .scaleProportionallyDown
-//                    subImageView.imageAlignment = .alignCenter
-//                    subImageView.sizeToFit()
-//                    subBox.addSubview(subImageView)
-//                    subImageView.mas_makeConstraints { (make) in
-//                        make?.width.height().equalTo()(16)
-//                        make?.centerY.equalTo()(0)
-//                        make?.left.equalTo()(18)
-//                    }
-//
-//                    let subLabel = NSTextField(frame: NSZeroRect)
-//                    subLabel.isBezeled = false
-//                    subLabel.isEditable = false
-//                    subLabel.backgroundColor = .clear
-//                    let paragraphStyle = NSMutableParagraphStyle()
-//                    paragraphStyle.lineSpacing = 22.0
-//                    subLabel.attributedStringValue = NSAttributedString(string: dict["Name"]! as String, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
-//                    subLabel.font = NSFont(name: "SFProText-Regular", size: 14)
-//                    subLabel.textColor = NSColor(red: 0.38, green: 0.392, blue: 0.412, alpha: 1.0)
-//                    subLabel.sizeToFit()
-//                    subBox.addSubview(subLabel)
-//                    subLabel.mas_makeConstraints { (make) in
-//                        make?.left.equalTo()(subImageView.mas_right)?.offset()(10)
-//                        make?.centerY.equalTo()(0)
-//                    }
-//                }
-//
-//                self.pdfOthersButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
-//                self.othersBoxHeightConstraint.constant = CGFloat(others.count) * 32.0
-//            }
-//        } else {
-//            self.pdfOthersButtonVC.image = NSImage(named: "icon_btn_expand_lv2_right_false")!
-//            self.othersBox.contentView = NSView.init()
-//            self.othersBoxHeightConstraint.constant = 0.0
-//        }
-//
-//        pdfSeriesButtonVC.updateUI()
-//        pdfOthersButtonVC.updateUI()
-    }
-    
     func refreshRightBoxUI(_ state: KMHomeToolState) {
         rightFullBox.isHidden = true
         rightTopBox.isHidden = true
@@ -431,9 +318,6 @@ extension KMHomeViewController: NSSplitViewDelegate {
         
         self.rightBox.frame = CGRect(origin: CGPoint(x: 271.0, y: 0), size: CGSize(width: rect.width - 271.0, height: rect.height))
         
-        refreshProductActiveSpacing()
-        
-//        refreshScrollView()
     }
     
     func splitView(_ splitView: NSSplitView, constrainSplitPosition proposedPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {

+ 31 - 91
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -73,11 +73,6 @@ import Cocoa
     
     var homeWindowController : MainWindowController!
     
-    // 产品推广数据
-    var productPromotionPDFProSeries: NSArray!
-    var productPromotionOthers: NSArray!
-    var productPromotionData: NSDictionary!
-    
     var isShowQuickTour: Bool = false
     var myDocument: NSDocument?
     var currentWindowController: NSWindowController?
@@ -129,17 +124,8 @@ import Cocoa
 
         self.homeSplitView.setPosition(270.0, ofDividerAt: 0)
         self.leftBox.fillColor = NSColor.km_init(hex: "#F7F8FA")
+        self.rightBox.fillColor = NSColor.km_init(hex: "#F7F8FA")
         
-        self.productPromotionPDFProSeries = ["Windows", "iPhone / iPad", "Android"]
-        self.productPromotionOthers = ["ComPDFKit", "SignFlow", "FiImage Editor", "FiImage Screen", "Free PDF Templates"]
-        self.productPromotionData = ["Windows": ["Name" : "Windows", "Image" : "icon_home_logo_windows", "link":""],
-                                     "iPhone / iPad" : ["Name" : "iPhone / iPad", "Image" : "icon_home_logo_mac", "link":""],
-                                     "Android" : ["Name" : "Android", "Image" : "icon_home_logo_android", "link":""],
-                                     "ComPDFKit" : ["Name" : "ComPDFKit", "Image" : "icon_home_logo_comPDFKit", "link":""],
-                                     "SignFlow" : ["Name" : "SignFlow", "Image" : "icon_home_logo_signflow", "link":""],
-                                     "FiImage Editor" : ["Name" : "FiImage Editor", "Image" : "icon_home_logo_editor", "link":""],
-                                     "FiImage Screen" : ["Name" : "FiImage Screen", "Image" : "icon_home_logo_screen", "link":""],
-                                     "Free PDF Templates" : ["Name" : "Free PDF Templates", "Image" : "icon_home_logo_templates"], "link":""]
         NSEvent.addLocalMonitorForEvents(matching: .leftMouseDown) { (aEvent) -> NSEvent? in
             self.otherMouseDown(with: aEvent)
             return aEvent
@@ -184,6 +170,7 @@ import Cocoa
     }
     
     func setup() {
+        //creatPDF
         self.creatPDFView.openPDFAction = { [unowned self] view, sender in
             self.openPDFAction(sender)
         }
@@ -192,76 +179,45 @@ import Cocoa
             self.creatPDFAction(sender)
         }
         
-        self.homeContentView.historyDidSelect = { [unowned self] view, url in
-            self.openFile(withFilePath: url)
+        //history
+        self.homeContentView.historyDidSelect = { [unowned self] view, item in
+            self.openHistoryFilePath(url: item.filePath!)
+        }
+        
+        self.homeContentView.historyRemoveFileAction = { [unowned self] view, item in
+            self.historyFile(deleteDocuments: [item.filePath!])
+        }
+        
+        self.homeContentView.historyShowPathAction = { [unowned self] view, item in
+            NSWorkspace.shared.open(item.filePath!.deletingLastPathComponent())
+        }
+        
+        self.homeContentView.historyRemoveAllFileAction = { [unowned self] view in
+            let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
+            self.historyFileDeleteAction(urls)
+        }
+        
+        //quciktools
+        self.homeContentView.qucikToolsDidSelect = { [unowned self] view, item in
+            self.fastToolItemAction(item.type!)
+        }
+        
+        self.homeContentView.qucikToolsAddAction = { [unowned self] view, item in
+            self.fastToolItemAction(item.type!)
+        }
+        
+        self.homeContentView.qucikToolsRemoveAction = { [unowned self] view, item in
+            self.fastToolItemAction(item.type!)
         }
     }
     
     // MARK: Init
     
     func initializeUI() {
-//        pdfToolsBox.fillColor = .clear
-//        pdfToolsBox.contentView = pdfToolsButtonVC.view
-//        pdfToolsButtonVC.target = self
-//        pdfToolsButtonVC.action = #selector(self.homeToolAction(_:))
-//        pdfToolsButtonVC.image = NSImage(named: "icon_home_sidebar_tool_false")!
-//        pdfToolsButtonVC.image_hover = NSImage(named: "icon_home_sidebar_tool_false")!
-//        pdfToolsButtonVC.image_click = NSImage(named: "icon_home_sidebar_tool_true")!
-//        pdfToolsButtonVC.navMenu(bg: "navmenu.has-icon.m.bg.norm", text: "navmenu.win-text.def", height: pdfToolsBoxHeight)
-//        pdfToolsButtonVC.navMenu(bg: "navmenu.has-icon.m.bg.hov", text: "navmenu.win-text.def", state:.Hov)
-//        pdfToolsButtonVC.navMenu(bg: "navmenu.has-icon.m.bg.sel", text: "navmenu.win-text.sel", state:.Sel)
-//        
-//        cloudDocumentsBox.fillColor = .clear
-//        cloudDocumentsBox.contentView = cloudDocumentsButtonVC.view
-//        cloudDocumentsButtonVC.target = self
-//        cloudDocumentsButtonVC.action = #selector(self.homeToolAction(_:))
-//        cloudDocumentsButtonVC.image = NSImage(named: "icon_home_sidebar_cloud_false")!
-//        cloudDocumentsButtonVC.image_hover = NSImage(named: "icon_home_sidebar_cloud_false")!
-//        cloudDocumentsButtonVC.image_click = NSImage(named: "icon_home_sidebar_cloud_true")!
-//        cloudDocumentsButtonVC.navMenu(bg: "navmenu.has-icon.m.bg.norm", text: "navmenu.win-text.def", height: cloudDocumentsBoxHeight)
-//        cloudDocumentsButtonVC.navMenu(bg: "navmenu.has-icon.m.bg.hov", text: "navmenu.win-text.def", state:.Hov)
-//        cloudDocumentsButtonVC.navMenu(bg: "navmenu.has-icon.m.bg.sel", text: "navmenu.win-text.sel", state:.Sel)
-//
-//        pdfSeriesBox.fillColor = .clear
-//        pdfSeriesBox.contentView = pdfSeriesButtonVC.view
-//        pdfSeriesButtonVC.target = self
-//        pdfSeriesButtonVC.action = #selector(self.productPromotionFoldOrUnfold(_:))
-//        pdfSeriesButtonVC.type = .Right
-//        pdfSeriesButtonVC.canHover = false
-//        pdfSeriesButtonVC.imageWidth = 12.0
-//        pdfSeriesButtonVC.imageHeight = 12.0
-//        pdfSeriesButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
-//        pdfSeriesButtonVC.navMenu(bg: "collapse.ad-list.bg", text: "collapse.ad-list.mac-text.norm", height: pdfSeriesBoxHeight)
-//
-//        pdfOthersBox.fillColor = .clear
-//        pdfOthersBox.contentView = pdfOthersButtonVC.view
-//        pdfOthersButtonVC.target = self
-//        pdfOthersButtonVC.action = #selector(self.productPromotionFoldOrUnfold(_:))
-//        pdfOthersButtonVC.type = .Right
-//        pdfOthersButtonVC.canHover = false
-//        pdfOthersButtonVC.imageWidth = 12.0
-//        pdfOthersButtonVC.imageHeight = 12.0
-//        pdfOthersButtonVC.image = NSImage(named: "icon_btn_expand_lv2_down_false")!
-//        pdfOthersButtonVC.navMenu(bg: "collapse.ad-list.bg", text: "collapse.ad-list.mac-text.norm", height: othersBoxHeightConstraint)
-
-//        if self.activitiesBox.isHidden {
-//            self.productPromotionShow(self.productPromotionPDFProSeries, withOthers: self.productPromotionOthers, isInitialize: true)
-//        } else {
-//            self.productPromotionShow(self.productPromotionPDFProSeries, withOthers: [], isInitialize: true)
-//        }
-        self.productPromotionShow(self.productPromotionPDFProSeries, withOthers: self.productPromotionOthers, isInitialize: true)
-        
-//        self.activitiesBox.contentView = KMProductPromotionViewController.init().view
-//        activitiesBox.cornerRadius = 8.0
-        
         rightTopBox.fillColor = .white
         rightBottomBox.fillColor = .white
         rightFullBox.fillColor = .white
         
-//        productPromotionBox.fillColor = .clear
-//        
-//        product_active_scrollView.verticalScrollElasticity = .none
-        
         self.refreshRightBoxUI(.Home)
         fastToolViewController.delete = self
         historyFileViewController.delete = self
@@ -401,12 +357,6 @@ import Cocoa
         dragView.delete = self
     }
     
-    // MARK: Action
-    
-    @IBAction func productPromotionButtonAction(_ sender: NSButton) {
-        self.productPromotionFoldOrUnfold(sender)
-    }
-    
     // MARK: Public Methods
     
     func savePDFDocument(_ pdf: CPDFDocument, password: String) -> Void {
@@ -524,16 +474,6 @@ import Cocoa
         }
     }
     
-    func refreshProductActiveSpacing() -> Void {
-//        let height = self.view.frame.height - 32.0 - openPDFBoxHeight.constant - 16.0 - createPDFBoxHeight.constant - 24.0 - pdfSeriesBoxHeight.constant - pdfProSeriesBoxHeightConstraint.constant - 8 - othersBoxHeightConstraint.constant - pdfOthersBoxHeightConstraint.constant - 242 - 30
-////        print("height == %f", height)
-//        if height > 24.0 {
-//            self.product_active_spacing.constant = height
-//        } else {
-//            self.product_active_spacing.constant = 24.0
-//        }
-    }
-    
     func fetchDifferentFilePath(filePath: String) -> String {
         var resultFilePath = filePath
         var index: Int = 0

+ 35 - 35
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -51,39 +51,6 @@
             <rect key="frame" x="0.0" y="0.0" width="1074" height="820"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
-                <customView translatesAutoresizingMaskIntoConstraints="NO" id="3Ej-3j-QZ3" customClass="KMHomeDragView" customModule="PDF_Master" customModuleProvider="target">
-                    <rect key="frame" x="16" y="16" width="1042" height="788"/>
-                    <subviews>
-                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="lTX-FO-7Ze">
-                            <rect key="frame" x="489" y="374" width="65" height="40"/>
-                            <subviews>
-                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hn2-R8-Bfv">
-                                    <rect key="frame" x="14" y="12" width="37" height="16"/>
-                                    <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="gkz-Hj-UOJ">
-                                        <font key="font" metaFont="system"/>
-                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                    </textFieldCell>
-                                </textField>
-                            </subviews>
-                            <constraints>
-                                <constraint firstItem="Hn2-R8-Bfv" firstAttribute="centerY" secondItem="lTX-FO-7Ze" secondAttribute="centerY" id="0mX-xj-ymp"/>
-                                <constraint firstAttribute="trailing" secondItem="Hn2-R8-Bfv" secondAttribute="trailing" constant="16" id="8ZE-Sq-o1b"/>
-                                <constraint firstItem="Hn2-R8-Bfv" firstAttribute="leading" secondItem="lTX-FO-7Ze" secondAttribute="leading" constant="16" id="VWe-FK-0wL"/>
-                                <constraint firstAttribute="height" constant="40" id="tbq-SH-11p"/>
-                            </constraints>
-                        </customView>
-                    </subviews>
-                    <constraints>
-                        <constraint firstItem="lTX-FO-7Ze" firstAttribute="centerY" secondItem="3Ej-3j-QZ3" secondAttribute="centerY" id="VsN-Nk-XSF"/>
-                        <constraint firstItem="lTX-FO-7Ze" firstAttribute="centerX" secondItem="3Ej-3j-QZ3" secondAttribute="centerX" id="Z88-ci-g4b"/>
-                    </constraints>
-                    <connections>
-                        <outlet property="dragLabel" destination="Hn2-R8-Bfv" id="Bcu-KC-jTb"/>
-                        <outlet property="dragView" destination="lTX-FO-7Ze" id="l8P-gG-51q"/>
-                        <outlet property="dragViewHeight" destination="tbq-SH-11p" id="rKn-sf-EOE"/>
-                    </connections>
-                </customView>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1v2-87-qa4">
                     <rect key="frame" x="537" y="410" width="0.0" height="0.0"/>
                     <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyDown" inset="2" id="Qq0-z1-7iI">
@@ -415,6 +382,39 @@ Gw
                         <outlet property="delegate" destination="-2" id="Nyn-SM-8if"/>
                     </connections>
                 </splitView>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="3Ej-3j-QZ3" customClass="KMHomeDragView" customModule="PDF_Master" customModuleProvider="target">
+                    <rect key="frame" x="16" y="16" width="1042" height="788"/>
+                    <subviews>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="lTX-FO-7Ze">
+                            <rect key="frame" x="489" y="374" width="65" height="40"/>
+                            <subviews>
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hn2-R8-Bfv">
+                                    <rect key="frame" x="14" y="12" width="37" height="16"/>
+                                    <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="gkz-Hj-UOJ">
+                                        <font key="font" metaFont="system"/>
+                                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                    </textFieldCell>
+                                </textField>
+                            </subviews>
+                            <constraints>
+                                <constraint firstItem="Hn2-R8-Bfv" firstAttribute="centerY" secondItem="lTX-FO-7Ze" secondAttribute="centerY" id="0mX-xj-ymp"/>
+                                <constraint firstAttribute="trailing" secondItem="Hn2-R8-Bfv" secondAttribute="trailing" constant="16" id="8ZE-Sq-o1b"/>
+                                <constraint firstItem="Hn2-R8-Bfv" firstAttribute="leading" secondItem="lTX-FO-7Ze" secondAttribute="leading" constant="16" id="VWe-FK-0wL"/>
+                                <constraint firstAttribute="height" constant="40" id="tbq-SH-11p"/>
+                            </constraints>
+                        </customView>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="lTX-FO-7Ze" firstAttribute="centerY" secondItem="3Ej-3j-QZ3" secondAttribute="centerY" id="VsN-Nk-XSF"/>
+                        <constraint firstItem="lTX-FO-7Ze" firstAttribute="centerX" secondItem="3Ej-3j-QZ3" secondAttribute="centerX" id="Z88-ci-g4b"/>
+                    </constraints>
+                    <connections>
+                        <outlet property="dragLabel" destination="Hn2-R8-Bfv" id="Bcu-KC-jTb"/>
+                        <outlet property="dragView" destination="lTX-FO-7Ze" id="l8P-gG-51q"/>
+                        <outlet property="dragViewHeight" destination="tbq-SH-11p" id="rKn-sf-EOE"/>
+                    </connections>
+                </customView>
             </subviews>
             <constraints>
                 <constraint firstItem="3Ej-3j-QZ3" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="16" id="DZ1-ex-OuL"/>

+ 31 - 5
PDF Office/PDF Master/Class/KMAdvertisement/View/Tableview/Cell/KMAdvertisementCollectionViewItem.swift

@@ -36,13 +36,23 @@ class KMAdvertisementCollectionViewItem: NSCollectionViewItem {
     }
     
     func updateColor(_ highlight: Bool) {
-        
+        self.view.appearance = NSAppearance(named: .aqua)
         if highlight {
-            self.titleLabel.textColor = KMAppearance.Layout.mColor()
-            self.contentView.layer?.backgroundColor = KMAppearance.Status.hovColor().cgColor
+            if KMAdvertisementConfig.isDarkModel() {
+                self.titleLabel.textColor = NSColor.km_init(hex: "#4E7EDB")
+                self.contentView.backgroundColor(NSColor.km_init(hex: "#FFFFFF", alpha: 0.05))
+            } else {
+                self.titleLabel.textColor = NSColor.km_init(hex: "#273C62")
+                self.contentView.backgroundColor(NSColor.km_init(hex: "#000000", alpha: 0.05))
+            }
         } else {
-            self.titleLabel.textColor = KMAppearance.Layout.h1Color()
-            self.contentView.layer?.backgroundColor = KMAppearance.Layout.l0Color().cgColor
+            if KMAdvertisementConfig.isDarkModel() {
+                self.contentView.backgroundColor(NSColor.km_init(hex: "#26282B"))
+                self.titleLabel.textColor = NSColor.km_init(hex: "#C8C9CC")
+            } else {
+                self.contentView.backgroundColor(NSColor.km_init(hex: "#FCFDFF"))
+                self.titleLabel.textColor = NSColor.km_init(hex: "#42464D")
+            }
         }
         
         let url = URL(string: KMAdvertisementModelTransition.transitionImagePath(image: model?.image, highlight: highlight))
@@ -51,6 +61,22 @@ class KMAdvertisementCollectionViewItem: NSCollectionViewItem {
         })
     }
     
+//    func updateColor(_ highlight: Bool) {
+//        
+//        if highlight {
+//            self.titleLabel.textColor = KMAppearance.Layout.mColor()
+//            self.contentView.layer?.backgroundColor = KMAppearance.Status.hovColor().cgColor
+//        } else {
+//            self.titleLabel.textColor = KMAppearance.Layout.h1Color()
+//            self.contentView.layer?.backgroundColor = KMAppearance.Layout.l0Color().cgColor
+//        }
+//        
+//        let url = URL(string: KMAdvertisementModelTransition.transitionImagePath(image: model?.image, highlight: highlight))
+//        self.iconImageView.image = KMAdvertisementImage.imageWithURL(url: url, completion: { [weak self] image in
+//            self?.iconImageView.image = image
+//        })
+//    }
+    
     override func mouseEntered(with event: NSEvent) {
         self.updateColor(true)
     }

+ 3 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarController.swift

@@ -712,6 +712,9 @@ extension KMToolbarController: KMToolbarViewControllerDelegate {
     }
     
     func toolbarViewController(_ viewController: KMToolbarViewController, itemDidClick toolbarItem: KMToolbarItemView) {
+        if toolbarItem.itemIdentifier == KMDocumentViewDisplayToolbarItemIdentifier {
+            self.toolbarType = .viewSetting
+        }
         self.delegate?.toolbarViewController?(viewController, itemDidClick: toolbarItem)
     }
     

+ 129 - 218
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift

@@ -21,7 +21,6 @@ extension KMToolbarItemView {
 }
 
 @objcMembers class KMToolbarItemView: NSView {
-    
     var menuFormRepresentation: NSMenuItem?
     
     private var _itemIdentifier: String?
@@ -32,25 +31,18 @@ extension KMToolbarItemView {
     }
     
     lazy var clickButton: KMToolbarClickButton = {
-        let _clickButton = KMToolbarClickButton()
-        _clickButton.bezelStyle = .regularSquare
-        _clickButton.isBordered = false
-        _clickButton.imagePosition = .imageOnly
-        _clickButton.clickObject = self
-        return _clickButton
+        let view = KMToolbarClickButton()
+        view.bezelStyle = .regularSquare
+        view.isBordered = false
+        view.imagePosition = .imageOnly
+        view.clickObject = self
+        return view
     }()
     
     var isSelected = false {
         didSet {
             if self.itemIdentifier != KMToolbarDividerItemIdentifier {
                 if (isSelected) {
-                    if (isMainTool) {
-//                        self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
-                        self.imageViewBox.fillColor = self.normalBackgroundColor
-                        self.nameBtn.setTitleColor(color: KMAppearance.titleColor(), font: .SFProTextSemiboldFont(14))
-                        self.linView.isHidden = false
-                        return
-                    }
 //                    self.layer?.backgroundColor = self.selectedBackgroundColor.cgColor
                     self.imageViewBox.fillColor = self.selectedBackgroundColor
                     if(self.image != nil && self.alternateImage != nil) {
@@ -67,13 +59,6 @@ extension KMToolbarItemView {
                         self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownSel")
                     }
                 } else {
-                    if (isMainTool) {
-//                        self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
-                        self.imageViewBox.fillColor = self.normalBackgroundColor
-                        self.nameBtn.setTitleColor(color: NSColor(red: 97.0/255.0, green: 100.0/255.0, blue: 105.0/255.0, alpha: 1.0),font: .SFProTextRegularFont(14))
-                        self.linView.isHidden = true
-                        return
-                    }
 //                    self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
                     self.imageViewBox.fillColor = self.normalBackgroundColor
                     if (self.needExpandAction) {
@@ -148,58 +133,42 @@ extension KMToolbarItemView {
             self._layoutView()
         }
     }
-    var isMainTool = false {
-        didSet {
-            if (isMainTool) {
-                self.nameBtn.setTitleColor(color: NSColor(red: 97.0/255.0, green: 100.0/255.0, blue: 105.0/255.0, alpha: 1), font: .SFProTextRegularFont(14))
-            } else {
-                self.nameBtn.setTitleColor(color: KMAppearance.titleColor())
-            }
-            self._layoutView()
-        }
-    }
-    
-    var linView: NSView = {
-        let _linView = NSView()
-        _linView.wantsLayer = true
-        _linView.layer?.backgroundColor = NSColor(red: 23/255.0, green: 112/255.0, blue: 244/255.0, alpha: 1).cgColor
-        _linView.layer?.cornerRadius = 2
-        return _linView
-    }()
   
     var normalBackgroundColor: NSColor = .clear
     var selectedBackgroundColor: NSColor = KMAppearance.Status.selColor()
     
-    var imageViewBox: NSBox = {
-        let _imageViewBox = NSBox()
-        _imageViewBox.borderWidth = 0
-        _imageViewBox.contentViewMargins = NSZeroSize
-        _imageViewBox.boxType = .custom
-        return _imageViewBox
+    lazy var imageViewBox: NSBox = {
+        let view = NSBox()
+        view.borderWidth = 0
+        view.contentViewMargins = NSSize.zero
+        view.boxType = .custom
+        view.borderColor = .clear
+        view.cornerRadius = 7.0
+        return view
     }()
     private lazy var imageViewBtn: NSButton = {
-        let _imageViewBtn = NSButton()
-        _imageViewBtn.bezelStyle = .regularSquare
-        _imageViewBtn.isBordered = false
-        _imageViewBtn.imagePosition = .imageOnly
-        return _imageViewBtn
+        let view = NSButton()
+        view.bezelStyle = .regularSquare
+        view.isBordered = false
+        view.imagePosition = .imageOnly
+        return view
     }()
     private var nameBtn: NSButton = {
-        let _nameBtn = NSButton()
-        _nameBtn.bezelStyle = .regularSquare
-        _nameBtn.isBordered = false
-        _nameBtn.imagePosition = .imageOnly
-        _nameBtn.font = .systemFont(ofSize: 12)
-        _nameBtn.title = ""
-        return _nameBtn
+        let view = NSButton()
+        view.bezelStyle = .regularSquare
+        view.isBordered = false
+        view.imagePosition = .imageOnly
+        view.font = .systemFont(ofSize: 12)
+        view.title = ""
+        return view
     }()
     private var needExpandButton: NSButton = {
-        let _needExpandButton = NSButton()
-        _needExpandButton.bezelStyle = .regularSquare
-        _needExpandButton.isBordered = false
-        _needExpandButton.imagePosition = .imageOnly
-        _needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
-        return _needExpandButton
+        let view = NSButton()
+        view.bezelStyle = .regularSquare
+        view.isBordered = false
+        view.imagePosition = .imageOnly
+        view.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
+        return view
     }()
     private var _popOver: NSPopover?
     var popOver: NSPopover? {
@@ -240,9 +209,6 @@ extension KMToolbarItemView {
         self.layer?.cornerRadius = 5
         self.layer?.masksToBounds = true
         
-//        self.normalBackgroundColor = .clear
-//        self.selectedBackgroundColor = NSColor(red: 223.0/255.0, green: 225.0/255.0, blue: 229.0/255.0, alpha: 1)
-        
         self._addTrackingArea()
         NotificationCenter.default.addObserver(self, selector: #selector(_windowClosedPop), name: KMToolbarItemView.popOverClosedNotificationName, object: nil)
     }
@@ -257,9 +223,6 @@ extension KMToolbarItemView {
         self.layer?.cornerRadius = 4
         self.layer?.masksToBounds = true
         
-//        self.normalBackgroundColor = .clear
-//        self.selectedBackgroundColor = NSColor(red: 223.0/255.0, green: 225.0/255.0, blue: 229.0/255.0, alpha: 1)
-        
         self._addTrackingArea()
         self._layoutView()
         if (popMenuViewController != nil) {
@@ -293,13 +256,6 @@ extension KMToolbarItemView {
         }
     }
     
-    // MARK: - Private Methods
-    
-    private func _addTrackingArea() {
-        let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .inVisibleRect, .activeInKeyWindow], owner: self)
-        self.addTrackingArea(trackingArea)
-    }
-    
     override func mouseEntered(with event: NSEvent) {
         super.mouseEntered(with: event)
         
@@ -325,7 +281,8 @@ extension KMToolbarItemView {
             }
         }
         if (self.needExpandAction) {
-            self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownSel")
+            // KMImageNameUXIconBtnTriDownSel
+            self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
             self._showPop(self)
         }else if (self.isShowCustomToolTip) {
             self.perform(#selector(_showHUDHint), with: nil, afterDelay: 0.1)
@@ -359,7 +316,7 @@ extension KMToolbarItemView {
             return
         }
         
-        if(self.nameBtn.superview != nil && !self.isSelected && !self.isMainTool) {
+        if(self.nameBtn.superview != nil && !self.isSelected) {
             self.nameBtn.setTitleColor(color: KMAppearance.titleColor())
         }
         
@@ -368,27 +325,20 @@ extension KMToolbarItemView {
             self._closePop()
         }
     }
-    
-    @objc private func _showHUDHint() {
-        //    KMToolbarItemPopViewController *popViewController = [[[KMToolbarItemPopViewController alloc] init] autorelease];
-        //    self.popOver = [[[NSPopover alloc] init] autorelease];
-        //    self.popOver.contentViewController = popViewController;
-        //    self.popOver.animates = NO;
-        //    self.popOver.behavior = NSPopoverBehaviorSemitransient;
-        //    self.popOver.backgroundColor = [KMAppearance KMBluegrey01Color];
-        //
-        //    self.popOver.contentSize = popViewController.view.frame.size;
-        //    [popViewController updateWithHelpTip:self.originalHelpTip];
-        //    [self.popOver showRelativeToRect:self.bounds ofView:self preferredEdge:NSRectEdgeMinY];
-    }
-    
-    @objc private func _windowClosedPop(sender: Notification) {
-        if let data = self._popOver?.isEqual(to: sender.object), data {
-            self.popOver = nil
-        }
+}
+
+// MARK: - Private Methods
+
+extension KMToolbarItemView {
+    private func _addTrackingArea() {
+        let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .inVisibleRect, .activeInKeyWindow], owner: self)
+        self.addTrackingArea(trackingArea)
     }
     
     private func _showPop(_ sender: NSView) {
+        if (self._popOver != nil) {
+            return
+        }
         let menuViewController = KMCustomButtonPopMenuViewController()
         menuViewController.delegate = self
         menuViewController.dataSources = self
@@ -400,13 +350,14 @@ extension KMToolbarItemView {
         self.popOver?.contentSize = menuViewController.view.frame.size
         
         var sourcesRect = sender.bounds
-        sourcesRect.size = sender.convert(sourcesRect.size, to: nil)
-        sourcesRect.origin.y -= 20
+        sourcesRect = sender.convert(sourcesRect, to: nil)
+//        sourcesRect.size = sender.convert(sourcesRect.size, to: nil)
+        sourcesRect.origin.y += 20
         sourcesRect.size.height += 20
         self.window?.popover = self.popOver
         self.window?.sourcesRect = sourcesRect
         
-        self.popOver?.show(relativeTo: CGRectInset(self.bounds, 0, 5), of: self, preferredEdge: .maxY)
+        self.popOver?.show(relativeTo: CGRectInset(self.bounds, 0, 5), of: self, preferredEdge: .minY)
     }
     
     private func _closePop() {
@@ -414,17 +365,29 @@ extension KMToolbarItemView {
         self.popOver = nil
     }
     
+    @objc private func _showHUDHint() {
+        //    KMToolbarItemPopViewController *popViewController = [[[KMToolbarItemPopViewController alloc] init] autorelease];
+        //    self.popOver = [[[NSPopover alloc] init] autorelease];
+        //    self.popOver.contentViewController = popViewController;
+        //    self.popOver.animates = NO;
+        //    self.popOver.behavior = NSPopoverBehaviorSemitransient;
+        //    self.popOver.backgroundColor = [KMAppearance KMBluegrey01Color];
+        //
+        //    self.popOver.contentSize = popViewController.view.frame.size;
+        //    [popViewController updateWithHelpTip:self.originalHelpTip];
+        //    [self.popOver showRelativeToRect:self.bounds ofView:self preferredEdge:NSRectEdgeMinY];
+    }
+    
+    @objc private func _windowClosedPop(sender: Notification) {
+        if let data = self._popOver?.isEqual(to: sender.object), data {
+            self.popOver = nil
+        }
+    }
+    
     private func _layoutView() {
-        let offset = 4.0
-        let offsetY = 2.0
-        let offsetX = 4.0
         if self.nameBtn.superview != nil {
             self.nameBtn.removeFromSuperview()
         }
-        if self.linView.superview != nil {
-            self.linView.removeFromSuperview()
-        }
-        
         if self.imageViewBox.superview != nil {
             self.imageViewBox.removeFromSuperview()
         }
@@ -432,97 +395,79 @@ extension KMToolbarItemView {
             self.imageViewBtn.removeFromSuperview()
         }
         
-        if self.customizeView != nil {
-            if self.customizeView?.superview != nil {
-                self.customizeView?.removeFromSuperview()
+        if let view = self.customizeView {
+            if view.superview != nil {
+                view.removeFromSuperview()
             }
-            self.addSubview(self.customizeView!)
-            
-            self.customizeView?.mas_makeConstraints({ make in
-                make?.left.right().equalTo()(0)
-                make?.centerY.equalTo()(0)
-                make?.width.offset()(self.customizeView!.frame.size.width)
-                make?.height.offset()(self.customizeView!.frame.size.height)
-            })
+            self.addSubview(view)
+            view.km_add_leading_constraint()
+            view.km_add_trailing_constraint()
+            view.km_add_centerY_constraint()
+            view.km_add_width_constraint(constant: NSWidth(view.bounds))
+            view.km_add_height_constraint(constant: NSHeight(view.bounds))
+            return
+        } else if (self.itemIdentifier == KMToolbarDividerItemIdentifier) {
+            self.addSubview(self.imageViewBox)
+            self.imageViewBox.km_add_inset_constraint(inset: NSEdgeInsetsZero)
+            self.imageViewBox.km_add_width_constraint(constant: 8)
             return
         }
-        if self.boxImagePosition == .imageOnly && self.itemIdentifier != KMToolbarDividerItemIdentifier {
+        
+        let offset = 4.0
+        let offsetY = 2.0
+        let offsetX = 4.0
+        if self.boxImagePosition == .imageOnly {
             self.addSubview(self.imageViewBox)
-            self.imageViewBox.mas_makeConstraints { make in
-                make?.left.right().top().bottom().equalTo()(0)
-            }
+            self.imageViewBox.km_add_inset_constraint()
             
             self.imageViewBox.contentView?.addSubview(self.imageViewBtn)
-            self.imageViewBtn.mas_makeConstraints { make in
-                make?.left.equalTo()(self.imageViewBox.mas_left)?.offset()(offsetX)
-                make?.top.equalTo()(self.imageViewBox.mas_top)?.offset()(offsetY)
-                make?.bottom.equalTo()(self.imageViewBox.mas_bottom)?.offset()(-offsetY)
-                make?.right.equalTo()(self.imageViewBox.mas_right)?.offset()(-offsetX)
-            }
+            self.imageViewBtn.km_add_inset_constraint(equalTo: self.imageViewBox, inset: NSEdgeInsets(top: offsetY, left: offsetX, bottom: offsetY, right: offsetX))
         } else if (self.boxImagePosition == .imageLeft) {
             self.addSubview(self.imageViewBox)
-            self.imageViewBox.mas_makeConstraints { make in
-                make?.left.top().bottom().equalTo()(0)
-            }
+            self.imageViewBox.km_add_leading_constraint()
+            self.imageViewBox.km_add_top_constraint()
+            self.imageViewBox.km_add_bottom_constraint()
             
             self.imageViewBox.contentView?.addSubview(self.imageViewBtn)
-            self.imageViewBtn.mas_makeConstraints { make in
-                make?.left.equalTo()(self.imageViewBox.mas_left)?.offset()(2 * offsetX)
-                make?.top.equalTo()(self.imageViewBox.mas_top)?.offset()(offsetY)
-                make?.bottom.equalTo()(self.imageViewBox.mas_bottom)?.offset()(-offsetY)
-                make?.right.equalTo()(0)
-            }
+            self.imageViewBtn.km_add_inset_constraint(equalTo: self.imageViewBox, inset: NSEdgeInsets(top: offsetY, left: 2*offsetX, bottom: offsetY, right: 0))
             
             self.addSubview(self.nameBtn)
-            self.nameBtn.mas_makeConstraints { make in
-                make?.centerY.equalTo()(0)
-                make?.left.equalTo()(self.imageViewBox.mas_right)?.offset()(0)
-                if (self.needExpandAction) {
-                    make?.right.equalTo()(self.mas_right)?.offset()(-2*offsetX-8)
-                } else {
-                    make?.right.equalTo()(self.mas_right)?.offset()(-2*offsetX)
-                }
+            self.nameBtn.km_add_centerY_constraint()
+            self.nameBtn.km_add_leading_constraint(equalTo: self.imageViewBox, attribute: .trailing)
+            if (self.needExpandAction) {
+                self.nameBtn.km_add_right_constraint(constant: -2*offsetX-8)
+            } else {
+                self.nameBtn.km_add_right_constraint(constant: -2*offsetX)
             }
             
             if(self.needExpandAction) {
                 self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
                 self.addSubview(self.needExpandButton)
-                self.needExpandButton.mas_makeConstraints { make in
-                    make?.centerY.equalTo()(0)
-                    make?.width.height().equalTo()(8)
-                    make?.right.equalTo()(self.mas_right)?.offset()(-offset)
-                }
+                self.needExpandButton.km_add_centerY_constraint()
+                self.needExpandButton.km_add_width_constraint(constant: 8)
+                self.needExpandButton.km_add_right_constraint(constant: -offset)
             }
             
             self.layer?.cornerRadius = 6
         } else if (self.boxImagePosition == .imageExpandLeft) {
             self.addSubview(self.imageViewBox)
-            self.imageViewBox.mas_makeConstraints { make in
-                make?.left.top().bottom().equalTo()(0)
-            }
+            self.imageViewBox.km_add_leading_constraint()
+            self.imageViewBox.km_add_top_constraint()
+            self.imageViewBox.km_add_bottom_constraint()
 
             self.imageViewBox.contentView?.addSubview(self.imageViewBtn)
-            self.imageViewBtn.mas_makeConstraints { make in
-                make?.left.equalTo()(self.imageViewBox.mas_left)?.offset()(offsetX)
-                make?.top.equalTo()(self.imageViewBox.mas_top)?.offset()(offsetY)
-                make?.bottom.equalTo()(self.imageViewBox.mas_bottom)?.offset()(-offsetY)
-                make?.right.equalTo()(0)
-            }
+            self.imageViewBtn.km_add_inset_constraint(equalTo: self.imageViewBox, inset: NSEdgeInsets(top: offsetY, left: offsetX, bottom: offsetY, right: 0))
 
             self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
             self.addSubview(self.needExpandButton)
-            self.needExpandButton.mas_makeConstraints { make in
-                make?.centerY.equalTo()(0)
-                make?.width.height().equalTo()(8)
-                make?.right.equalTo()(self.mas_right)?.offset()(-offset)
-            }
+            self.needExpandButton.km_add_centerY_constraint()
+            self.needExpandButton.km_add_width_constraint(constant: 8)
+            self.needExpandButton.km_add_right_constraint(constant: -offset)
 
             self.addSubview(self.nameBtn)
-            self.nameBtn.mas_makeConstraints { make in
-                make?.centerY.equalTo()(0)
-                make?.left.equalTo()(self.imageViewBox.mas_right)?.offset()(0)
-                make?.right.equalTo()(self.needExpandButton.mas_left)?.offset()(0)
-            }
+            self.nameBtn.km_add_centerY_constraint()
+            self.nameBtn.km_add_leading_constraint(equalTo: self.imageViewBox, attribute: .trailing)
+            self.nameBtn.km_add_trailing_constraint(equalTo: self.needExpandButton, attribute: .leading)
         } else if (self.boxImagePosition == .imageAbove) {
             self.addSubview(self.nameBtn)
             self.nameBtn.alignment = .center
@@ -531,66 +476,32 @@ extension KMToolbarItemView {
                 make?.width.greaterThanOrEqualTo()(32)
                 make?.bottom.equalTo()(self.mas_bottom)?.offset()(0)
             }
+//            self.nameBtn.km_add_leading_constraint()
+//            self.nameBtn.km_add_trailing_constraint()
+//            self.nameBtn.km_add_bottom_constraint()
             
             self.addSubview(self.imageViewBox)
-            self.imageViewBox.mas_makeConstraints { make in
-                make?.top.equalTo()(0)
-                make?.width.equalTo()(32)
-                make?.centerX.equalTo()(0)
-                make?.bottom.equalTo()(nameBtn.mas_top)?.offset()(0)
-            }
+            self.imageViewBox.km_add_top_constraint()
+            self.imageViewBox.km_add_width_constraint(constant: 32)
+            self.imageViewBox.km_add_centerX_constraint()
+            self.imageViewBox.km_add_bottom_constraint(equalTo: self.nameBtn, attribute: .top, constant: 0)
         
             self.imageViewBox.contentView?.addSubview(self.imageViewBtn)
-            self.imageViewBtn.mas_makeConstraints { make in
-                make?.left.equalTo()(offset)
-                make?.right.equalTo()(-offset)
-                make?.top.equalTo()(0)
-                make?.bottom.equalTo()(0)
-            }
-        } else {
-            if (self.itemIdentifier == KMToolbarDividerItemIdentifier) {
-                self.addSubview(self.imageViewBox)
-                self.imageViewBox.mas_makeConstraints { make in
-                    make?.top.equalTo()(0)
-                    make?.width.equalTo()(8)
-                    make?.left.equalTo()(0)
-                    make?.right.equalTo()(0)
-                    make?.bottom.equalTo()(self.mas_bottom)?.offset()(0)
-                }
-            }
-
+            self.imageViewBtn.km_add_inset_constraint(inset: .init(top: 0, left: offset, bottom: 0, right: offset))
         }
-
-        if self.nameBtn.superview != nil && self.isMainTool {
-            self.addSubview(self.linView)
-            self.linView.mas_makeConstraints { make in
-                make?.width.offset()(32)
-                make?.height.offset()(3)
-                make?.centerX.equalTo()(self.mas_centerX)
-                make?.bottom.equalTo()(self.mas_bottom)?.offset()(0)
-            }
-            
-            self.nameBtn.font = .systemFont(ofSize: 14)
-            self.linView.isHidden = true
-        } else {
-            self.nameBtn.font = .systemFont(ofSize: 12)
-        }
-        
-        if self.itemIdentifier != KMToolbarDividerItemIdentifier {
-            self.imageViewBox.borderColor = .clear
-            self.imageViewBox.borderWidth = 1.0
-            self.imageViewBox.cornerRadius = 7.0
             
-            self.addSubview(self.clickButton)
-            self.clickButton.mas_makeConstraints { make in
-                make?.left.right().top().bottom().equalTo()(0)
-            }
-        }
+        self.imageViewBox.borderWidth = 1.0
+        self.addSubview(self.clickButton)
+        self.clickButton.km_add_inset_constraint()
     }
 }
 
 extension KMToolbarItemView: NSPopoverDelegate {
-    
+    func popoverDidClose(_ notification: Notification) {
+        if let data = self.popOver?.isEqual(to: notification.object), data {
+            self._closePop()
+        }
+    }
 }
 
 extension KMToolbarItemView: KMCustomButtonPopMenuViewControllerDelegate, KMCustomButtonPopMenuViewControllerDataSources {

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarView.swift

@@ -105,7 +105,7 @@ private let KMToolbarItemSpace = 8.0
     }
     
     override func mouseMoved(with event: NSEvent) {
-        self.window?.mouseMoved(with: event)
+//        self.window?.mouseMoved(with: event)
         super.mouseMoved(with: event)
     }
     

+ 60 - 3
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -236,6 +236,14 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
         self.delegate?.toolbarViewController?(self, clickChaildToolType: .crop, toolbar: item)
     }
     
+    @objc private func _cropAction(_ sender: NSMenuItem) {
+        if let data = self._currentItemView {
+            self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
+        } else {
+            self.delegate?.toolbarViewController?(self, menuItemDidClick: self.toolbarItemFindItemIdentifiers(value: KMToolbarCropIdentifier), index: sender.tag, info: nil)
+        }
+    }
+    
     @objc func batesMenuAction(sender: KMToolbarClickButton) {
         self._currentItemView = sender.clickObject as? KMToolbarItemView
         if let subMenu = (sender.clickObject as? KMToolbarItemView)?.menuFormRepresentation?.submenu {
@@ -477,7 +485,7 @@ extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidatio
     
     func toolbarRightDefaultItemIdentifiers(_ toolbar: KMToolbarView) -> [String] {
         if toolbarType == .Main {
-            return [KMDocumentViewSettingToolbarItemIdentifier, KMDocumentShareToolbarItemIdentifier,
+            return [KMDocumentViewDisplayToolbarItemIdentifier, KMDocumentShareToolbarItemIdentifier,
                     KMDocumentSearchToolbarItemIdentifier, KMRightControlToolbarItemIdentifier]
         } else if [.Annatiton,.Magnify,.Move,.Select,.SelectZoom].contains(toolbarType) {
             return [KMToolbarAnnotationSettingItemIdentifier]
@@ -604,7 +612,8 @@ extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidatio
             return [KMToolbarToolEnhancedScanIdentifier,
                 KMToolbarToolOCRTextIdentifier]
         case .viewSetting:
-            return []
+            return [KMToolbarViewSettingIdentifier, KMToolbarCropIdentifier,
+                    KMToolbarSnapshotIdentifier, KMToolbarTTSIdentifier]
         default:
             break
         }
@@ -639,6 +648,8 @@ extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidatio
                     self._setupFormItem(item)
                 } else if toolToolIdentifiers.contains(identifier) {
                     self._setupToolItem(item)
+                } else if KMViewDisplayIdentifiers.contains(identifier) {
+                    self._setupViewDisplayItem(item)
                 }
             }
 
@@ -955,7 +966,7 @@ extension KMToolbarViewController {
             item?.toolTip = NSLocalizedString("Print", comment: "")
             item?.boxImagePosition = .imageOnly
             item?.btnAction = #selector(_itemAction)
-        } else if identifier == KMDocumentViewSettingToolbarItemIdentifier {
+        } else if identifier == KMDocumentViewDisplayToolbarItemIdentifier {
             item?.image = NSImage(named: "KMImageNameUXIconToolbarPageviewNor")
             item?.titleName = NSLocalizedString("Page Display", comment: "")
             item?.target = self
@@ -1508,6 +1519,52 @@ extension KMToolbarViewController {
         }
     }
     
+    private func _setupViewDisplayItem(_ item: KMToolbarItemView?) {
+        let identifier = item?.itemIdentifier
+        if identifier == KMToolbarViewSettingIdentifier {
+            item?.image = NSImage(named: KMImageNameUXIconSubtoolbarDisplayView)
+            item?.target = self
+            item?.toolTip = NSLocalizedString("View Settings", comment: "")
+            item?.titleName = NSLocalizedString("View Settings", comment: "")
+            item?.boxImagePosition = .imageLeft
+            item?.btnAction = #selector(_itemAction)
+        } else if identifier == KMToolbarCropIdentifier {
+            item?.image = NSImage(named: KMImageNameUXIconSubtoolbarDisplayTailor)
+            item?.target = self
+            item?.toolTip = NSLocalizedString("Note: Cropping a PDF hides some of the PDF’s content without removing it.", comment: "")
+            item?.titleName = NSLocalizedString("Crop", comment: "")
+            item?.boxImagePosition = .imageExpandLeft
+            item?.needExpandAction = true
+            item?.btnAction = #selector(cropMenuAction)
+            
+            let menuItem = NSMenuItem.init(title: "Crop", action: #selector(cropMenuAction), target: self)
+            let subMenu = NSMenu()
+            subMenu.addItem(title: NSLocalizedString("Crop All Pages", comment: ""), action: #selector(_cropAction), target: self, tag: 1)
+            subMenu.addItem(title: NSLocalizedString("Crop Current Page", comment: ""), action: #selector(_cropAction), target: self, tag: 2)
+            subMenu.addItem(title: NSLocalizedString("Auto Crop – Separate", comment: ""), action: #selector(_cropAction), target: self, tag: 3)
+            subMenu.addItem(title: NSLocalizedString("Auto Crop – Combined", comment: ""), action: #selector(_cropAction), target: self, tag: 4)
+            subMenu.addItem(title: NSLocalizedString("Select Area", comment: ""), action: #selector(_cropAction), target: self, tag: 5)
+            subMenu.addItem(title: NSLocalizedString("Crop Options...", comment: ""), action: #selector(_cropAction), target: self, tag: 6)
+            
+            menuItem.submenu = subMenu
+            item?.menuFormRepresentation = menuItem
+        } else if identifier == KMToolbarSnapshotIdentifier {
+            item?.image = NSImage(named: KMImageNameUXIconSubtoolbarDisplaySnapshot)
+            item?.target = self
+            item?.toolTip = NSLocalizedString("Take Snapshot", comment: "")
+            item?.titleName = NSLocalizedString("Snapshot", comment: "")
+            item?.boxImagePosition = .imageLeft
+            item?.btnAction = #selector(_itemAction)
+        } else if identifier == KMToolbarTTSIdentifier {
+            item?.image = NSImage(named: KMImageNameUXIconSubtoolbarDisplayTTS)
+            item?.target = self
+            item?.toolTip = NSLocalizedString("TTS (Text-to-speech)", comment: "")
+            item?.titleName = NSLocalizedString("TTS", comment: "")
+            item?.boxImagePosition = .imageLeft
+            item?.btnAction = #selector(_itemAction)
+        }
+    }
+    
     private func _setupToolItem(_ item: KMToolbarItemView?) {
         let identifier = item?.itemIdentifier
         if identifier == KMToolbarToolCropItemIdentifier {

+ 8 - 2
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/PublicKey.swift

@@ -24,7 +24,7 @@ let KMDocumentEditToolbarItemIdentifier = "KMDocumentPageEditToolbarItemIdentifi
 let KMDocumentFillSginToolbarItemIdentifier = "KMDocumentFillSginToolbarItemIdentifier"
 let KMDocumentToolToolbarItemIdentifier = "KMDocumentToolToolbarItemIdentifier"
 let KMDocumentRedactToolbarItemIdentifier = "KMDocumentRedactToolbarItemIdentifier"
-let KMDocumentViewSettingToolbarItemIdentifier = "KMDocumentViewSettingToolbarItemIdentifier"
+let KMDocumentViewDisplayToolbarItemIdentifier = "KMDocumentViewDisplayToolbarItemIdentifier"
 let KMDocumentPrintToolbarItemIdentifier = "KMDocumentPrintToolbarItemIdentifier"
 let KMDocumentAITranslationToolbarItemIdentifier = "KMDocumentAITranslationToolbarItemIdentifier"
 let KMDocumentShareToolbarItemIdentifier = "KMDocumentShareToolbarItemIdentifier"
@@ -32,7 +32,7 @@ let KMDocumentSearchToolbarItemIdentifier = "KMDocumentSearchToolbarItemIdentifi
 let KMRightControlToolbarItemIdentifier  = "KMRightControlToolbarItemIdentifier"
 let mainToolIdentifiers = [KMLeftControlToolbarItemIdentifier, KMDocumentZoomToolbarItemIdentifier, KMDocumentZoomOutToolbarItemIdentifier,
                            KMDocumentZoomViewToolbarItemIdentifier, KMDocumentPreviousPageToolbarItemIdentifier, KMDocumentNextPageToolbarItemIdentifier,
-                           KMDocumentHomeToolbarItemIdentifier, KMDocumentAnnotationToolbarItemIdentifier, KMDocumentPageToolbarItemIdentifier, KMDocumentConversonToolbarItemIdentifier,KMDocumentRedactToolbarItemIdentifier,KMDocumentViewSettingToolbarItemIdentifier,
+                           KMDocumentHomeToolbarItemIdentifier, KMDocumentAnnotationToolbarItemIdentifier, KMDocumentPageToolbarItemIdentifier, KMDocumentConversonToolbarItemIdentifier,KMDocumentRedactToolbarItemIdentifier,KMDocumentViewDisplayToolbarItemIdentifier,
                            KMDocumentScanOCRToolbarItemIdentifier, KMDocumentFormToolbarItemIdentifier, KMDocumentEditToolbarItemIdentifier,
                            KMDocumentFillSginToolbarItemIdentifier, KMDocumentToolToolbarItemIdentifier, KMDocumentPrintToolbarItemIdentifier,
                            KMDocumentShareToolbarItemIdentifier, KMDocumentSearchToolbarItemIdentifier, KMRightControlToolbarItemIdentifier]
@@ -165,6 +165,12 @@ let fillSignToolIdentifiers = [KMToolbarToolHookItemIdentifier, KMToolbarToolFor
 let KMToolbarToolOCRTextIdentifier     =  "KMToolbarToolOCRTextIdentifier"
 let KMToolbarToolEnhancedScanIdentifier     =  "KMToolbarToolEnhancedScanIdentifier"
 
+let KMToolbarViewSettingIdentifier = "KMToolbarViewSettingIdentifier"
+let KMToolbarCropIdentifier = "KMToolbarCropIdentifier"
+let KMToolbarSnapshotIdentifier = "KMToolbarSnapshotIdentifier"
+let KMToolbarTTSIdentifier = "KMToolbarTTSIdentifier"
+let KMViewDisplayIdentifiers = [KMToolbarViewSettingIdentifier, KMToolbarCropIdentifier, KMToolbarSnapshotIdentifier, KMToolbarTTSIdentifier]
+
 let KMNewToolbarSpaceItemIdentifier         =  "KMNewToolbarSpaceItemIdentifier"
 //let KMToolbarDividerItemIdentifier          =  "KMToolbarDividerItemIdentifier"
 

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

@@ -2914,8 +2914,8 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     self.changePDFViewGoToPreviousPageAction()
                 } else if toolbarItem.itemIdentifier == KMDocumentNextPageToolbarItemIdentifier {
                     self.changePDFViewGotoNextPageAction()
-                } else if toolbarItem.itemIdentifier == KMDocumentViewSettingToolbarItemIdentifier {
-                    Swift.debugPrint("KMDocumentViewSettingToolbarItemIdentifier ...")
+                } else if toolbarItem.itemIdentifier == KMDocumentViewDisplayToolbarItemIdentifier {
+                    Swift.debugPrint("KMDocumentViewDisplayToolbarItemIdentifier ...")
                 } else if toolbarItem.itemIdentifier == KMLeftControlToolbarItemIdentifier {
                     toolbarItem.isSelected = !toolbarItem.isSelected
                     self.toggleLeftPane()
@@ -2940,6 +2940,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     self.showPrintWindow()
                 } else if toolbarItem.itemIdentifier == KMToolbarToolProfileIdentifier {
                     Swift.debugPrint("KMToolbarToolProfileIdentifier ...")
+                } else if toolbarItem.itemIdentifier == KMToolbarViewSettingIdentifier {
+                    Swift.debugPrint("KMToolbarViewSettingIdentifier ...")
+                } else if toolbarItem.itemIdentifier == KMToolbarSnapshotIdentifier {
+                    Swift.debugPrint("KMToolbarSnapshotIdentifier ...")
+                } else if toolbarItem.itemIdentifier == KMToolbarTTSIdentifier {
+                    Swift.debugPrint("KMToolbarTTSIdentifier ...")
                 }
             }
         }
@@ -2964,6 +2970,8 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             KMPrint("KMToolbarConversionExportImageItemIdentifier \(index)")
         } else if (toolbarItem.itemIdentifier == KMToolbarConversionCreatePDFItemIdentifier) {
             KMPrint("KMToolbarConversionCreatePDFItemIdentifier \(index)")
+        } else if (toolbarItem.itemIdentifier == KMToolbarCropIdentifier) {
+            KMPrint("KMToolbarCropIdentifier \(index)")
         }
     }