|
@@ -604,7 +604,7 @@ extension AppDelegate {
|
|
|
NSSelectorFromString("menuItemAction_FullScreen:"),
|
|
|
NSSelectorFromString("menuItemAction_Presentation:"),
|
|
|
NSSelectorFromString("menuItemAction_SplitView:"),
|
|
|
- NSSelectorFromString("menuItemAction_Thumbnail:"),
|
|
|
+ NSSelectorFromString("menuItemAction_BOTAMode:"),
|
|
|
NSSelectorFromString("menuItemAction_Outline:"),
|
|
|
NSSelectorFromString("menuItemAction_Notes:"),
|
|
|
NSSelectorFromString("menuItemAction_Annotate:"),
|
|
@@ -622,73 +622,208 @@ extension AppDelegate {
|
|
|
}
|
|
|
|
|
|
func validateViewMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
|
|
-
|
|
|
- return true
|
|
|
+ let action = menuItem.action
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ if action == NSSelectorFromString("menuItemAction_ChangeDisplayMode:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_ReadMode:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_FullScreen:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_Presentation:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_SplitView:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_BOTAMode:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_Themes:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_Zoom:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_Rotate:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_HighlightFormsField:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_HighlightLinks:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_ResetForm:") {
|
|
|
+
|
|
|
+ } else if action == NSSelectorFromString("menuItemAction_AutoScroll:") {
|
|
|
+
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
}
|
|
|
|
|
|
//MARK: -IBAction
|
|
|
@IBAction func menuItemAction_ChangeDisplayMode(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ if sender.tag == 1 {
|
|
|
+ mainVC.updatePDFViewDisplayMode(viewMode: .singlePage)
|
|
|
+ } else if sender.tag == 2 {
|
|
|
+ mainVC.updatePDFViewDisplayMode(viewMode: .singlePageContinuous)
|
|
|
+ } else if sender.tag == 3 {
|
|
|
+ mainVC.updatePDFViewDisplayMode(viewMode: .twoUp)
|
|
|
+ } else if sender.tag == 4 {
|
|
|
+ mainVC.updatePDFViewDisplayMode(viewMode: .twoUpContinuous)
|
|
|
+ } else if sender.tag == 5 {
|
|
|
+ mainVC.updatePDFViewDisplayMode(isbookMode: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_ReadMode(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ mainVC.viewManager.isPDFReadMode = !mainVC.viewManager.isPDFReadMode
|
|
|
+ if mainVC.viewManager.isPDFReadMode {
|
|
|
+ mainVC.openPDFReadMode()
|
|
|
+ } else {
|
|
|
+ mainVC.exitPDFReadMode()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_FullScreen(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ mainVC.view.window?.toggleFullScreen(nil)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_Presentation(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ mainVC.togglePresentation(nil)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_SplitView(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @IBAction func menuItemAction_Thumbnail(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @IBAction func menuItemAction_Outline(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @IBAction func menuItemAction_Notes(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ if sender.tag == 0 {
|
|
|
+ mainVC.listView.viewSplitMode = .vertical
|
|
|
+ } else if sender.tag == 1 {
|
|
|
+ mainVC.listView.viewSplitMode = .horizontal
|
|
|
+ } else if sender.tag == 2 {
|
|
|
+ mainVC.listView.viewSplitMode = .disable
|
|
|
+ }
|
|
|
+ mainVC.reloadPDFSplitInfo()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @IBAction func menuItemAction_Annotate(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ @IBAction func menuItemAction_BOTAMode(_ sender: NSMenuItem) {
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ if sender.tag == 0 {
|
|
|
+ if mainVC.viewManager.pdfSideBarType == .thumbnail {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .none
|
|
|
+ } else {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .thumbnail
|
|
|
+ }
|
|
|
+ } else if sender.tag == 1 {
|
|
|
+ if mainVC.viewManager.pdfSideBarType == .outline {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .none
|
|
|
+ } else {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .outline
|
|
|
+ }
|
|
|
+ } else if sender.tag == 2 {
|
|
|
+ if mainVC.viewManager.pdfSideBarType == .bookmark {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .none
|
|
|
+ } else {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .bookmark
|
|
|
+ }
|
|
|
+ } else if sender.tag == 3 {
|
|
|
+ if mainVC.viewManager.pdfSideBarType == .annotation {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .none
|
|
|
+ } else {
|
|
|
+ mainVC.viewManager.pdfSideBarType = .annotation
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if mainVC.viewManager.pdfSideBarType == .none {
|
|
|
+ mainVC.toggleCloseLeftSide()
|
|
|
+ } else {
|
|
|
+ mainVC.toggleOpenLeftSide(pdfSideBarType: mainVC.viewManager.pdfSideBarType)
|
|
|
+ }
|
|
|
+ mainVC.reloadSideBar()
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
|
|
|
@IBAction func menuItemAction_Themes(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ var model: KMPDFViewMode = .normal
|
|
|
+ var color = NSColor.clear
|
|
|
+
|
|
|
+ if sender.tag == 0 {
|
|
|
+ model = .normal
|
|
|
+ } else if sender.tag == 1 {
|
|
|
+ model = .soft
|
|
|
+ } else if sender.tag == 2 {
|
|
|
+ model = .green
|
|
|
+ } else if sender.tag == 3 {
|
|
|
+ model = .night
|
|
|
+ } else {
|
|
|
+ model = .other
|
|
|
+
|
|
|
+ }
|
|
|
+ mainVC.listView.setPageBackgroundColorWith(color, viewMode: model)
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_Zoom(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ var type: KMPDFZoomType = .width
|
|
|
+ if sender.tag == 0 {
|
|
|
+ type = .width
|
|
|
+ } else if sender.tag == 1 {
|
|
|
+ type = .fit
|
|
|
+ } else if sender.tag == 2 {
|
|
|
+ type = .actualSize
|
|
|
+ } else if sender.tag == 3 {
|
|
|
+ type = .zoom_In
|
|
|
+ } else if sender.tag == 4 {
|
|
|
+ type = .zoom_Out
|
|
|
+ }
|
|
|
+ mainVC.selectZoom(type)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_Rotate(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ if sender.tag == 0 {
|
|
|
+ mainVC.rotateLeft(page: mainVC.listView.currentPage(), listView: mainVC.listView)
|
|
|
+ } else if sender.tag == 1 {
|
|
|
+ mainVC.rotateRight(page: mainVC.listView.currentPage(), listView: mainVC.listView)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_HighlightFormsField(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ let enabled = CPDFKitConfig.sharedInstance().enableFormFieldHighlight()
|
|
|
+ CPDFKitConfig.sharedInstance().setEnableFormFieldHighlight(!enabled)
|
|
|
+
|
|
|
+ mainVC.listView.setNeedsDisplayForVisiblePages()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_HighlightLinks(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ let enabled = CPDFKitConfig.sharedInstance().enableLinkFieldHighlight()
|
|
|
+ CPDFKitConfig.sharedInstance().setEnableLinkFieldHighlight(!enabled)
|
|
|
+
|
|
|
+ mainVC.listView.setNeedsDisplayForVisiblePages()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_ResetForm(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ mainVC.listView.resetFormAnnotation()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func menuItemAction_AutoScroll(_ sender: NSMenuItem) {
|
|
|
-
|
|
|
+ if let mainVC = self.mainViewController() {
|
|
|
+ mainVC.toggleAutoFlow(nil)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|