|
@@ -9,7 +9,7 @@ import Foundation
|
|
|
|
|
|
// MARK: - Action
|
|
|
|
|
|
-extension KMLeftSideViewController {
|
|
|
+extension KMLeftSideViewController {
|
|
|
@IBAction func leftSideViewMoreButtonAction(_ sender: AnyObject?) {
|
|
|
guard let button = sender as? NSButton else {
|
|
|
NSSound.beep()
|
|
@@ -55,95 +55,7 @@ extension KMLeftSideViewController {
|
|
|
} else if (tag == 302) {
|
|
|
self.outlineMoreMenu(button)
|
|
|
} else if (tag == 304) {
|
|
|
- let menu = NSMenu()
|
|
|
- let object = KMPopupMenuObject()
|
|
|
- object.menuTag = 1001
|
|
|
- menu.delegate = object
|
|
|
- object.enterControllerCallback = { [weak self] isEnter in
|
|
|
- if (isEnter) {
|
|
|
- self?.moreButtonLayer?.isHidden = false
|
|
|
- } else {
|
|
|
- self?.moreButtonLayer?.isHidden = true
|
|
|
- }
|
|
|
- }
|
|
|
- let expandAllCommentsItem = menu.addItem(title: KMLocalizedString("Expand All", nil), action: #selector(note_expandAllComments), target: self)
|
|
|
- expandAllCommentsItem?.representedObject = self.noteOutlineView
|
|
|
- let foldAllCommentsItem = menu.addItem(title: KMLocalizedString("Collapse All", nil), action: #selector(note_foldAllComments), target: self)
|
|
|
- foldAllCommentsItem?.representedObject = self.noteOutlineView
|
|
|
- if (self.foldType == .unfold) {
|
|
|
- expandAllCommentsItem?.state = .on
|
|
|
- foldAllCommentsItem?.state = .off
|
|
|
- } else if (self.foldType == .fold) {
|
|
|
- expandAllCommentsItem?.state = .off
|
|
|
- foldAllCommentsItem?.state = .on
|
|
|
- } else {
|
|
|
- expandAllCommentsItem?.state = .off
|
|
|
- foldAllCommentsItem?.state = .off
|
|
|
- }
|
|
|
-
|
|
|
- let showAnnotationItem = menu.addItem(title: KMLocalizedString("Show Note", nil), action: nil, target: self)
|
|
|
- let subMenu = NSMenu()
|
|
|
- var t = subMenu.addItem(title: KMLocalizedString("Page", nil), action: #selector(noteShowNoteAction), target: self)
|
|
|
- let pageKey = self.noteTypeDict[Self.Key.noteFilterPage] as? Bool ?? false
|
|
|
- if pageKey {
|
|
|
- t?.state = .off
|
|
|
- } else {
|
|
|
- t?.state = .on
|
|
|
- }
|
|
|
- t?.representedObject = self.noteOutlineView
|
|
|
- t?.tag = 101
|
|
|
- t = subMenu.addItem(title: KMLocalizedString("Time", nil) , action: #selector(noteShowNoteAction), target: self)
|
|
|
- let timeKey = self.noteTypeDict[Self.Key.noteFilterTime] as? Bool ?? false
|
|
|
- if timeKey {
|
|
|
- t?.state = .off
|
|
|
- } else {
|
|
|
- t?.state = .on
|
|
|
- }
|
|
|
- t?.representedObject = self.noteOutlineView
|
|
|
- t?.tag = 102
|
|
|
- t = subMenu.addItem(title: KMLocalizedString("Author", nil) , action: #selector(noteShowNoteAction), target: self)
|
|
|
- let authorKey = self.noteTypeDict[Self.Key.noteFilterAuther] as? Bool ?? false
|
|
|
- if authorKey {
|
|
|
- t?.state = .off
|
|
|
- } else {
|
|
|
- t?.state = .on
|
|
|
- }
|
|
|
- t?.representedObject = self.noteOutlineView
|
|
|
- t?.tag = 103
|
|
|
- showAnnotationItem?.submenu = subMenu
|
|
|
- menu.addItem(.separator())
|
|
|
-
|
|
|
- let exportAnnotationsItem = menu.addItem(title: NSLocalizedString("Export Annotations…", comment: ""), action: nil, target: self)
|
|
|
- let subMenu2 = NSMenu()
|
|
|
- var t2 = subMenu2.addItem(title: NSLocalizedString("PDF", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- t2?.representedObject = self.noteOutlineView
|
|
|
- t2?.tag = 0
|
|
|
- t2 = subMenu2.addItem(title: NSLocalizedString("PDF Bundle", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- t2?.representedObject = self.noteOutlineView
|
|
|
- t2?.tag = 1
|
|
|
- t2 = subMenu2.addItem(title: NSLocalizedString("PDF Reader Pro Edition Notes", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- t2?.representedObject = self.noteOutlineView
|
|
|
- t2?.tag = 2
|
|
|
- t2 = subMenu2.addItem(title: NSLocalizedString("Notes as Text", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- t2?.representedObject = self.noteOutlineView
|
|
|
- t2?.tag = 3
|
|
|
- t2 = subMenu2.addItem(title: NSLocalizedString("Notes as RTF", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- t2?.representedObject = self.noteOutlineView
|
|
|
- t2?.tag = 4
|
|
|
- t2 = subMenu2.addItem(title: NSLocalizedString("Notes as RTFD", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- t2?.representedObject = self.noteOutlineView
|
|
|
- t2?.tag = 5
|
|
|
- t2 = subMenu2.addItem(title: NSLocalizedString("Notes as FDF", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
|
|
|
- t2?.representedObject = self.noteOutlineView
|
|
|
- t2?.tag = 6
|
|
|
- exportAnnotationsItem?.submenu = subMenu2
|
|
|
- menu.addItem(.separator())
|
|
|
-
|
|
|
- let removeAllAnnotationsItem = menu.addItem(title: NSLocalizedString("Remove All Annotations", comment: ""), action: #selector(leftSideEmptyAnnotationClick_DeleteAnnotation), target: self)
|
|
|
- removeAllAnnotationsItem?.representedObject = self.noteOutlineView
|
|
|
- if let data = NSApp.currentEvent {
|
|
|
- NSMenu.popUpContextMenu(menu, with: data, for: button, with: nil)
|
|
|
- }
|
|
|
+ self.annoListMoreMenu(button)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -432,7 +344,7 @@ extension KMLeftSideViewController: NSMenuDelegate {
|
|
|
|
|
|
// MARK: - NSMenuItemValidation
|
|
|
|
|
|
-extension KMLeftSideViewController: NSMenuItemValidation {
|
|
|
+extension KMLeftSideViewController: NSMenuItemValidation {
|
|
|
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
|
|
let isLocked = self.isLocked()
|
|
|
if isLocked {
|
|
@@ -459,31 +371,20 @@ extension KMLeftSideViewController: NSMenuItemValidation {
|
|
|
action == #selector(outlineContextMenuItemClicked_Rename) ||
|
|
|
action == #selector(outlineContextMenuItemClicked_Promote) ||
|
|
|
action == #selector(outlineContextMenuItemClicked_Demote) ||
|
|
|
- action == #selector(leftSideEmptyAnnotationClick_DeleteOutline)) {
|
|
|
+ action == #selector(leftSideEmptyAnnotationClick_DeleteOutline)) { // 大纲列表
|
|
|
return self.outlineListValidateMenuItem(menuItem)
|
|
|
- } else if action == #selector(toggleOutlineCaseInsensitiveSearch) {
|
|
|
- menuItem.state = self.outlineIgnoreCaseFlag ? .on : .off
|
|
|
- return true
|
|
|
- } else if (action == #selector(note_expandAllComments) ||
|
|
|
+ }
|
|
|
+ if (action == #selector(note_expandAllComments) ||
|
|
|
action == #selector(note_foldAllComments) ||
|
|
|
action == #selector(exportAnnotationNotes) ||
|
|
|
action == #selector(leftSideEmptyAnnotationClick_DeleteAnnotation) ||
|
|
|
- action == #selector(removeAllAnnotations)) {
|
|
|
- return self.annotations.count > 0
|
|
|
- } else if (action == #selector(unfoldNoteAction) ||
|
|
|
- action == #selector(foldNoteAction)) {
|
|
|
- let row = self.noteOutlineView.clickedRow
|
|
|
-// NSArray *noteArr = [rightSideController.noteArrayController arrangedObjects];
|
|
|
-// PDFAnnotation *foldNote = (PDFAnnotation *)noteArr[row];
|
|
|
-// let foldNote = self.allAnnotations[row]
|
|
|
- let foldNote = self.fetchNote(for: row)
|
|
|
- // SKNPDFAnnotationNote
|
|
|
- if foldNote is CPDFMarkupAnnotation || foldNote is CPDFTextAnnotation {
|
|
|
- return true
|
|
|
- } else {
|
|
|
- return false
|
|
|
- }
|
|
|
- } else if (action == #selector(menuItemClick_ExportPNG) ||
|
|
|
+ action == #selector(removeAllAnnotations) ||
|
|
|
+ action == #selector(unfoldNoteAction) ||
|
|
|
+ action == #selector(foldNoteAction) ||
|
|
|
+ action == #selector(editNoteFromTable)) { // 注释列表
|
|
|
+ return self.annoListValidateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+ if (action == #selector(menuItemClick_ExportPNG) ||
|
|
|
action == #selector(menuItemClick_ExportJPG) ||
|
|
|
action == #selector(menuItemClick_ExportPDF)) {
|
|
|
if (self.snapshotTableView.selectedRow == -1 ) {
|
|
@@ -491,19 +392,6 @@ extension KMLeftSideViewController: NSMenuItemValidation {
|
|
|
} else {
|
|
|
return true
|
|
|
}
|
|
|
- } else if (action == #selector(editNoteFromTable)) {
|
|
|
- let row = self.noteOutlineView.clickedRow
|
|
|
- let foldNote = self.fetchNote(for: row)
|
|
|
-// if (@available(macOS 10.13, *)) {
|
|
|
-// if ([foldNote.widgetFieldType isEqualToString:PDFAnnotationWidgetSubtypeSignature]) {
|
|
|
-// return NO;
|
|
|
-// }
|
|
|
-// }
|
|
|
- if foldNote is CPDFStampAnnotation || foldNote is KMAnnotationStamp || foldNote is CPDFListStampAnnotation {
|
|
|
- return false
|
|
|
- } else {
|
|
|
- return true
|
|
|
- }
|
|
|
} else if (action == #selector(menuItemClick_SelectAll)) {
|
|
|
menuItem.state = self.snapshotListIsAllSelected() ? .on : .off
|
|
|
return true
|