瀏覽代碼

【BOTA】大纲重置目的菜单功能补充

tangchao 1 年之前
父節點
當前提交
d8bce0db24

+ 23 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Outline.swift

@@ -141,6 +141,11 @@ extension KMLeftSideViewController {
             self.tocOutlineView.reloadData()
             self.tocOutlineView.reloadData()
         }
         }
     }
     }
+    
+    @objc dynamic func changePDFOutlineDestination(_ destination: CPDFDestination, PDFoutline outline: CPDFOutline) {
+        (self.listView.undoManager?.prepare(withInvocationTarget: self) as AnyObject).changePDFOutlineDestination(outline.destination, PDFoutline: outline)
+        outline.destination = destination
+    }
 }
 }
 
 
 // MARK: - Menu Actions
 // MARK: - Menu Actions
@@ -204,4 +209,22 @@ extension KMLeftSideViewController {
             self.removeOutline(parent: outL.parent , removeOutline: outL, index: Int(outL.index), needExpand: false)
             self.removeOutline(parent: outL.parent , removeOutline: outL, index: Int(outL.index), needExpand: false)
         }
         }
     }
     }
+    
+    //重置目的
+    
+    @objc func outlineContextMenuItemClicked_SetDestination(_ sender: AnyObject?) {
+        guard let setPDFOutline = self.tocOutlineView.item(atRow: self.tocOutlineView.clickedRow) as? CPDFOutline else {
+            return
+        }
+
+        Task {
+            let modalRes = await KMAlertTool.runModel(style: .informational, message: KMLocalizedString("Are you sure you want to set the destination as the current location?", nil), buttons: [KMLocalizedString("Yes", nil), KMLocalizedString("No", nil)])
+            if (modalRes == .alertFirstButtonReturn) {
+                self.changePDFOutlineDestination(self.listView.currentDestination, PDFoutline: setPDFOutline)
+                self.tocOutlineView.reloadData()
+                let idx = self.tocOutlineView.row(forItem: setPDFOutline)
+                self.tocOutlineView.selectRowIndexes(IndexSet(integer: idx), byExtendingSelection: false)
+            }
+        }
+    }
 }
 }

+ 0 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -4753,10 +4753,6 @@ extension KMLeftSideViewController {
         KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Edit...")
         KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Edit...")
     }
     }
     
     
-    @objc func outlineContextMenuItemClicked_SetDestination(_ sender: AnyObject?) {
-        KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_SetDestination...")
-    }
-    
     @objc func outlineContextMenuItemClicked_Rename(_ sender: AnyObject?) {
     @objc func outlineContextMenuItemClicked_Rename(_ sender: AnyObject?) {
         KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Rename...")
         KMPrint("KMLeftSideViewController-outlineContextMenuItemClicked_Rename...")
     }
     }