|
@@ -28,6 +28,7 @@ import Cocoa
|
|
|
case viewSetting
|
|
|
case sign
|
|
|
case AITools
|
|
|
+ case OCR
|
|
|
|
|
|
func isToolMode() -> Bool {
|
|
|
return (self == .Move || self == .Magnify || self == .Select || self == .SelectZoom)
|
|
@@ -97,6 +98,8 @@ import Cocoa
|
|
|
case comparison = 8010
|
|
|
case aiTools = 8011
|
|
|
case measure = 8012
|
|
|
+ case fileOCR
|
|
|
+ case areaOCR
|
|
|
}
|
|
|
|
|
|
@objc protocol KMToolbarViewControllerDelegate {
|
|
@@ -286,7 +289,17 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
|
|
|
|
|
|
@objc private func OCRbtnAction1(_ item: KMToolbarClickButton) {
|
|
|
FMTrackEventManager.defaultManager.trackEvent(event: "Tbr", withProperties: ["Tbr_Btn": "Btn_Tbr_OCR"])
|
|
|
- self._itemAction(item)
|
|
|
+
|
|
|
+ if let item: KMToolbarItemView = item.clickObject as? KMToolbarItemView {
|
|
|
+ var type: KMToolbarType = .fileOCR
|
|
|
+ if (item.btnTag == KMToolbarType.fileOCR.rawValue) {
|
|
|
+ type = .fileOCR
|
|
|
+ } else if (item.btnTag == KMToolbarType.areaOCR.rawValue) {
|
|
|
+ type = .areaOCR
|
|
|
+ }
|
|
|
+ self.delegate?.toolbarViewController?(self, clickChaildToolType: type, toolbar: item)
|
|
|
+ self._itemSetPromptFlag(item: item)
|
|
|
+ }
|
|
|
}
|
|
|
@objc private func OCRbtnAction2(_ item: KMToolbarClickButton) {
|
|
|
FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_Converter", withProperties: ["SubTbr_Btn": "Btn_SubTbr_Converter_OCR"])
|
|
@@ -926,6 +939,8 @@ extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidatio
|
|
|
KMToolbarSnapshotIdentifier /*, KMToolbarTTSIdentifier*/]
|
|
|
case .sign:
|
|
|
return [KMToolbarToolSignBoxIdentifier, KMSignDigitalSignToolbarItemIdentifier]
|
|
|
+ case .OCR:
|
|
|
+ return [KMToolbarToolOCRFileIdentifier, KMToolbarToolOCRAreaIdentifier]
|
|
|
default:
|
|
|
break
|
|
|
}
|
|
@@ -1104,6 +1119,8 @@ extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidatio
|
|
|
return item!
|
|
|
} else if KMSignIdentifiers.contains(identifier) {
|
|
|
self._setupSignItem(item)
|
|
|
+ } else if KMOCRIdentifiers.contains(identifier) {
|
|
|
+ self._setupOCRItem(item)
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -1395,7 +1412,8 @@ extension KMToolbarViewController {
|
|
|
item?.boxImagePosition = .imageAbove
|
|
|
item?.toolTip = NSLocalizedString("Recognize text from Image-based or Scanned PDF with OCR", comment: "")
|
|
|
item?.selectBackgroundType = .imageBox
|
|
|
- item?.btnAction = #selector(OCRbtnAction1)
|
|
|
+ item?.btnTag = KMToolbarViewType.OCR.rawValue
|
|
|
+ item?.btnAction = #selector(leftControllButtonAction)
|
|
|
item?.promptIdentifier = identifier
|
|
|
|
|
|
let menuItem = NSMenuItem.init(title: NSLocalizedString("OCR", comment: ""), action: #selector(_menuItemAction), target: self)
|
|
@@ -2634,6 +2652,27 @@ extension KMToolbarViewController {
|
|
|
item?.menuFormRepresentation = menuItem
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private func _setupOCRItem(_ item: KMToolbarItemView?) {
|
|
|
+ let identifier = item?.itemIdentifier
|
|
|
+ if identifier == KMToolbarToolOCRFileIdentifier {
|
|
|
+ item?.image = NSImage(named: "KMImageNameButtonEidtPDFText")
|
|
|
+ item?.target = self
|
|
|
+ item?.btnTag = CAnnotationType.fileOCR.rawValue
|
|
|
+ item?.toolTip = NSLocalizedString("File", comment: "")
|
|
|
+ item?.titleName = NSLocalizedString("File", comment: "")
|
|
|
+ item?.boxImagePosition = .imageLeft
|
|
|
+ item?.btnAction = #selector(OCRbtnAction1)
|
|
|
+ } else if identifier == KMToolbarToolOCRAreaIdentifier {
|
|
|
+ item?.image = NSImage(named: "KMImageNameButtonEidtPDFImage")
|
|
|
+ item?.target = self
|
|
|
+ item?.btnTag = CAnnotationType.areaOCR.rawValue
|
|
|
+ item?.toolTip = NSLocalizedString("Area", comment: "")
|
|
|
+ item?.titleName = NSLocalizedString("Area", comment: "")
|
|
|
+ item?.boxImagePosition = .imageLeft
|
|
|
+ item?.btnAction = #selector(OCRbtnAction1)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
extension KMToolbarViewController: NSMenuItemValidation {
|