Bladeren bron

【PDFView】- 阅读界面右键菜单添加注释交互 补充

liaoxiaoyue 1 jaar geleden
bovenliggende
commit
e616035b19

+ 2 - 5
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Outline/KMOutlineViewController.swift

@@ -358,11 +358,8 @@ class KMOutlineViewController: NSViewController,NSMenuItemValidation {
     
     func addPDFOutlineCurrentSelections() {
         var string : String = ""
-        for currentSelection in  self.listView.currentSelection.selectionsByLine {
-            if string.count == 0 {
-                string = "\(string)+\("\n")"
-                string = "\(string)+\(String(describing: currentSelection.string()))"
-            } else {
+        if self.listView.currentSelection.selectionsByLine != nil {
+            for currentSelection in  self.listView.currentSelection.selectionsByLine {
                 string = currentSelection.string()
             }
         }

+ 25 - 21
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -256,10 +256,12 @@ extension KMMainViewController {
         let outline = NSMenuItem(title: NSLocalizedString("Add outline", comment: ""), action: #selector(menuItemAnnotationClick_add), target: self, tag: 9)!
 //        let tts = NSMenuItem(title: NSLocalizedString("TTS", comment: ""), action: #selector(menuItemAnnotationClick_add), target: self, tag: 10)!
         menu.insertItem(NSMenuItem.separator(), at: menu.items.count)
-        menu.insertItem(height, at: menu.items.count)
-        menu.insertItem(underline, at: menu.items.count)
-        menu.insertItem(strickout, at: menu.items.count)
-        menu.insertItem(NSMenuItem.separator(), at: menu.items.count)
+        if listView.currentSelection.selectionType() != .image {
+            menu.insertItem(height, at: menu.items.count)
+            menu.insertItem(underline, at: menu.items.count)
+            menu.insertItem(strickout, at: menu.items.count)
+            menu.insertItem(NSMenuItem.separator(), at: menu.items.count)
+        }
         menu.insertItem(text, at: menu.items.count)
         menu.insertItem(note, at: menu.items.count)
         menu.insertItem(NSMenuItem.separator(), at: menu.items.count)
@@ -435,22 +437,24 @@ extension KMMainViewController {
         case 8:
             annotationType = .link
         case 9:
-            var newOutline : CPDFOutline = CPDFOutline()
-            newOutline.label = "11111111"
-            let des = self.listView.currentDestination
-            if "\(des?.point.x ?? 0)" != "nan" {
-                newOutline.destination = self.listView.currentDestination
-            } else {
-                let destination : CPDFDestination = CPDFDestination(document: self.listView.document, pageIndex: self.listView.currentPageIndex, at: CGPoint(x: 0, y: 0), zoom: self.listView.scaleFactor)
-                newOutline.destination = destination
-            }
-            let current = self.listView.document.outlineRoot().insertChild(at: 0) ?? CPDFOutline()
-            let parent = current.parent ?? CPDFOutline()
-            let index = current.index + 1
-            parent.insertChild(newOutline, at: index)
-            if self.leftSideViewController.type.methodType == .Outline {
-                self.leftSideViewController.outlineViewController.reloadData()
+//            var newOutline : CPDFOutline = CPDFOutline()
+//            newOutline.label = "11111111"
+//            let des = self.listView.currentDestination
+//            if "\(des?.point.x ?? 0)" != "nan" {
+//                newOutline.destination = self.listView.currentDestination
+//            } else {
+//                let destination : CPDFDestination = CPDFDestination(document: self.listView.document, pageIndex: self.listView.currentPageIndex, at: CGPoint(x: 0, y: 0), zoom: self.listView.scaleFactor)
+//                newOutline.destination = destination
+//            }
+//            let current = self.listView.document.outlineRoot().insertChild(at: 0) ?? CPDFOutline()
+//            let parent = current.parent ?? CPDFOutline()
+//            let index = current.index + 1
+//            parent.insertChild(newOutline, at: index)
+            if self.leftPanelOpen == false || self.leftSideViewController.type.methodType != .Outline {
+                self.leftSideViewController.refreshMethodType(methodType: .Outline)
             }
+            self.leftSideViewController.outlineViewController.addPDFOutlineCurrentSelections()
+            return
         case 10:
             annotationType = .unkown
         default:
@@ -1165,13 +1169,13 @@ extension KMMainViewController {
     }
     
     @objc func openRightPane() -> Void {
-        if KMPreferenceManager.shared.showOutlineList == false {
+        if KMPreferenceManager.shared.leftSideExpandType == 0 {
             applyLeftSideWidth(lastLeftPanWidth, rightSideWidth: defaultRightWidth)
         }
     }
     
     @objc func closeRightPane() -> Void {
-        if KMPreferenceManager.shared.showOutlineList == false {
+        if KMPreferenceManager.shared.leftSideExpandType == 0 {
             applyLeftSideWidth(lastLeftPanWidth, rightSideWidth: 0)
         }
     }

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

@@ -155,7 +155,7 @@ import Cocoa
             UserDefaults.standard.synchronize()
         }
         let position = mianSplitView.maxPossiblePositionOfDivider(at: 1)
-        mianSplitView.setPosition(position, ofDividerAt: 1, animate: false)
+        mianSplitView.setPosition(position, ofDividerAt: 0, animate: false)
         mianSplitView.setPosition(mianSplitView.minPossiblePositionOfDivider(at: 0), ofDividerAt: 0, animate: false)
         
         pdfSplitView.setPosition(mianSplitView.maxPossiblePositionOfDivider(at: 1), ofDividerAt: 0, animate: true)