Ver código fonte

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

tangchao 1 ano atrás
pai
commit
a277668119

+ 2 - 0
PDF Office/PDF Master/Class/Home/View/KMHomeDragView.swift

@@ -9,6 +9,7 @@ import Cocoa
 
 protocol KMHomeDragViewDelegate: NSObjectProtocol {
     func homeDragView(_ viewController: KMHomeDragView, filePath: URL)
+    func homeDragView(_ viewController: KMHomeDragView, notSupport: Bool)
 }
 
 class KMHomeDragView: NSView {
@@ -111,6 +112,7 @@ class KMHomeDragView: NSView {
             let type = path!.pathExtension.lowercased()
             if (KMTools.isPDFType(type) || KMTools.isImageType(type) || KMTools.isOfficeType(type)) {} else {
                 canAdd = false
+                self.delete?.homeDragView(self, notSupport: true)
                 break
             }
         }

+ 16 - 13
PDF Office/PDF Master/Class/Home/ViewController/KMHistoryFileCollectionViewItem.swift

@@ -29,18 +29,18 @@ class KMHistoryFileCollectionViewItem: NSCollectionViewItem {
         initializeUI()
         mainBox.menu = tableCellMenu
         documentName.maximumNumberOfLines = 2
-        mainBox.moveCallback =  { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
-            if self != nil {
-                if !self!.isSelect {
-                    if mouseEntered {
-                        self!.mainBox.fillColor = NSColor(hex: "#EDEEF0", alpha: 0.6)
-                        self!.documentName.textColor = NSColor(hex: "#252629")
-                        self!.mainBox.cornerRadius = 8.0
-                    } else {
-                        self!.mainBox.fillColor = .clear
-                        self!.documentName.textColor = NSColor(hex: "#252629")
-                        self!.mainBox.cornerRadius = 0.0
-                    }
+        mainBox.moveCallback =  { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
+            if !self.isSelect {
+                if mouseEntered {
+                    self.mainBox.fillColor = NSColor(hex: "#EDEEF0")
+                    self.mainBox.borderWidth = 0.0
+                    self.documentName.textColor = NSColor(hex: "#252629")
+                    self.mainBox.cornerRadius = 8.0
+                } else {
+                    self.mainBox.fillColor = .clear
+                    self.mainBox.borderWidth = 0.0
+                    self.documentName.textColor = NSColor(hex: "#252629")
+                    self.mainBox.cornerRadius = 0.0
                 }
             }
         }
@@ -57,11 +57,14 @@ class KMHistoryFileCollectionViewItem: NSCollectionViewItem {
         
         if selectUrls.contains(path) {
             isSelect = true
-            mainBox.fillColor = NSColor(hex: "#CED0D4")
+            mainBox.fillColor = NSColor(hex: "#CED0D4", alpha: 0.6)
+            mainBox.borderWidth = 1.0
+            mainBox.borderColor = NSColor(hex: "#CED0D4")
             mainBox.cornerRadius = 8.0
         } else {
             isSelect = false
             mainBox.fillColor = .clear
+            mainBox.borderWidth = 0.0
             mainBox.cornerRadius = 0.0
         }
         favoriteButton.isHidden = true

+ 37 - 29
PDF Office/PDF Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift

@@ -37,24 +37,24 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
                 
         mainBox.menu = tableCellMenu
         documentName.maximumNumberOfLines = 1
-        mainBox.moveCallback =  { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
-            if self != nil {
-                if !self!.isSelect {
-                    if mouseEntered {
-                        self!.documentName.textColor = NSColor(hex: "#252629")
-                        self!.documentType.textColor = NSColor(hex: "#94989C")
-                        self!.documentSize.textColor = NSColor(hex: "#94989C")
-                        self!.lastModificationTime.textColor = NSColor(hex: "#94989C")
-                        self!.mainBox.fillColor = NSColor(hex: "#CED0D4", alpha: 0.6)
-                        self!.mainBox.cornerRadius = 4.0
-                    } else {
-                        self!.documentName.textColor = NSColor(hex: "#252629")
-                        self!.documentType.textColor = NSColor(hex: "#94989C")
-                        self!.documentSize.textColor = NSColor(hex: "#94989C")
-                        self!.lastModificationTime.textColor = NSColor(hex: "#94989C")
-                        self!.mainBox.fillColor = .clear
-                        self!.mainBox.cornerRadius = 0.0
-                    }
+        mainBox.moveCallback =  { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
+            if !self.isSelect {
+                if mouseEntered {
+                    self.documentName.textColor = NSColor(hex: "#252629")
+                    self.documentType.textColor = NSColor(hex: "#94989C")
+                    self.documentSize.textColor = NSColor(hex: "#94989C")
+                    self.lastModificationTime.textColor = NSColor(hex: "#94989C")
+                    self.mainBox.fillColor = NSColor(hex: "#EDEEF0")
+                    self.mainBox.borderWidth = 0
+                    self.mainBox.cornerRadius = 4.0
+                } else {
+                    self.documentName.textColor = NSColor(hex: "#252629")
+                    self.documentType.textColor = NSColor(hex: "#94989C")
+                    self.documentSize.textColor = NSColor(hex: "#94989C")
+                    self.lastModificationTime.textColor = NSColor(hex: "#94989C")
+                    self.mainBox.fillColor = .clear
+                    self.mainBox.borderWidth = 0
+                    self.mainBox.cornerRadius = 0.0
                 }
             }
         }
@@ -101,11 +101,14 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
             
             if selectUrls.contains(url) {
                 isSelect = true
-                mainBox.fillColor = NSColor(hex: "#CED0D4")
+                mainBox.fillColor = NSColor(hex: "#CED0D4", alpha: 0.6)
+                mainBox.borderWidth = 1.0
+                mainBox.borderColor = NSColor(hex: "#CED0D4")
                 mainBox.cornerRadius = 4.0
             } else {
                 isSelect = false
                 mainBox.fillColor = .clear
+                mainBox.borderWidth = 0.0
                 mainBox.cornerRadius = 0.0
             }
             documentName.backgroundColor = .clear
@@ -126,6 +129,8 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
         for i in rows {
             if i == row {
                 mainBox.fillColor = NSColor(hex: "#CED0D4", alpha: 0.6)
+                mainBox.borderWidth = 1.0
+                mainBox.borderColor = NSColor(hex: "#CED0D4")
             }
         }
     }
@@ -503,6 +508,7 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
             if event.keyCode == 55 { // cmd
                 if allowMultipleChoices_cmd {
                     selectFiles_shift.removeAll()
+                    selectFiles.removeAll()
                     allowMultipleChoices_cmd = false
                 } else {
                     allowMultipleChoices_cmd = true
@@ -511,6 +517,7 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
             } else if event.keyCode == 56 { // shift
                 if allowMultipleChoices_shift {
                     selectFiles_shift.removeAll()
+                    selectFiles.removeAll()
                     allowMultipleChoices_shift = false
                 } else {
                     allowMultipleChoices_shift = true
@@ -531,16 +538,17 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
             }
             self.delete?.historyFileViewController!(self, deleteDocuments: selectFiles)
         } else if selectFiles.count > 0 {
-            let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
-            NSDocumentController.shared.clearRecentDocuments(nil)
-            DispatchQueue.main.asyncAfter(deadline: .now()) { [self] in
-                for (_, url) in urls.enumerated() {
-                    if !selectFiles.contains(url) {
-                        NSDocumentController.shared.noteNewRecentDocumentURL(url)
-                    }
-                }
-                NotificationCenter.default.post(name: NSNotification.Name.init(rawValue: "KMHomeFileRectChange"), object: NSApp.mainWindow)
-            }
+//            let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
+//            NSDocumentController.shared.clearRecentDocuments(nil)
+//            DispatchQueue.main.asyncAfter(deadline: .now()) { [self] in
+//                for (_, url) in urls.enumerated() {
+//                    if !selectFiles.contains(url) {
+//                        NSDocumentController.shared.noteNewRecentDocumentURL(url)
+//                    }
+//                }
+//                NotificationCenter.default.post(name: NSNotification.Name.init(rawValue: "KMHomeFileRectChange"), object: NSApp.mainWindow)
+//            }
+            self.delete?.historyFileViewController!(self, deleteDocuments: selectFiles)
         }
     }
     

+ 2 - 1
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -606,7 +606,8 @@ extension KMHomeViewController {
                 if historyFileViewController.historyFileCollectionView.frame.contains(point) ||
                     historyFileViewController.historyFileTableView.frame.contains(point) ||
                     historyFileViewController.deleteBox.frame.contains(point) ||
-                    historyFileViewController.modeBox.frame.contains(point) {
+                    historyFileViewController.listBox.frame.contains(point) ||
+                    historyFileViewController.thumbnailBox.frame.contains(point) {
                     
                 } else {
                     self.historyFileViewController.selectFiles.removeAll()

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

@@ -274,4 +274,13 @@ extension KMHomeViewController: KMHomeDragViewDelegate {
     func homeDragView(_ viewController: KMHomeDragView, filePath: URL) {
         self.openFile(withFilePath: filePath)
     }
+    
+    func homeDragView(_ viewController: KMHomeDragView, notSupport: Bool) {
+        if notSupport {
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = NSLocalizedString("This file format is not supported. Please enter PDF, picture, or Office file", comment: "")
+            alert.runModal()
+        }
+    }
 }

+ 7 - 1
PDF Office/PDF Master/Class/Home/WindowController/KMHistoryFileDeleteWindowController.swift

@@ -68,7 +68,13 @@ class KMHistoryFileDeleteWindowController: NSWindowController {
     func initLocalization() {
         let firstPath = indexPaths.first?.path.lastPathComponent ?? ""
 //        deleteOptionsLabel.stringValue = String(format: NSLocalizedString("Remove\"%@\"from your Recent Files?", comment: ""), firstPath)
-        deleteOptionsLabel.stringValue = NSLocalizedString("Delete selected file from the recents", comment: "")
+        let urls: Array<URL> = NSDocumentController.shared.recentDocumentURLs
+        if urls.count == indexPaths.count {
+            deleteOptionsLabel.stringValue = NSLocalizedString("Clear All Recents", comment: "")
+        } else {
+            deleteOptionsLabel.stringValue = NSLocalizedString("Delete selected file from the recents", comment: "")
+        }
+
         noLongerPromptVC.stringValue = NSLocalizedString("Don't ask again", comment: "")
         cancelVC.stringValue = NSLocalizedString("Cancel", comment: "")
         deleteVC.stringValue = NSLocalizedString("Delete", comment: "")

+ 2 - 3
PDF Office/PDF Master/Class/Home/WindowController/KMHistoryFileDeleteWindowController.xib

@@ -1,12 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
-        <deployment identifier="macosx"/>
         <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMHistoryFileDeleteWindowController" customModule="PDF_Office" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMHistoryFileDeleteWindowController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="cancelBox" destination="84N-oJ-zPU" id="vS5-xZ-TRI"/>
                 <outlet property="deleteBox" destination="ICh-pS-7xc" id="e6j-Jk-V9z"/>
@@ -30,7 +29,7 @@
                         <constraints>
                             <constraint firstAttribute="width" constant="228" id="SGg-Fg-WbD"/>
                         </constraints>
-                        <textFieldCell key="cell" title="Label" id="I5C-zs-Vdr">
+                        <textFieldCell key="cell" alignment="center" title="Label" id="I5C-zs-Vdr">
                             <font key="font" usesAppearanceFont="YES"/>
                             <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>