Преглед на файлове

【PDFView】- 右键菜单添加书签,移除书签显示修改

liaoxiaoyue преди 1 година
родител
ревизия
891c7d4685
променени са 1 файла, в които са добавени 17 реда и са изтрити 4 реда
  1. 17 4
      PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

+ 17 - 4
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -273,8 +273,13 @@ extension KMMainViewController {
     }
     
     func addBookmarkMenu() -> NSMenuItem {
-        let bookMarkItem = NSMenuItem(title: NSLocalizedString("Add BookMark", comment: ""), action: #selector(menuItemBookMarkClick_add), target: self)!
-        return bookMarkItem
+        if self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex)) == nil {
+            let bookMarkItem = NSMenuItem(title: NSLocalizedString("Add BookMark", comment: ""), action: #selector(menuItemBookMarkClick_add), target: self)!
+            return bookMarkItem
+        } else {
+            let bookMarkItem = NSMenuItem(title: NSLocalizedString("Remove BookMark", comment: ""), action: #selector(menuItemBookMarkClick_add), target: self)!
+            return bookMarkItem
+        }
     }
     
     func findStringMenu() -> NSMenuItem {
@@ -499,8 +504,16 @@ extension KMMainViewController {
             self.listView.document.removeBookmark(forPageIndex: UInt(self.listView.currentPageIndex))
             self.listView.setNeedsDisplayForVisiblePages()
         }
-        self.leftSideViewController.refreshMethodType(methodType: .BookMark)
-        self.leftSideViewController.bookViewController.reloadData()
+        if self.leftPanelOpen == false || self.leftSideViewController.type.methodType != .BookMark {
+            self.leftSideViewController.refreshMethodType(methodType: .BookMark)
+        }
+        let bookMark = self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex))
+        if bookMark != nil {
+            self.leftSideViewController.bookViewController.addBookMarkAndEdit(newBookMark: bookMark!)
+        } else {
+            self.leftSideViewController.bookViewController.reloadData()
+        }
+        
     }
     
     @objc func menuItemAnnotationClick_FindString(sender:NSMenuItem) {