|
@@ -356,9 +356,69 @@ extension KMBrowserWindowController: NSSearchFieldDelegate {
|
|
|
// MARK: -
|
|
|
// MARK: Menu Actions
|
|
|
|
|
|
+extension KMBrowserWindowController {
|
|
|
+ func canResponseDocumentAction() -> Bool {
|
|
|
+ if (self.browser == nil) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ guard let _ = self.browser.activeTabContents() as? KMMainDocument else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// MARK: -
|
|
|
// MARK: File Menu
|
|
|
|
|
|
+extension KMBrowserWindowController: NSMenuDelegate, NSMenuItemValidation {
|
|
|
+ func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
|
|
+ if (self.browser == nil) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ guard let action = menuItem.action else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ guard let document = self.browser.activeTabContents() as? KMMainDocument else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (KMSystemMenu.isFileSelector(sel: action)) {
|
|
|
+ if (document.isHome) {
|
|
|
+ if (menuItem.action == KMSystemMenu.File.closeTagPageSelector ||
|
|
|
+ menuItem.action == KMSystemMenu.File.propertySelector ||
|
|
|
+ menuItem.action == KMSystemMenu.File.showInFinderSelector ||
|
|
|
+ menuItem.action == KMSystemMenu.File.printSelector) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return document.homeViewController.validateMenuItem(menuItem)
|
|
|
+ } else {
|
|
|
+ return document.mainViewController.validateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (KMSystemMenu.isEditSelector(sel: action)) {
|
|
|
+ return document.isHome ? false : document.mainViewController.validateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+ if (KMSystemMenu.isViewSelector(sel: action)) {
|
|
|
+ return document.isHome ? false : document.mainViewController.validateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+ if (KMSystemMenu.isAnnotationSelector(sel: action)) {
|
|
|
+ return document.isHome ? false : document.mainViewController.validateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+ if (KMSystemMenu.isGotoSelector(sel: action)) {
|
|
|
+ return document.isHome ? false : document.mainViewController.validateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+ if (KMSystemMenu.isToolSelector(sel: action)) {
|
|
|
+ return document.isHome ? false : document.mainViewController.validateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+ if (KMSystemMenu.isWindowSelector(sel: action)) {
|
|
|
+ return document.isHome ? document.homeViewController.validateMenuItem(menuItem) : document.mainViewController.validateMenuItem(menuItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
extension KMBrowserWindowController {
|
|
|
@IBAction func menuItemAction_openFile(_ sender: Any) {
|
|
|
super.openDocument(sender)
|
|
@@ -383,3 +443,769 @@ extension KMBrowserWindowController {
|
|
|
self.openDocumentWindow()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// MARK: - KMSystemFileMenuProtocol
|
|
|
+
|
|
|
+extension KMBrowserWindowController: KMSystemFileMenuProtocol {
|
|
|
+ func menuItemClick_mergePDF(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemClick_mergePDF(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemClick_mergePDF(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemClick_Compress(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemClick_Compress(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemClick_Compress(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToWord(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToWord(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToWord(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToExcel(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToExcel(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToExcel(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToPPT(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToPPT(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToPPT(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToRTF(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToRTF(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToRTF(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToHTML(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToHTML(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToHTML(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToText(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToText(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToText(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToCSV(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToCSV(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToCSV(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_ConvertToImage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_ConvertToImage(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_ConvertToImage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemClick_SettingPassword(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemClick_SettingPassword(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemClick_SettingPassword(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemClick_RemovePassword(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemClick_RemovePassword(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_closeWindow(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_closeWindow(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_closeWindow(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_closeAllWindows(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_closeAllWindows(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_closeAllWindows(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_closeTagPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_closeTagPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_showInFinder(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_showInFinder(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_property(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_property(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_print(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_print(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - KMSystemViewMenuProtocol
|
|
|
+
|
|
|
+extension KMBrowserWindowController: KMSystemViewMenuProtocol {
|
|
|
+ func menuItemAction_adjustWidth(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_adjustWidth(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_adjustPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_adjustPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_size(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_size(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_zoomOut(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_zoomOut(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_zoomIn(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_zoomIn(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_singlePage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_singlePage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_singlePageContinue(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_singlePageContinue(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_doublePage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_doublePage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_doublePageContinue(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_doublePageContinue(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_bookMode(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_bookMode(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_readMode(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_readMode(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_showSplitPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_showSplitPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_rotateLeft(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_rotateLeft(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_rotateRight(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_rotateRight(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_rotateAllPageLeft(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_rotateAllPageLeft(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_rotateAllPageRight(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_rotateAllPageRight(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_view_readMode(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_view_readMode(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_hiddenLeftSide(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_hiddenLeftSide(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_hiddenRightSide(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_hiddenRightSide(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_thumai(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_thumai(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_outline(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_outline(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_bookmark(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_bookmark(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_annotation(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_annotation(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_search(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_search(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_hiddenPageIndicator(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_hiddenPageIndicator(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - KMSystemEditMenuProtocol
|
|
|
+
|
|
|
+extension KMBrowserWindowController: KMSystemEditMenuProtocol {
|
|
|
+ func menuItemAction_find(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_find(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - Annotation Menu
|
|
|
+
|
|
|
+extension KMBrowserWindowController {
|
|
|
+ @IBAction func menuItemAction_highlight(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_highlight(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_underline(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_underline(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_deleteLine(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_deleteLine(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_freehand(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_freehand(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_text(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_text(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_note(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_note(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_squre(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_squre(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_circle(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_circle(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_arrow(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_arrow(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_line(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_line(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // link
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_link(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_link(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_linkPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_linkPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // stamp
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_stamp(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_stamp(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_signure(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_signure(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_hiddenAllAnnotation(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_hiddenAllAnnotation(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_clearAllAnnotation(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_clearAllAnnotation(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - KMSystemGotoMenuProtocol
|
|
|
+
|
|
|
+extension KMBrowserWindowController: KMSystemGotoMenuProtocol {
|
|
|
+ func menuItemAction_nextPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_nextPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_forwardPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_forwardPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_firstPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_firstPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_lastPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_lastPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_forward(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_forward(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_goback(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_goback(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_gotoPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_gotoPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - KMSystemToolMenuProtocol
|
|
|
+
|
|
|
+extension KMBrowserWindowController: KMSystemToolMenuProtocol {
|
|
|
+ func menuItemAction_scrolTool(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_scrolTool(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_zoomOutTool(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_zoomOutTool(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_selectTool(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
|
|
|
+ document.mainViewController.menuItemAction_selectTool(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// MARK: - KMSystemWindowMenuRrotocol
|
|
|
+
|
|
|
+extension KMBrowserWindowController: KMSystemWindowMenuRrotocol {
|
|
|
+ func menuItemAction_showForwardTagPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_showForwardTagPage(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_showForwardTagPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_showNextTagPage(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_showNextTagPage(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_showNextTagPage(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_newTagPageToNewWindow(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_newTagPageToNewWindow(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_newTagPageToNewWindow(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func menuItemAction_mergeAllWindow(_ sender: Any) {
|
|
|
+ if (self.canResponseDocumentAction() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if let document = self.browser.activeTabContents() as? KMMainDocument {
|
|
|
+ if (document.isHome) {
|
|
|
+ document.homeViewController.menuItemAction_mergeAllWindow(sender)
|
|
|
+ } else {
|
|
|
+ document.mainViewController.menuItemAction_mergeAllWindow(sender)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|