Browse Source

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

tangchao 1 year ago
parent
commit
6a5422d795

+ 3 - 0
PDF Office/PDF Master/Class/Home/ViewController/KMHistoryFileCollectionViewItem.swift

@@ -79,6 +79,9 @@ class KMHistoryFileCollectionViewItem: NSCollectionViewItem {
         fileImageView.image = image
     }
     
+    //MARK: update
+
+    
     // MARK: Menu
     
     lazy var tableCellMenu: NSMenu = {

+ 19 - 46
PDF Office/PDF Master/Class/Home/ViewController/KMHomeHistoryFileViewController.swift

@@ -28,11 +28,6 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
     var file: URL?
     var selectUrls: [URL] = []
     var isSelect: Bool = false
-    var isHover: Bool = false {
-        didSet {
-            self.updateCellState()
-        }
-    }
     var currentWindowController: NSWindowController?
 
     // MARK: Init
@@ -43,7 +38,25 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
         mainBox.menu = tableCellMenu
         documentName.maximumNumberOfLines = 1
         mainBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
-            self.isHover = mouseEntered
+            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
+                }
+            }
         }
     }
     
@@ -157,30 +170,6 @@ class KMHomeHistoryFileTableviewCell: NSTableCellView {
     }
     
     //MARK: update
-    func updateCellState() {
-        if fileImageView != nil {
-            if !self.isSelect {
-                if self.isHover {
-                    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 {
-                    print("updateCellState hover")
-                    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
-                }
-            }
-        }
-    }
         
     // MARK: Menu
     lazy var tableCellMenu: NSMenu = {
@@ -292,8 +281,6 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
     
     var deleteButtonVC: KMDesignButton!
     
-    //hover
-    var hoverRow: Int = 0
     // MARK: Init
     
     override func viewWillAppear() {
@@ -796,20 +783,6 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
                 }
             }
         }
-        
-        cellView.mainBox.moveCallback = { [unowned self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
-            if self.hoverRow != row {
-                self.historyFileTableView.reloadData(forRowIndexes: IndexSet(integer: self.hoverRow), columnIndexes: IndexSet(integer: 0))
-            }
-            
-            self.hoverRow = row
-            cellView.isHover = mouseEntered
-        }
-        
-        if row != self.hoverRow {
-            let cell: KMHomeHistoryFileTableviewCell = self.historyFileTableView.rowView(atRow: self.hoverRow, makeIfNecessary: false) as? KMHomeHistoryFileTableviewCell ?? KMHomeHistoryFileTableviewCell()
-            cell.isHover = false
-        }
         return cellView
     }
     

+ 19 - 15
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m

@@ -810,22 +810,26 @@ NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification =
 }
 
 - (void)removeAnnotation:(CPDFAnnotation *)annotation {
-    CPDFAnnotation *wasAnnotation = annotation;
-    CPDFPage *page = wasAnnotation.page;
-    
-    [[[self undoManager] prepareWithInvocationTarget:self] addAnnotation:wasAnnotation toPage:page];
-    
-    [page removeAnnotation:wasAnnotation];
-    [self annotationsChangedOnPage:page];
-    [self setNeedsDisplayAnnotation:wasAnnotation];
+    if ([annotation isKindOfClass:[CPDFTextAnnotation class]] && self.popOver.isShown) {
+        
+    } else {
+        CPDFAnnotation *wasAnnotation = annotation;
+        CPDFPage *page = wasAnnotation.page;
+        
+        [[[self undoManager] prepareWithInvocationTarget:self] addAnnotation:wasAnnotation toPage:page];
+        
+        [page removeAnnotation:wasAnnotation];
+        [self annotationsChangedOnPage:page];
+        [self setNeedsDisplayAnnotation:wasAnnotation];
 
-    dispatch_async(dispatch_get_main_queue(), ^{
-        [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewDidRemoveAnnotationNotification object:self
-                                                          userInfo:[NSDictionary dictionaryWithObjectsAndKeys:wasAnnotation, CPDFListViewAnnotationKey, page, CPDFListViewPageKey, nil]];
-    });
-    
-    if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewRemoveAnnotations:forRemoveAnnotations:inPage:)])
-        [self.pdfListViewDelegate PDFListViewRemoveAnnotations:self forRemoveAnnotations:@[annotation] inPage:page];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewDidRemoveAnnotationNotification object:self
+                                                              userInfo:[NSDictionary dictionaryWithObjectsAndKeys:wasAnnotation, CPDFListViewAnnotationKey, page, CPDFListViewPageKey, nil]];
+        });
+        
+        if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewRemoveAnnotations:forRemoveAnnotations:inPage:)])
+            [self.pdfListViewDelegate PDFListViewRemoveAnnotations:self forRemoveAnnotations:@[annotation] inPage:page];
+    }
 }
 
 - (void)drawPage:(CPDFPage *)pdfPage toContext:(CGContextRef)context {