|
@@ -172,8 +172,8 @@ extension KMLeftSideViewController {
|
|
var rowIndexes = self.noteOutlineView.selectedRowIndexes
|
|
var rowIndexes = self.noteOutlineView.selectedRowIndexes
|
|
let row = self.noteOutlineView.clickedRow
|
|
let row = self.noteOutlineView.clickedRow
|
|
if row == -1 {
|
|
if row == -1 {
|
|
- self._addExportPDFMenu(menu)
|
|
|
|
- item = menu.addItem(title: NSLocalizedString("Remove All Annotations", tableName: "MainMenu", comment: "Menu item title"), action: #selector(removeAllAnnotations), target: self)
|
|
|
|
|
|
+ _ = self._addExportPDFMenu(menu)
|
|
|
|
+ _ = self._addDeleteAllAnnoItem(menu)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if rowIndexes.contains(row) == false {
|
|
if rowIndexes.contains(row) == false {
|
|
@@ -237,12 +237,12 @@ extension KMLeftSideViewController {
|
|
item = menu.addItem(title: KMLocalizedString("Delete", "Menu item title"), action: #selector(deleteNotes), target: self)
|
|
item = menu.addItem(title: KMLocalizedString("Delete", "Menu item title"), action: #selector(deleteNotes), target: self)
|
|
item?.representedObject = items
|
|
item?.representedObject = items
|
|
}
|
|
}
|
|
- item = menu.addItem(title: NSLocalizedString("Remove All Annotations", tableName: "MainMenu", comment: "Menu item title"), action: #selector(removeAllAnnotations), target: self)
|
|
|
|
|
|
+ _ = self._addDeleteAllAnnoItem(menu)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private func _addExportPDFMenu(_ menu: NSMenu) -> NSMenu {
|
|
private func _addExportPDFMenu(_ menu: NSMenu) -> NSMenu {
|
|
- var item = menu.addItem(title: NSLocalizedString("Export Annotations…", tableName: "", comment: ""), action: #selector(exportAnnotationNotes), target: self)
|
|
|
|
|
|
+ var item = menu.addItem(title: NSLocalizedString("Export Annotations…", tableName: "", comment: ""), action: nil, target: self)
|
|
|
|
|
|
let subMenu = NSMenu()
|
|
let subMenu = NSMenu()
|
|
item?.submenu = subMenu
|
|
item?.submenu = subMenu
|
|
@@ -263,6 +263,10 @@ extension KMLeftSideViewController {
|
|
return menu
|
|
return menu
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private func _addDeleteAllAnnoItem(_ menu: NSMenu) -> NSMenuItem? {
|
|
|
|
+ return menu.addItem(title: NSLocalizedString("Remove All Annotations", tableName: "", comment: ""), action: #selector(removeAllAnnotations), target: self)
|
|
|
|
+ }
|
|
|
|
+
|
|
func annoListMoreMenu(_ view: NSButton) {
|
|
func annoListMoreMenu(_ view: NSButton) {
|
|
let menu = NSMenu()
|
|
let menu = NSMenu()
|
|
let object = KMPopupMenuObject()
|
|
let object = KMPopupMenuObject()
|
|
@@ -307,8 +311,8 @@ extension KMLeftSideViewController {
|
|
_ = self._addExportPDFMenu(menu)
|
|
_ = self._addExportPDFMenu(menu)
|
|
menu.addItem(.separator())
|
|
menu.addItem(.separator())
|
|
|
|
|
|
- let removeAllItem = menu.addItem(title: NSLocalizedString("Remove All Annotations", comment: ""), action: #selector(leftSideEmptyAnnotationClick_DeleteAnnotation), target: self)
|
|
|
|
- removeAllItem?.representedObject = self.noteOutlineView
|
|
|
|
|
|
+ let removeAllItem = self._addDeleteAllAnnoItem(menu)
|
|
|
|
+// removeAllItem?.representedObject = self.noteOutlineView
|
|
if let data = NSApp.currentEvent {
|
|
if let data = NSApp.currentEvent {
|
|
NSMenu.popUpContextMenu(menu, with: data, for: view, with: nil)
|
|
NSMenu.popUpContextMenu(menu, with: data, for: view, with: nil)
|
|
}
|
|
}
|
|
@@ -319,7 +323,6 @@ extension KMLeftSideViewController {
|
|
if (action == #selector(note_expandAllComments) ||
|
|
if (action == #selector(note_expandAllComments) ||
|
|
action == #selector(note_foldAllComments) ||
|
|
action == #selector(note_foldAllComments) ||
|
|
action == #selector(exportAnnotationNotes) ||
|
|
action == #selector(exportAnnotationNotes) ||
|
|
- action == #selector(leftSideEmptyAnnotationClick_DeleteAnnotation) ||
|
|
|
|
action == #selector(removeAllAnnotations)) {
|
|
action == #selector(removeAllAnnotations)) {
|
|
return self.annotations.count > 0
|
|
return self.annotations.count > 0
|
|
} else if (action == #selector(unfoldNoteAction) ||
|
|
} else if (action == #selector(unfoldNoteAction) ||
|
|
@@ -397,35 +400,6 @@ extension KMLeftSideViewController {
|
|
doc?.saveTo(sender)
|
|
doc?.saveTo(sender)
|
|
}
|
|
}
|
|
|
|
|
|
- @objc func leftSideEmptyAnnotationClick_DeleteAnnotation(_ sender: AnyObject?) {
|
|
|
|
- guard let doc = self.pdfDocument() else {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- Task {
|
|
|
|
- let response = await KMAlertTool.runModel(message: KMLocalizedString("This will permanently remove all annotations. Are you sure to continue?", nil), buttons: [KMLocalizedString("Yes", nil), KMLocalizedString("No", nil)])
|
|
|
|
- if response == .alertFirstButtonReturn {
|
|
|
|
- var annos: [CPDFAnnotation] = []
|
|
|
|
- for i in 0 ..< doc.pageCount {
|
|
|
|
- let page = self.pdfDocument()?.page(at: i)
|
|
|
|
- for anno in page?.annotations ?? [] {
|
|
|
|
- if anno is CPDFTextWidgetAnnotation || anno is CPDFButtonWidgetAnnotation || anno is CPDFChoiceWidgetAnnotation {
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- // if ([annotation.widgetFieldType isEqualToString:PDFAnnotationWidgetSubtypeSignature]) {
|
|
|
|
- // continue;
|
|
|
|
- // }
|
|
|
|
- annos.append(anno)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for anno in annos {
|
|
|
|
- self.listView?.remove(anno)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- self.reloadAnnotation()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@objc func unfoldNoteAction(_ sender: NSMenuItem) {
|
|
@objc func unfoldNoteAction(_ sender: NSMenuItem) {
|
|
if sender.state == .on {
|
|
if sender.state == .on {
|
|
return
|
|
return
|
|
@@ -477,7 +451,32 @@ extension KMLeftSideViewController {
|
|
}
|
|
}
|
|
|
|
|
|
@objc func removeAllAnnotations(_ sender: AnyObject?) {
|
|
@objc func removeAllAnnotations(_ sender: AnyObject?) {
|
|
- self.leftSideEmptyAnnotationClick_DeleteAnnotation(nil)
|
|
|
|
|
|
+ guard let doc = self.pdfDocument() else {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ Task {
|
|
|
|
+ let response = await KMAlertTool.runModel(message: KMLocalizedString("This will permanently remove all annotations. Are you sure to continue?", nil), buttons: [KMLocalizedString("Yes", nil), KMLocalizedString("No", nil)])
|
|
|
|
+ if response == .alertFirstButtonReturn {
|
|
|
|
+ var annos: [CPDFAnnotation] = []
|
|
|
|
+ for i in 0 ..< doc.pageCount {
|
|
|
|
+ let page = self.pdfDocument()?.page(at: i)
|
|
|
|
+ for anno in page?.annotations ?? [] {
|
|
|
|
+ if anno is CPDFTextWidgetAnnotation || anno is CPDFButtonWidgetAnnotation || anno is CPDFChoiceWidgetAnnotation {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ // if ([annotation.widgetFieldType isEqualToString:PDFAnnotationWidgetSubtypeSignature]) {
|
|
|
|
+ // continue;
|
|
|
|
+ // }
|
|
|
|
+ annos.append(anno)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for anno in annos {
|
|
|
|
+ self.listView?.remove(anno)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self.reloadAnnotation()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@objc func editNoteTextFromTable(_ sender: NSMenuItem) {
|
|
@objc func editNoteTextFromTable(_ sender: NSMenuItem) {
|
|
@@ -600,6 +599,33 @@ extension KMLeftSideViewController {
|
|
// self.annotationSort(sortArray: [])
|
|
// self.annotationSort(sortArray: [])
|
|
self.reloadAnnotation()
|
|
self.reloadAnnotation()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func showNoteEmptyView() {
|
|
|
|
+ let view = self.noteOutlineView.enclosingScrollView?.documentView
|
|
|
|
+ let viewFrame = view?.frame ?? .zero
|
|
|
|
+ let emptyVcSize = self.leftSideEmptyVC.emptyAnnotationView.frame.size
|
|
|
|
+ self.leftSideEmptyVC.emptyAnnotationView.frame = NSMakeRect((viewFrame.size.width-emptyVcSize.width)/2.0,(viewFrame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height)
|
|
|
|
+
|
|
|
|
+ self.leftSideEmptyVC.emptyAnnotationView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
|
|
|
|
+ self.noteOutlineView.enclosingScrollView?.documentView?.addSubview(self.leftSideEmptyVC.emptyAnnotationView)
|
|
|
|
+ self.leftSideEmptyVC.exportAnnotationBtn.isEnabled = false
|
|
|
|
+ self.leftSideEmptyVC.deleteAnnotationBtn.isEnabled = false
|
|
|
|
+
|
|
|
|
+ if (self.leftView.segmentedControl.selectedSegment == KMSelectedSegmentType.annotation.rawValue) {
|
|
|
|
+ self.noteHeaderView.isHidden = true
|
|
|
|
+ self.toolButtonBoxLayoutConstraint.constant = 40.0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func hideNoteEmptyView() {
|
|
|
|
+ self.leftSideEmptyVC.emptyAnnotationView.removeFromSuperview()
|
|
|
|
+ self.leftSideEmptyVC.exportAnnotationBtn.isEnabled = true
|
|
|
|
+ self.leftSideEmptyVC.deleteAnnotationBtn.isEnabled = true
|
|
|
|
+ if (self.leftView.segmentedControl.selectedSegment == KMSelectedSegmentType.annotation.rawValue) {
|
|
|
|
+ self.noteHeaderView.isHidden = false
|
|
|
|
+ self.toolButtonBoxLayoutConstraint.constant = 64.0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - Note
|
|
// MARK: - Note
|
|
@@ -639,9 +665,9 @@ extension KMLeftSideViewController {
|
|
func reloadAnnotation() {
|
|
func reloadAnnotation() {
|
|
if self.listView != nil {
|
|
if self.listView != nil {
|
|
let filterKey = self.pdfDocument()?.documentURL.path ?? ""
|
|
let filterKey = self.pdfDocument()?.documentURL.path ?? ""
|
|
- var typeArr: [Any] = KMBotaTools.noteFilterAnnoTypes(key: filterKey)
|
|
|
|
- var colorArr: [Any] = KMBotaTools.noteFilterColors(key: filterKey)
|
|
|
|
- var authorArr: [Any] = KMBotaTools.noteFilterAuthors(key: filterKey)
|
|
|
|
|
|
+ let typeArr: [Any] = KMBotaTools.noteFilterAnnoTypes(key: filterKey)
|
|
|
|
+ let colorArr: [Any] = KMBotaTools.noteFilterColors(key: filterKey)
|
|
|
|
+ let authorArr: [Any] = KMBotaTools.noteFilterAuthors(key: filterKey)
|
|
if typeArr.count == 0 && colorArr.count == 0 && authorArr.count == 0 {
|
|
if typeArr.count == 0 && colorArr.count == 0 && authorArr.count == 0 {
|
|
// self.filtrateButton.image = NSImage(named: "KMImageNameAnnotationsFiltrate")
|
|
// self.filtrateButton.image = NSImage(named: "KMImageNameAnnotationsFiltrate")
|
|
self.filterButtonLayer?.isHidden = true
|
|
self.filterButtonLayer?.isHidden = true
|