Browse Source

【综合】系统菜单栏切换注释模式补充

tangchao 1 year ago
parent
commit
fe82639d94

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

@@ -432,7 +432,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "3743"
             endingLineNumber = "3743"
-            landmarkName = "toolbarViewController(_:menuItemDidClick:index:info:)"
+            landmarkName = "showTTSWindow()"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>

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

@@ -307,6 +307,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
                 }
             }
         }
+        
     }
     
     @objc func sharePageItemAction(sender: NSMenuItem) {

+ 9 - 9
PDF Office/PDF Master/Base.lproj/Main.storyboard

@@ -1544,31 +1544,31 @@ CA
                                         <menuItem title="Note Type" id="hBi-aS-9Zx">
                                             <menu key="submenu" title="Note Type" id="Dbh-Cv-oAm">
                                                 <items>
-                                                    <menuItem title="Highlight" tag="4" keyEquivalent="1" id="4Kl-m6-31M">
+                                                    <menuItem title="Highlight" tag="8" keyEquivalent="1" id="4Kl-m6-31M">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="xX1-cv-p4E"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Underline" tag="5" keyEquivalent="2" id="DUW-eu-32T">
+                                                    <menuItem title="Underline" tag="9" keyEquivalent="2" id="DUW-eu-32T">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="YId-H1-eZv"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Strikethrough" tag="6" keyEquivalent="3" id="kTp-hj-OXB">
+                                                    <menuItem title="Strikethrough" tag="10" keyEquivalent="3" id="kTp-hj-OXB">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="VF7-yr-zLu"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Freehand" tag="8" keyEquivalent="4" id="riR-iX-bHk">
+                                                    <menuItem title="Freehand" tag="13" keyEquivalent="4" id="riR-iX-bHk">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="QVG-ha-acg"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Text Note" keyEquivalent="5" id="xbJ-yP-tFc">
+                                                    <menuItem title="Text Note" tag="3" keyEquivalent="5" id="xbJ-yP-tFc">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="Fhi-yf-bU9"/>
@@ -1580,25 +1580,25 @@ CA
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="5M6-o4-GSz"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Rectangle" tag="3" keyEquivalent="7" id="xm8-ha-hwY">
+                                                    <menuItem title="Rectangle" tag="6" keyEquivalent="7" id="xm8-ha-hwY">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="VDm-2f-xXK"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Circle" tag="2" keyEquivalent="8" id="u8I-ki-UiV">
+                                                    <menuItem title="Circle" tag="7" keyEquivalent="8" id="u8I-ki-UiV">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="huC-gj-Ceg"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Line" tag="7" keyEquivalent="9" id="Hk7-Kl-hgp">
+                                                    <menuItem title="Line" tag="4" keyEquivalent="9" id="Hk7-Kl-hgp">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="H6c-zB-vd1"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Link" tag="9" keyEquivalent="0" id="asA-Rg-hpM">
+                                                    <menuItem title="Link" tag="2" keyEquivalent="0" id="asA-Rg-hpM">
                                                         <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
                                                         <connections>
                                                             <action selector="changeAnnotationMode:" target="Ady-hI-5gd" id="nap-bT-qYk"/>

+ 12 - 3
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift

@@ -813,9 +813,6 @@ extension KMBrowserWindowController {
     @IBAction func changeToolMode(_ sender: Any?) {
         KMPrint("changeToolMode ...")
     }
-    @IBAction func changeAnnotationMode(_ sender: Any?) {
-        KMPrint("changeAnnotationMode ...")
-    }
     @IBAction func toggleFullscreen(_ sender: Any?) {
         KMPrint("toggleFullscreen ...")
     }
@@ -1924,6 +1921,18 @@ extension KMBrowserWindowController: KMSystemToolMenuProtocol {
             }
         }
     }
+    
+    @IBAction func changeAnnotationMode(_ sender: Any?) {
+        if (self.canResponseDocumentAction() == false) {
+            return
+        }
+        if let document = self.browser.activeTabContents() as? KMMainDocument {
+            if (document.isHome) {
+            } else {
+                document.mainViewController?.changeAnnotationMode(sender)
+            }
+        }
+    }
 }
 
 // MARK: - KMSystemWindowMenuRrotocol

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

@@ -248,17 +248,17 @@ extension KMMainViewController {
         let item4 = stypeMenu.addItem(withTitle: NSLocalizedString("Select", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: CToolMode.selectToolMode.rawValue)
 //        stypeMenu.addItem(withTitle: NSLocalizedString("Zoom to Selected Area", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 4)
         stypeMenu.insertItem(NSMenuItem.separator(), at: 4)
-        let item5 = stypeMenu.addItem(withTitle: NSLocalizedString("Highlight", comment: ""), action: #selector(changeAnnotationMode), target: self, tag:  CAnnotationType.highlight.rawValue)
-        let item6 = stypeMenu.addItem(withTitle: NSLocalizedString("Underline", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.underline.rawValue)
-        let item7 = stypeMenu.addItem(withTitle: NSLocalizedString("Strikethrough", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.strikeOut.rawValue)
-        let item8 = stypeMenu.addItem(withTitle: NSLocalizedString("Freehand", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.ink.rawValue)
-        let item9 = stypeMenu.addItem(withTitle: NSLocalizedString("Text Note", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.freeText.rawValue)
-        let item10 = stypeMenu.addItem(withTitle: NSLocalizedString("Anchored Note", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.anchored.rawValue)
-        let item11 = stypeMenu.addItem(withTitle: NSLocalizedString("Rectangle", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.square.rawValue)
-        let item12 = stypeMenu.addItem(withTitle: NSLocalizedString("Circle", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.circle.rawValue)
-        let item13 = stypeMenu.addItem(withTitle: NSLocalizedString("Arrow", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.arrow.rawValue)
-        let item14 = stypeMenu.addItem(withTitle: NSLocalizedString("Line", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.line.rawValue)
-        let item15 = stypeMenu.addItem(withTitle: NSLocalizedString("Link", comment: ""), action: #selector(changeAnnotationMode), target: self, tag: CAnnotationType.link.rawValue)
+        let item5 = stypeMenu.addItem(withTitle: NSLocalizedString("Highlight", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag:  CAnnotationType.highlight.rawValue)
+        let item6 = stypeMenu.addItem(withTitle: NSLocalizedString("Underline", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.underline.rawValue)
+        let item7 = stypeMenu.addItem(withTitle: NSLocalizedString("Strikethrough", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.strikeOut.rawValue)
+        let item8 = stypeMenu.addItem(withTitle: NSLocalizedString("Freehand", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.ink.rawValue)
+        let item9 = stypeMenu.addItem(withTitle: NSLocalizedString("Text Note", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.freeText.rawValue)
+        let item10 = stypeMenu.addItem(withTitle: NSLocalizedString("Anchored Note", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.anchored.rawValue)
+        let item11 = stypeMenu.addItem(withTitle: NSLocalizedString("Rectangle", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.square.rawValue)
+        let item12 = stypeMenu.addItem(withTitle: NSLocalizedString("Circle", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.circle.rawValue)
+        let item13 = stypeMenu.addItem(withTitle: NSLocalizedString("Arrow", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.arrow.rawValue)
+        let item14 = stypeMenu.addItem(withTitle: NSLocalizedString("Line", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.line.rawValue)
+        let item15 = stypeMenu.addItem(withTitle: NSLocalizedString("Link", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.link.rawValue)
         
         stypItem.submenu = stypeMenu
         if self.toolbarController.toolbarType == .Annatiton {
@@ -748,7 +748,7 @@ extension KMMainViewController {
         self.toolbarController.mainToolBarView?.delegate?.toolbarViewController?(self.toolbarController.mainToolBarView!, clickMode:model, toolbar: item, [])
     }
     
-    @objc func changeAnnotationMode(sender : NSMenuItem) {
+    @objc func changeAnnotationMode_itemAction(sender : NSMenuItem) {
         var itemId: String?
         if sender.tag == CAnnotationType.highlight.rawValue {
             itemId = KMToolbarHighlightAnnotationItemIdentifier

+ 19 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -769,6 +769,12 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
     func takeSnapshotSelectContent(_ sender: Any?) {
         self.listView.takeSnapshotSelectContent(sender)
     }
+    
+    func changeAnnotationMode(_ sender: Any?) {
+        if let data = sender as? NSMenuItem {
+            self.changeAnnotationMode_itemAction(sender: data)
+        }
+    }
 }
 
 // MARK: window Menu
@@ -898,6 +904,19 @@ extension KMMainViewController: NSMenuItemValidation, NSMenuDelegate {
                 return self.listView.km_canGoBack()
             }
         }
+        
+        if menuItem.action == #selector(changeAnnotationMode) || menuItem.action == #selector(changeAnnotationMode_itemAction) {
+//            if ([[menuItem menu] numberOfItems] > ANNOTATION_MODE_COUNT)
+//                [menuItem setState:[self toolMode] == SKNoteToolMode && [self annotationMode] == (SKNoteType)[menuItem tag] ? NSOnState : NSOffState];
+//            else
+//                [menuItem setState:[self annotationMode] == (SKNoteType)[menuItem tag] ? NSOnState : NSOffState];
+            if self.listView.annotationType.rawValue == menuItem.tag {
+                menuItem.state = .on
+            } else {
+                menuItem.state = .off
+            }
+            return true
+        }
 
         return true
     }

+ 5 - 1
PDF Office/PDF Master/Class/SystemMenu/KMSystemToolMenu.swift

@@ -21,6 +21,8 @@ import Foundation
     
     @objc optional func extractImage(_ sender: Any?)
     
+    @objc optional func changeAnnotationMode(_ sender: Any?)
+    
     // convert
     @objc optional func convert(_ sender: Any?)
     @objc optional func imageToPDF(_ sender: Any?)
@@ -59,6 +61,8 @@ extension KMSystemMenu.Tool {
     
     public static let extractImageSelector       = NSSelectorFromString("extractImage:")
     
+    public static let changeAnnotationModeSelector       = NSSelectorFromString("changeAnnotationMode:")
+    
     // convert
     public static let convertSelector       = NSSelectorFromString("convert:")
     public static let imageToPDFSelector       = NSSelectorFromString("imageToPDF:")
@@ -86,7 +90,7 @@ extension KMSystemMenu.Tool {
         return [self.textToolSelector, self.scrolToolSelector, self.zoomToolSelector, self.selectToolSelector,
                 self.redactSelector, self.warkmarkSelector, self.backgroundSelector, self.headerfooterSelector,
                 self.batesSelector, self.batchSelector,
-                self.extractImageSelector,
+                self.extractImageSelector, self.changeAnnotationModeSelector,
                 // convert
                 self.convertSelector, self.imageToPDFSelector,
                 // Editor