Browse Source

【页面编辑】- 右键菜单

jiajie 1 year ago
parent
commit
ac152992cd

+ 29 - 18
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -645,23 +645,29 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     break;
             }
             
-            [subMenu addItem:singlePageItem];
-            [subMenu addItem:singlePageContinuousItem];
-            [subMenu addItem:twoPagesItem];
-            [subMenu addItem:twoPagesContinuousItem];
-            [subMenu addItem:bookModeItem];
-            pageDisplayItem.submenu = subMenu;
+//            [subMenu addItem:singlePageItem];
+//            [subMenu addItem:singlePageContinuousItem];
+//            [subMenu addItem:twoPagesItem];
+//            [subMenu addItem:twoPagesContinuousItem];
+//            [subMenu addItem:bookModeItem];
+//            pageDisplayItem.submenu = subMenu;
+            
+//            [menu insertItem:pageDisplayItem atIndex:0];
+            [menu insertItem:[NSMenuItem separatorItem] atIndex:0];
+            [menu insertItem:twoPagesContinuousItem atIndex:0];
+            [menu insertItem:twoPagesItem atIndex:0];
+            [menu insertItem:singlePageContinuousItem atIndex:0];
+            [menu insertItem:singlePageItem atIndex:0];
             
-            [menu insertItem:pageDisplayItem atIndex:0];
             
             NSMenuItem *zoomItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Zoom", @"PDFListView") action:nil keyEquivalent:@""];
             subMenu = [[NSMenu alloc]init];
             
-            NSMenuItem * fitWidthItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Fit Width", @"PDFListView") action:@selector(menuItemClick_FitWidth:) keyEquivalent:@""];
+            NSMenuItem * fitWidthItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Automatically Resize", @"PDFListView") action:@selector(menuItemClick_FitWidth:) keyEquivalent:@""];
             NSMenuItem * automaticallyItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Fit Page", @"PDFListView") action:@selector(menuItemClick_FitPage:) keyEquivalent:@""];
-            NSMenuItem * actualSizeItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Actual Size", @"PDFListView") action:@selector(menuItemClick_ActualSize:) keyEquivalent:@""];
             NSMenuItem * zoomInItem =  [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Zoom In", @"PDFListView") action:@selector(menuItemClick_ZoomIn:) keyEquivalent:@""];
             NSMenuItem * zoomOutItem =  [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Zoom Out", @"PDFListView") action:@selector(menuItemClick_ZoomOut:) keyEquivalent:@""];
+            NSMenuItem * actualSizeItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Actual Size", @"PDFListView") action:@selector(menuItemClick_ActualSize:) keyEquivalent:@""];
             
             NSMenuItem * hidenShowNoteItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Hide Notes", @"PDFListView") action:@selector(menuItemClick_HidenorShowNote:) keyEquivalent:@""];
             
@@ -682,16 +688,21 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 [hidenShowNoteItem setTitle:NSLocalizedString(@"Hide Notes", @"PDFListView")];
             }
             
-            [subMenu addItem:fitWidthItem];
-            [subMenu addItem:automaticallyItem];
-            [subMenu addItem:actualSizeItem];
-            [subMenu addItem:zoomInItem];
-            [subMenu addItem:zoomOutItem];
-            zoomItem.submenu = subMenu;
-            [menu insertItem:zoomItem atIndex:0];
-            
+//            [subMenu addItem:fitWidthItem];
+//            [subMenu addItem:automaticallyItem];
+//            [subMenu addItem:actualSizeItem];
+//            [subMenu addItem:zoomInItem];
+//            [subMenu addItem:zoomOutItem];
+//            zoomItem.submenu = subMenu;
+//            [menu insertItem:zoomItem atIndex:0];
             [menu insertItem:[NSMenuItem separatorItem] atIndex:0];
-            [menu insertItem:hidenShowNoteItem atIndex:0];
+            [menu insertItem:actualSizeItem atIndex:0];
+            [menu insertItem:zoomOutItem atIndex:0];
+            [menu insertItem:zoomInItem atIndex:0];
+            [menu insertItem:fitWidthItem atIndex:0];
+            
+            
+//            [menu insertItem:hidenShowNoteItem atIndex:0];
             [menu insertItem:[NSMenuItem separatorItem] atIndex:0];
             [menu insertItem:pasteItem atIndex:0];
 

+ 114 - 1
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -186,7 +186,7 @@ extension KMMainViewController {
     }
     
     func enterAnnotationStype() -> NSMenuItem {
-        let stypItem = NSMenuItem(title: NSLocalizedString("Add Annotation", comment: ""), action: nil, target: self)
+        let stypItem = NSMenuItem(title: NSLocalizedString("Annotation", comment: ""), action: nil, target: self)
         let stypeMenu = NSMenu()
         stypeMenu.addItem(withTitle: NSLocalizedString("Freehand", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 0)
         stypeMenu.addItem(withTitle: NSLocalizedString("Text", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 1)
@@ -257,6 +257,94 @@ extension KMMainViewController {
         }
         return stypItem
     }
+    func addOutlineStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Add Outline Item", comment: ""), action: #selector(addOutLineItemAction), target: self)
+        
+        return stypItem
+    }
+    
+    func setTTSStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("TTS", comment: ""), action: #selector(showTTSView), target: self)
+        
+        return stypItem
+    }
+    
+    func setLookUpStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Look Up", comment: ""), action: #selector(lookUpAction), target: self)
+        
+        return stypItem
+    }
+    func setSearchBaiduStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Search with Baidu", comment: ""), action: #selector(searchBaiduAction), target: self)
+        
+        return stypItem
+    }
+    
+    func setNextPageStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Next Page", comment: ""), action: #selector(NextPageAction), target: self)
+        
+        return stypItem
+    }
+    
+    func setPreviousPageStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Previous Page", comment: ""), action: #selector(PreviousPageAction), target: self)
+        
+        return stypItem
+    }
+    
+    func setTranslateStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Translate", comment: ""), action: #selector(TranslateItemAction), target: self)
+        
+        return stypItem
+    }
+    
+    func setAutoScrollStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Auto Scroll", comment: ""), action: #selector(AutoScrollItemAction), target: self)
+        
+        return stypItem
+    }
+    
+    func setSnapshotStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Snapshot", comment: ""), action: nil, target: self)
+        let stypeMenu = NSMenu()
+        stypeMenu.addItem(withTitle: NSLocalizedString("Auto", comment: ""), action: #selector(takeSnapshot), target: self, tag: 0)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Select Area", comment: ""), action: #selector(takeSnapshotSelectContent), target: self, tag: 1)
+        stypItem.submenu = stypeMenu
+//        if self.toolbarController.toolbarType == .Annatiton {
+//            stypeMenu.item(at: 0)?.state = .on
+//        } else if self.toolbarController.toolbarType == .Move {
+//            stypeMenu.item(at: 1)?.state = .on
+//        }
+        return stypItem
+    }
+    
+    func setCropStype() -> NSMenuItem {
+        let stypItem = NSMenuItem(title: NSLocalizedString("Crop", comment: ""), action: nil, target: self)
+        let stypeMenu = NSMenu()
+        stypeMenu.addItem(withTitle: NSLocalizedString("Crop All Pages", comment: ""), action: #selector(cropAllPageItem), target: self, tag: 0)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Crop Current Page", comment: ""), action: #selector(cropCurrentPageItem), target: self, tag: 1)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Auto Crop – Separate", comment: ""), action: #selector(autoCropAllItem), target: self, tag: 2)
+        stypeMenu.addItem(withTitle: NSLocalizedString("Auto Crop – Combined", comment: ""), action: #selector(smartAutoCropAllItem), target: self, tag: 3)
+//        if(NSIsEmptyRect(selectionRect)) {
+            stypeMenu.addItem(withTitle: NSLocalizedString("Select Area", comment: ""), action: #selector(selectToolModel), target: self, tag: 4)
+            stypeMenu.addItem(withTitle: NSLocalizedString("Crop Options...", comment: ""), action: #selector(customCropModel), target: self, tag: 5)
+//
+//        }
+        
+        stypItem.submenu = stypeMenu
+//        if self.toolbarController.toolbarType == .Annatiton {
+//            stypeMenu.item(at: 0)?.state = .on
+//        } else if self.toolbarController.toolbarType == .Move {
+//            stypeMenu.item(at: 1)?.state = .on
+//        } else if self.toolbarController.toolbarType == .Magnify {
+//            stypeMenu.item(at: 2)?.state = .on
+//        } else if self.toolbarController.toolbarType == .Select {
+//            stypeMenu.item(at: 3)?.state = .on
+//        } else if self.toolbarController.toolbarType == .SelectZoom {
+//            stypeMenu.item(at: 4)?.state = .on
+//        }
+        return stypItem
+    }
     
     func addHighlightLinksStype() -> NSMenuItem {
         let highlightLink = KMPreferenceManager.shared.highlightLinks
@@ -502,6 +590,31 @@ extension KMMainViewController {
         }
     }
     
+    @objc func takeSnapshot(sender: NSMenuItem) {
+        
+    }
+    @objc func takeSnapshotSelectContent(sender: NSMenuItem) {
+        
+    }
+    
+    @objc func cropAllPageItem(sender: NSMenuItem) {
+        
+    }
+    @objc func cropCurrentPageItem(sender: NSMenuItem) {
+        
+    }
+    @objc func autoCropAllItem(sender: NSMenuItem) {
+        
+    }
+    @objc func smartAutoCropAllItem(sender: NSMenuItem) {
+        
+    }
+    @objc func selectToolModel(sender: NSMenuItem) {
+        
+    }
+    @objc func customCropModel(sender: NSMenuItem) {
+        
+    }
     @objc func menuItemAnnotationClick_toolModel(sender: NSMenuItem) {
         self.listView.toolMode = .noteToolMode
         var identifier = KMDocumentAnnotationToolbarItemIdentifier

+ 27 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift

@@ -534,6 +534,33 @@ extension KMMainViewController {
         let alertView = CustomAlertView.alertView(message: NSLocalizedString("Read Mode Off", comment: ""), fromView: self.view, withStyle: .blue, backgroundColor: NSColor.km_init(hex: "#36383B"))
     }
     
+    @objc func addOutLineItemAction() {
+        //在当前page上添加
+//        self.listView.currentPageIndex
+//        self.listView.currentPage()
+    }
+    
+    @objc func showTTSView() {
+       
+    }
+    @objc func lookUpAction() {
+        
+    }
+    @objc func searchBaiduAction() {
+        
+    }
+    @objc func NextPageAction() {
+        
+    }
+    @objc func PreviousPageAction() {
+        
+    }
+    @objc func TranslateItemAction() {
+        
+    }
+    @objc func AutoScrollItemAction() {
+        //增加判断,如果是正在滚动,就停止,否则就开始滚动
+    }
     @objc func highlightLinks() {
         let highlightLinks = KMPreferenceManager.shared.highlightLinks
         KMPreferenceManager.shared.highlightLinks = !highlightLinks

+ 55 - 11
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -2092,6 +2092,37 @@ import Cocoa
     func pdfListViewMenu(forEvent pdfListView: CPDFListView!, for theEvent: NSEvent!, click menu: AutoreleasingUnsafeMutablePointer<NSMenu?>!) {
         self.mouseRightMenuEvent = theEvent
         let currentMenu : NSMenu = menu.pointee!
+        if (currentMenu.items.count > 2) {
+            currentMenu.insertItem(self.setSnapshotStype(), at: 2)
+        }
+        if (currentMenu.items.count > 2) {
+            currentMenu.insertItem(self.setCropStype(), at: 3)
+        }
+        if (currentMenu.items.count > 3) {
+            currentMenu.insertItem(self.setTTSStype(), at: 4)
+        }
+        if(currentMenu.items.count > 4) {
+            currentMenu.insertItem(NSMenuItem.separator(), at: 5)
+        }
+        if (currentMenu.items.count > 5) {
+            currentMenu.insertItem(self.setLookUpStype(), at: 6)
+        }
+        if(currentMenu.items.count > 6) {
+            currentMenu.insertItem(NSMenuItem.separator(), at: 7)
+        }
+        if (currentMenu.items.count > 7) {
+            currentMenu.insertItem(self.setSearchBaiduStype(), at: 8)
+        }
+        if(currentMenu.items.count > 8) {
+            currentMenu.insertItem(NSMenuItem.separator(), at: 9)
+        }
+        if(currentMenu.items.count > 9) {
+            currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count-1)
+        }
+        if (currentMenu.items.count > 16) {
+            currentMenu.insertItem(self.addReadModelStype(), at: currentMenu.items.count-1)
+        }
+        
         if (listView.toolMode == .redactToolMode) {
             if (listView.activeAnnotation == nil) {
 
@@ -2160,23 +2191,32 @@ import Cocoa
                 if(currentMenu.items.count > 2) {
                     currentMenu.insertItem(self.enterAnnotationStype(), at: 2)
                 }
+                if(currentMenu.items.count > 2) {
+                    currentMenu.insertItem(NSMenuItem.separator(), at: 3)
+                }
                 if(currentMenu.items.count > 3) {
-                    currentMenu.insertItem(self.addBookmarkMenu(), at: 4)
+                    currentMenu.insertItem(self.setAnnotationToolStype(), at: 4)
                 }
+                
                 if(currentMenu.items.count > 4) {
                     currentMenu.insertItem(NSMenuItem.separator(), at: 5)
                 }
                 if(currentMenu.items.count > 5) {
-                    currentMenu.insertItem(self.setAnnotationToolStype(), at: 6)
+                    currentMenu.insertItem(self.addBookmarkMenu(), at: 6)
                 }
                 
                 if (currentMenu.items.count > 6) {
-                    currentMenu.insertItem(self.addReadModelStype(), at: 7)
+                    currentMenu.insertItem(self.addOutlineStype(), at: 7)
                 }
                 
-                if (currentMenu.items.count > 7 && self.isReadMode) {
+                if (currentMenu.items.count > 6 && self.isReadMode) {
                     currentMenu.removeItem(currentMenu.item(withTitle: "Zoom")!)
                 }
+                if(currentMenu.items.count > 7) {
+                    currentMenu.insertItem(NSMenuItem.separator(), at: 8)
+                }
+               
+               
 //                if(currentMenu.items.count > 6) {
 //                    let menuItem = NSMenuItem(title: NSLocalizedString("Automatic rolling", comment: ""), action:nil, target: self)!
 //                    currentMenu.insertItem(menuItem, at: 6)
@@ -2190,18 +2230,22 @@ import Cocoa
 //                    currentMenu.insertItem(menuItem, at: 8)
 //                }
 
-                if !self.isReadMode {
-                    if (currentMenu.items.count > 10) {
-                        currentMenu.insertItem(self.addHighlightLinksStype(), at: 11)
-                    }
-                }
+//                if !self.isReadMode {
+//                    if (currentMenu.items.count > 10) {
+//                        currentMenu.insertItem(self.addHighlightLinksStype(), at: 11)
+//                    }
+//                }
 
                 if self.isReadMode {
                     
                 } else {
                     currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count)
-                    currentMenu.insertItem(self.findStringMenu(), at: currentMenu.items.count)
-                    currentMenu.insertItem(self.printingMenu(), at: currentMenu.items.count)
+//                    currentMenu.insertItem(self.findStringMenu(), at: currentMenu.items.count)
+//                    currentMenu.insertItem(self.printingMenu(), at: currentMenu.items.count)
+                    currentMenu.insertItem(self.setNextPageStype(), at: currentMenu.items.count)
+                    currentMenu.insertItem(self.setPreviousPageStype(), at: currentMenu.items.count)
+                    currentMenu.insertItem(self.setTranslateStype(), at: currentMenu.items.count)
+                    currentMenu.insertItem(self.setAutoScrollStype(), at: currentMenu.items.count)
                 }
             } else if listView.activeAnnotation != nil {
                 var type : CAnnotationType = .unkown