Browse Source

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

tangchao 1 year ago
parent
commit
a52c634b5c

+ 1 - 1
PDF Office/PDF Master/AppDelegate.swift

@@ -12,7 +12,7 @@ import KMAdvertisement
 class AppDelegate: NSObject, NSApplicationDelegate {
     
     func applicationWillBecomeActive(_ notification: Notification) {
-        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMApplicationWillBecomeActive"), object: nil)
+//        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMApplicationWillBecomeActive"), object: nil)
     }
     
     func applicationDidBecomeActive(_ notification: Notification) {

+ 10 - 7
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -21,6 +21,16 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
     override func makeWindowControllers() {
         // Returns the storyboard that contains your document window.
         
+        if ((self.fileURL?.path) != nil) {
+            if !self.fileURL!.path.isPDFValid() {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
+                alert.runModal()
+                return
+            }
+        }
+        
         let mainWindow = NSApp.mainWindow
         var currentWindowController: KMBrowserWindowController?
         if mainWindow != nil {
@@ -57,13 +67,6 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
         mainViewController?.myDocument = self
         
         if ((self.fileURL?.path) != nil) {
-            if !self.fileURL!.path.isPDFValid() {
-                let alert = NSAlert()
-                alert.alertStyle = .critical
-                alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
-                alert.runModal()
-                return
-            }
             let pdfDocument = CPDFDocument.init(url: URL(fileURLWithPath: self.fileURL!.path))
             mainViewController?.document = pdfDocument
         }

+ 12 - 6
PDF Office/PDF Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift

@@ -254,7 +254,7 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
     @IBOutlet weak var emptySubtitleLabel: NSTextField!
     @IBOutlet weak var emptyHovBox: KMMoveBox!
     
-    var files: [Any] = []
+    var files: [URL] = []
     var selectFiles: [URL] = []
     var selectFiles_shift: [Int] = []
 
@@ -283,7 +283,7 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
         allowMultipleChoices_cmd = false
         allowMultipleChoices_shift = false
 
-        NotificationCenter.default.addObserver(self, selector: #selector(willBecomeActive), name: NSNotification.Name(rawValue: "KMApplicationWillBecomeActive"), object: nil)
+//        NotificationCenter.default.addObserver(self, selector: #selector(willBecomeActive), name: NSNotification.Name(rawValue: "KMApplicationWillBecomeActive"), object: nil)
         
         if UserDefaults.standard.bool(forKey: "kFileListViewListModeKey") {
             showMode = .List
@@ -337,7 +337,13 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
     override func viewDidAppear() {
         super.viewDidAppear()
         
-        reloadData()
+        for url in NSDocumentController.shared.recentDocumentURLs {
+            if FileManager.default.fileExists(atPath: url.path) {
+                if !self.files.contains(url) {
+                    reloadData()
+                }
+            }
+        }
     }
     
     func initializeUI() {
@@ -513,9 +519,9 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
         }
     }
     
-    @objc func willBecomeActive() {
-        self.reloadData()
-    }
+//    @objc func willBecomeActive() {
+//        self.reloadData()
+//    }
 
     // MARK: Action
     

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

@@ -357,7 +357,9 @@ extension KMHomeViewController {
             let alert = NSAlert()
             alert.alertStyle = .critical
             alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
-            alert.runModal()
+            alert.beginSheetModal(for: view.window!) { [unowned self] result in
+                self.historyFileViewController.reloadData()
+            }
             return
         }
 
@@ -456,7 +458,9 @@ extension KMHomeViewController {
                 let alert = NSAlert()
                 alert.alertStyle = .critical
                 alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
-                alert.runModal()
+                alert.beginSheetModal(for: view.window!) { [unowned self] result in
+                    self.historyFileViewController.reloadData()
+                }
             }
         } else {
             NSWorkspace.shared.open(url)

+ 10 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSCursor+PDFListView.m

@@ -619,6 +619,16 @@ static NSCursor *textSelfSignCursor = nil;
     if (nil == stampCursor) {
         if(tampSignatureObject) {
             NSImage *cursorImage = [tampSignatureObject stampPreImage];
+            CGSize size = cursorImage.size;
+            CGFloat newWidth = 140.0, newHeight = 140.0;
+            if (size.width > 140 || size.height > 140) {
+                if (size.width > size.height) {
+                    newHeight = 140/size.width * size.height;
+                } else {
+                    newWidth = 140/size.height * size.width;
+                }
+                cursorImage.size = CGSizeMake(newWidth, newHeight);
+            }
             if(!cursorImage)
                 return [self arrowCursor];
 

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotationModel.m

@@ -877,7 +877,7 @@
 }
 
 - (CGFloat)noteWidth {
-    CGFloat width = 128;
+    CGFloat width = 140;
     //多选注释去拿注释类型的默认值
     if (_annotation && self.annotations.count == 1) {
         width = _annotation.bounds.size.width;
@@ -990,7 +990,7 @@
 }
 
 - (CGFloat)noteHeight {
-    CGFloat height = 64;
+    CGFloat height = 140;
     //多选注释去拿注释类型的默认值
     if (_annotation && self.annotations.count == 1) {
         height =  _annotation.bounds.size.height;

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/InitialUserDefaults.plist

@@ -225,9 +225,9 @@
 		<key>CAnnotationSelfSignDateFormatterIncludeTime</key>
 		<integer>0</integer>
 		<key>CDefaultNoteWidth</key>
-		<real>128</real>
+		<integer>140</integer>
 		<key>CDefaultNoteHeight</key>
-		<real>64</real>
+		<integer>140</integer>
 		<key>CDefaultAnchoredNoteWidth</key>
 		<integer>16</integer>
 		<key>CDefaultAnchoredNoteHeight</key>

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.m

@@ -1530,6 +1530,7 @@
     self.borderWidthSlider.floatValue = self.annotationModel.lineWidth;
     self.borderWidthVC.stringValue = [NSString stringWithFormat:@"%0.1f pt",self.annotationModel.lineWidth];
     self.fillColorPickerVC.annotationType = KMPropertiesColor_LineFillColors;
+    self.fillColorPickerVC.isFillColor = YES;
     self.borderColorPickerVC.annotationType = KMPropertiesColor_CircleLineColors;
 }