AppDelegate+MenuAction.swift 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  1. //
  2. // AppDelegate+MenuAction.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2025/1/2.
  6. //
  7. import Foundation
  8. //MARK: - NSMenuDelegate
  9. extension AppDelegate: NSMenuDelegate, NSMenuItemValidation {
  10. func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
  11. let action = menuItem.action
  12. if self.isPDFReaderProMenuActions(sel: action) {
  13. return self.validatePDFReaderProMenuItem(menuItem)
  14. } else if self.isFileMenuActions(sel: action) {
  15. return self.validateFileMenuItem(menuItem)
  16. } else if self.isEditMenuActions(sel: action) {
  17. return self.validateEditMenuItem(menuItem)
  18. } else if self.isViewMenuActions(sel: action) {
  19. return self.validateViewMenuItem(menuItem)
  20. } else if self.isGoMenuActions(sel: action) {
  21. return self.validateGoMenuItem(menuItem)
  22. } else if self.isWindowMenuActions(sel: action) {
  23. return self.validateWindowMenuItem(menuItem)
  24. } else if self.isHelpMenuActions(sel: action) {
  25. return self.validateHelpMenuItem(menuItem)
  26. }
  27. // if (action == #selector(sharePageItemAction)) {
  28. // guard let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController else {
  29. // return false
  30. // }
  31. //
  32. // let isHome = _windowC.browser?.activeTabContents()?.isHome ?? false
  33. // return !isHome
  34. // }
  35. // if action == #selector(menuItemAction_closeDocument) {
  36. // guard let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController else {
  37. // if NSApp.mainWindow?.windowController != nil {
  38. // return true
  39. // }
  40. // return false
  41. // }
  42. // let isNewTab = _windowC.browser?.activeTabContents()?.isNewTab ?? false
  43. // if isNewTab {
  44. // return true
  45. // }
  46. // }
  47. return false
  48. }
  49. func updateLoginMenuItem() {
  50. let firstItem = NSApp.mainMenu?.item(at: 0)?.submenu
  51. if firstItem != nil {
  52. let item1 = firstItem?.item(withTag: 11)
  53. let item2 = firstItem?.item(withTag: 12)
  54. let item3 = firstItem?.item(withTag: 13)
  55. let item4 = firstItem?.item(withTag: 14)
  56. let item6 = firstItem?.item(withTag: kKMMainMenuAccountRefreshItemTag)
  57. item1?.isHidden = true
  58. item2?.isHidden = true
  59. item3?.isHidden = true
  60. item4?.isHidden = true
  61. item6?.isHidden = true
  62. }
  63. }
  64. @objc func clickOutline(menuItem: NSMenuItem) {
  65. KMPrint("更新菜单栏")
  66. }
  67. func menu(_ menu: NSMenu, update item: NSMenuItem, at index: Int, shouldCancel: Bool) -> Bool {
  68. return true
  69. }
  70. // MARK: - update Menu
  71. func initMainMenu() {
  72. // 处理菜单栏多语
  73. let mainMenu = NSApp.mainMenu
  74. if (mainMenu == nil) {
  75. return
  76. }
  77. for menu in mainMenu!.items {
  78. let subMenu = menu.submenu
  79. for item in subMenu!.items {
  80. item.title = NSLocalizedString(item.title, comment: "")
  81. let itemSubMenu = item.submenu
  82. if (itemSubMenu == nil) {
  83. continue
  84. }
  85. for item in itemSubMenu!.items {
  86. item.title = NSLocalizedString(item.title, comment: "")
  87. let itemSubMenu = item.submenu
  88. if (itemSubMenu == nil) {
  89. continue
  90. }
  91. for item in itemSubMenu!.items {
  92. item.title = NSLocalizedString(item.title, comment: "")
  93. }
  94. }
  95. }
  96. }
  97. // let PDFOfficeMenu = mainMenu?.item(at: 0)?.submenu
  98. //#if VERSION_DMG
  99. // _ = PDFOfficeMenu?.insertItem(withTitle: NSLocalizedString("Check for Updates", comment: ""), action: #selector(checkForUpdates), target: self, at: 3)
  100. // _ = PDFOfficeMenu?.insertItem(withTitle: NSLocalizedString("Enter License", comment: ""), action: #selector(enterLicense), target: self, at: 4)
  101. // if VerificationManager.default().needUpgradeLicense {
  102. // _ = PDFOfficeMenu?.insertItem(withTitle: NSLocalizedString("PDF to Office Pack", comment: ""), action: #selector(pdftoOfficeMenuItemAction), target: self, at: 5)
  103. // }
  104. //
  105. // let accountRefreshItem = PDFOfficeMenu?.insertItem(withTitle: NSLocalizedString("Account Refresh", comment: ""), action: #selector(accountRefreshAction), target: self, at: 8)
  106. // accountRefreshItem?.tag = kKMMainMenuAccountRefreshItemTag
  107. //#endif
  108. //#if !VERSION_DMG
  109. // _ = PDFOfficeMenu?.insertItem(withTitle: NSLocalizedString("Restore Previous Purchase", comment: ""), action: #selector(restoreSubscriptions), target: self, at: 1)
  110. //#endif
  111. // if let items = PDFOfficeMenu?.items {
  112. // for menu in items {
  113. //
  114. // }
  115. // }
  116. // if let item = PDFOfficeMenu?.item(withTitle: NSLocalizedString("Volume Discount", comment: "")) {
  117. // item.isHidden = true
  118. // }
  119. // if let item = PDFOfficeMenu?.item(withTitle: NSLocalizedString("One License for Mac and Windows", comment: "")) {
  120. // item.isHidden = true
  121. // }
  122. // if let item = PDFOfficeMenu?.item(withTitle: NSLocalizedString("Education Discount", comment: "")) {
  123. // item.isHidden = true
  124. // }
  125. //
  126. let fileMenu = mainMenu?.item(at: 1)?.submenu
  127. for item in fileMenu?.items ?? [] {
  128. if item.action == NSSelectorFromString("menuItemAction_showInFinder:") {
  129. let shareItem: NSMenuItem? = NSMenuItem(title: KMLocalizedString("Share"), action: nil, target: nil)
  130. fileMenu?.insertItem(shareItem!, at: item.index)
  131. shareItem?.submenu = NSSharingServicePicker.menu(forSharingItems: [""], subjectContext: "", withTarget: self, selector: #selector(sharePageItemAction), serviceDelegate: nil)
  132. }
  133. }
  134. }
  135. @objc func sharePageItemAction(sender: NSMenuItem) {
  136. if ((NSApp.mainWindow?.windowController is KMBrowserWindowController) == false) {
  137. return
  138. }
  139. let windowControler = NSApp.mainWindow?.windowController as! KMBrowserWindowController
  140. let model = windowControler.browser?.tabStripModel
  141. if let cnt = model?.count(), cnt <= 0 {
  142. return
  143. }
  144. if let data = model?.activeTabContents()?.isHome, data {
  145. return
  146. }
  147. let document: KMMainDocument = model?.activeTabContents() as! KMMainDocument
  148. if let data = document.mainViewController?.saveWatermarkFlag, !data {
  149. let represent : NSSharingService = sender.representedObject as! NSSharingService
  150. represent.perform(withItems: [document.fileURL as Any])
  151. return
  152. }
  153. let represent : NSSharingService = sender.representedObject as! NSSharingService
  154. represent.perform(withItems: [document.fileURL as Any])
  155. }
  156. @objc func accountRefreshAction() {
  157. }
  158. }
  159. // MARK: - PDF Reader Pro Menu
  160. extension AppDelegate {
  161. func isPDFReaderProMenuActions(sel: Selector?) -> Bool {
  162. guard let selector = sel else {
  163. return false
  164. }
  165. let selectors = [NSSelectorFromString("menuItemAction_openPreferenceWindow:"),
  166. NSSelectorFromString("menuItemAction_loginMenuItemAction:"),
  167. NSSelectorFromString("menuItemAction_logoutMenuItemAction:"),
  168. NSSelectorFromString("menuItemAction_buyNowItemAction:"),
  169. NSSelectorFromString("menuItemAction_restoreMenuItemAction:"),
  170. NSSelectorFromString("menuItemAction_EducationDiscountAction:"),
  171. NSSelectorFromString("menuItemAction_volumeDiscount:")]
  172. if selectors.contains(selector) {
  173. return true
  174. }
  175. return false
  176. }
  177. func validatePDFReaderProMenuItem(_ menuItem: NSMenuItem) -> Bool {
  178. return true
  179. }
  180. //MARK: -IBAction
  181. @IBAction func menuItemAction_openPreferenceWindow(_ sender: Any) {
  182. SettingsWindowController.shared.showWindow(self)
  183. }
  184. @IBAction func menuItemAction_loginMenuItemAction(_ sender: Any) {
  185. }
  186. @IBAction func menuItemAction_logoutMenuItemAction(_ sender: Any) {
  187. }
  188. @IBAction func menuItemAction_buyNowItemAction(_ sender: Any) {
  189. }
  190. @IBAction func menuItemAction_restoreMenuItemAction(_ sender: Any) {
  191. }
  192. @IBAction func menuItemAction_EducationDiscountAction(_ sender: NSMenuItem) {
  193. KMTools.openEducateWebSite()
  194. }
  195. @IBAction func menuItemAction_volumeDiscount(_ sender: NSMenuItem) {
  196. KMTools.openVPPWebSite()
  197. }
  198. }
  199. //MARK: - File Menu
  200. extension AppDelegate {
  201. func isFileMenuActions(sel: Selector?) -> Bool {
  202. guard let selector = sel else {
  203. return false
  204. }
  205. let selectors = [NSSelectorFromString("menuItemAction_NewFromFile:"),
  206. NSSelectorFromString("menuItemAction_NewFromWeb:"),
  207. NSSelectorFromString("menuItemAction_NewFromClipboard:"),
  208. NSSelectorFromString("menuItemAction_NewFromScanner:"),
  209. NSSelectorFromString("menuItemAction_NewFromBlankPage:"),
  210. NSSelectorFromString("menuItemAction_NewFromWindow:"),
  211. NSSelectorFromString("menuItemAction_MergePDFFiles:"),
  212. NSSelectorFromString("menuItemAction_closeDocument:"),
  213. NSSelectorFromString("menuItemAction_closeWindow:"),
  214. NSSelectorFromString("menuItemAction_closeAllWindows:"),
  215. NSSelectorFromString("menuItemClick_saveAsFlattenedPDF:"),
  216. NSSelectorFromString("menuItemClick_Compress:"),
  217. NSSelectorFromString("menuItemAction_ConvertTo:"),
  218. NSSelectorFromString("menuItemAction_addPassword:"),
  219. NSSelectorFromString("menuItemAction_removePassword:"),
  220. NSSelectorFromString("menuItemAction_unlockFunction:"),
  221. NSSelectorFromString("menuItemAction_searchPDF:"),
  222. NSSelectorFromString("menuItemAction_performFindPanelAction:"),
  223. NSSelectorFromString("menuItemAction_showInFinder:"),
  224. NSSelectorFromString("menuItemAction_property:"),
  225. NSSelectorFromString("menuItemAction_print:"),
  226. NSSelectorFromString("menuItemAction_customPrint:"),
  227. NSSelectorFromString("sharePageItemActionWithSender:")]
  228. if selectors.contains(selector) {
  229. return true
  230. }
  231. return false
  232. }
  233. func validateFileMenuItem(_ menuItem: NSMenuItem) -> Bool {
  234. let action = menuItem.action
  235. if action == NSSelectorFromString("menuItemAction_NewFromFile:") {
  236. return true
  237. } else if action == NSSelectorFromString("menuItemAction_NewFromWeb:") {
  238. return true
  239. } else if action == NSSelectorFromString("menuItemAction_NewFromClipboard:") {
  240. return true
  241. } else if action == NSSelectorFromString("menuItemAction_NewFromScanner:") {
  242. return true
  243. } else if action == NSSelectorFromString("menuItemAction_NewFromBlankPage:") {
  244. return true
  245. } else if action == NSSelectorFromString("menuItemAction_NewFromWindow:") {
  246. return true
  247. } else if action == NSSelectorFromString("menuItemAction_MergePDFFiles:") {
  248. return true
  249. } else if action == NSSelectorFromString("menuItemAction_closeDocument:") {
  250. return true
  251. } else if action == NSSelectorFromString("menuItemAction_closeWindow:") {
  252. return true
  253. } else if action == NSSelectorFromString("menuItemAction_closeAllWindows:") {
  254. return true
  255. }
  256. if let mainVC = self.mainViewController() {
  257. if action == NSSelectorFromString("menuItemClick_saveAsFlattenedPDF:") {
  258. } else if action == NSSelectorFromString("menuItemClick_Compress:") {
  259. } else if action == NSSelectorFromString("menuItemAction_ConvertTo:") {
  260. } else if action == NSSelectorFromString("menuItemAction_addPassword:") {
  261. } else if action == NSSelectorFromString("menuItemAction_removePassword:") {
  262. if mainVC.listView.document.isLocked == true {
  263. return true
  264. } else {
  265. if let pw = mainVC.listView.document.password {
  266. return true
  267. }
  268. return false
  269. }
  270. } else if action == NSSelectorFromString("menuItemAction_unlockFunction:") {
  271. return mainVC.listView.document.isEncrypted
  272. } else if action == NSSelectorFromString("menuItemAction_searchPDF:") {
  273. } else if action == NSSelectorFromString("menuItemAction_performFindPanelAction:") {
  274. } else if action == NSSelectorFromString("menuItemAction_showInFinder:") {
  275. } else if action == NSSelectorFromString("menuItemAction_property:") {
  276. } else if action == NSSelectorFromString("menuItemAction_print:") {
  277. } else if action == NSSelectorFromString("menuItemAction_customPrint:") {
  278. } else if action == NSSelectorFromString("sharePageItemActionWithSender:") {
  279. return true
  280. }
  281. return true
  282. }
  283. return false
  284. }
  285. //MARK: -IBAction
  286. @IBAction func menuItemAction_NewFromFile(_ sender: NSMenuItem) -> Void {
  287. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  288. _windowC.newFromImageFile()
  289. }
  290. }
  291. @IBAction func menuItemAction_NewFromWeb(_ sender: NSMenuItem) -> Void {
  292. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  293. _windowC.newFromWebPage()
  294. }
  295. }
  296. @IBAction func menuItemAction_NewFromClipboard(_ sender: NSMenuItem) -> Void {
  297. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  298. _windowC.newFromClipboard()
  299. }
  300. }
  301. @IBAction func menuItemAction_NewFromScanner(_ sender: NSMenuItem) -> Void {
  302. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  303. _windowC.importFromScanner()
  304. }
  305. }
  306. @IBAction func menuItemAction_NewFromBlankPage(_ sender: NSMenuItem) -> Void {
  307. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  308. _windowC.newBlankPage()
  309. }
  310. }
  311. @IBAction func menuItemAction_NewFromWindow(_ sender: NSMenuItem) -> Void {
  312. if sender.tag == 0 {
  313. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  314. _windowC.screenShot_SelectArea(nil)
  315. }
  316. } else if sender.tag == 1 {
  317. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  318. _windowC.screenShot_Window(nil)
  319. }
  320. } else if sender.tag == 2 {
  321. if let _windowC = NSApp.mainWindow?.windowController as? KMBrowserWindowController {
  322. _windowC.screenShot_FullScreen(nil)
  323. }
  324. }
  325. }
  326. @IBAction func menuItemAction_MergePDFFiles(_ sender: NSMenuItem) -> Void {
  327. if let homeVC = self.homeViewController() {
  328. homeVC.fastTool_MergePDF()
  329. } else if let mainVC = self.mainViewController() {
  330. mainVC.showMergeWindow(mainVC.listView.document.password)
  331. }
  332. }
  333. @IBAction func menuItemAction_closeDocument(_ sender: Any) {
  334. if ((NSApp.mainWindow?.windowController is KMBrowserWindowController) == false) {
  335. guard let windowControler = NSApp.mainWindow?.windowController else {
  336. return
  337. }
  338. windowControler.window?.performClose(nil)
  339. return
  340. }
  341. let windowControler = NSApp.mainWindow?.windowController as? KMBrowserWindowController
  342. if let data = windowControler?.browser, data.tabCount() >= 2 { // 有两个以上的标签
  343. if data.activeTabIndex() == 0 { // 主页不允许关闭,暂时处理为无反应
  344. return
  345. }
  346. }
  347. if let browser = windowControler?.browser {
  348. if browser.tabCount() == 1 {
  349. windowControler?.window?.close()
  350. } else {
  351. if let _ = windowControler?.window?.attachedSheet {
  352. NSSound.beep()
  353. return
  354. }
  355. browser.closeTab()
  356. }
  357. } else {
  358. windowControler?.window?.close()
  359. }
  360. }
  361. @IBAction func menuItemAction_closeWindow(_ sender: Any) {
  362. NSApp.mainWindow?.close()
  363. }
  364. @IBAction func menuItemAction_closeAllWindows(_ sender: Any) {
  365. for window in NSApp.windows {
  366. window.close()
  367. }
  368. }
  369. @IBAction func menuItemClick_saveAsFlattenedPDF(_ sender: Any) {
  370. if let mainVC = self.mainViewController() {
  371. mainVC.saveAsFlattenedPDFAction()
  372. }
  373. }
  374. @IBAction func menuItemClick_Compress(_ sender: Any) {
  375. if let mainVC = self.mainViewController() {
  376. let model = KMBatchProcessingTableViewModel.initWithFilePath(url: mainVC.listView.document.documentURL)
  377. model.password = mainVC.listView.document.password ?? ""
  378. mainVC.showCompressController(model: model)
  379. }
  380. }
  381. @IBAction func menuItemAction_ConvertTo(_ sender: NSMenuItem) {
  382. if let mainVC = self.mainViewController() {
  383. var convertType: KMPDFConvertType = .word
  384. if sender.tag == 0 {
  385. } else if sender.tag == 1 {
  386. convertType = .excel
  387. } else if sender.tag == 2 {
  388. convertType = .ppt
  389. } else if sender.tag == 30 {
  390. convertType = .jpeg
  391. } else if sender.tag == 31 {
  392. convertType = .jpg
  393. } else if sender.tag == 32 {
  394. convertType = .png
  395. } else if sender.tag == 33 {
  396. convertType = .gif
  397. } else if sender.tag == 34 {
  398. convertType = .tiff
  399. } else if sender.tag == 35 {
  400. convertType = .tga
  401. } else if sender.tag == 36 {
  402. convertType = .bmp
  403. } else if sender.tag == 37 {
  404. convertType = .jp2
  405. } else if sender.tag == 4 {
  406. convertType = .rtf
  407. } else if sender.tag == 5 {
  408. convertType = .csv
  409. } else if sender.tag == 6 {
  410. convertType = .html
  411. } else if sender.tag == 7 {
  412. convertType = .text
  413. } else if sender.tag == 8 {
  414. convertType = .json
  415. }
  416. mainVC.showConvertWindow(convertType)
  417. }
  418. }
  419. @IBAction func menuItemAction_addPassword(_ sender: Any) {
  420. if let mainVC = self.mainViewController() {
  421. mainVC.showSecureWindow()
  422. }
  423. }
  424. @IBAction func menuItemAction_removePassword(_ sender: Any) {
  425. if let mainVC = self.mainViewController() {
  426. mainVC.showRemoveSecureWindow()
  427. }
  428. }
  429. @IBAction func menuItemAction_unlockFunction(_ sender: Any) {
  430. if let mainVC = self.mainViewController() {
  431. mainVC.unlockPDFDocument()
  432. }
  433. }
  434. @IBAction func menuItemAction_searchPDF(_ sender: Any?) {
  435. if let mainVC = self.mainViewController() {
  436. mainVC.searchPDF()
  437. }
  438. }
  439. @IBAction func menuItemAction_performFindPanelAction(_ sender: NSMenuItem) {
  440. if let mainVC = self.mainViewController() {
  441. if sender.tag == 0 {
  442. mainVC.find_ReplacePDF()
  443. } else if sender.tag == 1 {
  444. mainVC.fineNext()
  445. } else if sender.tag == 2 {
  446. mainVC.findPrevious()
  447. } else if sender.tag == 3 {
  448. mainVC.useSelectionForFind()
  449. }
  450. }
  451. }
  452. @IBAction func menuItemAction_showInFinder(_ sender: Any) {
  453. if let mainVC = self.mainViewController() {
  454. mainVC.showInFinder()
  455. }
  456. }
  457. @IBAction func menuItemAction_property(_ sender: Any) {
  458. if let mainVC = self.mainViewController() {
  459. KMInfoWindowController.shared.showWindow(sender)
  460. }
  461. }
  462. @IBAction func menuItemAction_print(_ sender: Any) {
  463. if let mainVC = self.mainViewController() {
  464. mainVC.showPrintWindow()
  465. }
  466. }
  467. @IBAction func menuItemAction_customPrint(_ sender: NSMenuItem) {
  468. if let mainVC = self.mainViewController() {
  469. if sender.tag == 0 {
  470. mainVC.showPosterPrintWindow()
  471. } else if sender.tag == 1 {
  472. mainVC.showMultiplePrintWindow()
  473. } else if sender.tag == 2 {
  474. mainVC.showBookletPrintWindow()
  475. }
  476. }
  477. }
  478. }
  479. // MARK: - Edit Menu
  480. extension AppDelegate {
  481. func isEditMenuActions(sel: Selector?) -> Bool {
  482. guard let selector = sel else {
  483. return false
  484. }
  485. let selectors = [ NSSelectorFromString("menuItemAction_PasteAndMatch:"),
  486. NSSelectorFromString("menuItemAction_ShowFont:"),
  487. NSSelectorFromString("menuItemAction_FontAction:"),
  488. NSSelectorFromString("menuItemAction_CustomFont:"),
  489. NSSelectorFromString("menuItemAction_FontAlign:")]
  490. if selectors.contains(selector) {
  491. return true
  492. }
  493. return false
  494. }
  495. func validateEditMenuItem(_ menuItem: NSMenuItem) -> Bool {
  496. let action = menuItem.action
  497. if let mainVC = self.mainViewController() {
  498. if action == NSSelectorFromString("menuItemAction_PasteAndMatch:") {
  499. } else if action == NSSelectorFromString("menuItemAction_ShowFont:") {
  500. if mainVC.viewManager.toolMode == .Edit {
  501. if mainVC.viewManager.subToolMode == .None || mainVC.viewManager.subToolMode == .Edit_text {
  502. if mainVC.listView.km_editingTextAreas().count > 0 {
  503. return true
  504. }
  505. }
  506. }
  507. return false
  508. } else if action == NSSelectorFromString("menuItemAction_FontAction:") {
  509. if mainVC.viewManager.toolMode == .Edit {
  510. if mainVC.viewManager.subToolMode == .None || mainVC.viewManager.subToolMode == .Edit_text {
  511. if mainVC.listView.km_editingTextAreas().count > 0 {
  512. return true
  513. }
  514. }
  515. }
  516. return false
  517. } else if action == NSSelectorFromString("menuItemAction_CustomFont:") {
  518. if mainVC.viewManager.toolMode == .Edit {
  519. if mainVC.viewManager.subToolMode == .None || mainVC.viewManager.subToolMode == .Edit_text {
  520. if mainVC.listView.km_editingTextAreas().count > 0 {
  521. return true
  522. }
  523. }
  524. }
  525. return false
  526. } else if action == NSSelectorFromString("menuItemAction_FontAlign:") {
  527. if mainVC.viewManager.toolMode == .Edit {
  528. if mainVC.viewManager.subToolMode == .None || mainVC.viewManager.subToolMode == .Edit_text {
  529. if mainVC.listView.km_editingTextAreas().count > 0 {
  530. return true
  531. }
  532. }
  533. }
  534. return false
  535. }
  536. return true
  537. }
  538. return false
  539. }
  540. //MARK: -IBAction
  541. @IBAction func menuItemAction_PasteAndMatch(_ menuItem: NSMenuItem) {
  542. }
  543. @IBAction func menuItemAction_ShowFont(_ menuItem: NSMenuItem) {
  544. if let mainVC = self.mainViewController() {
  545. mainVC.menuItemAction_FontPanel()
  546. }
  547. }
  548. @IBAction func menuItemAction_FontAction(_ menuItem: NSMenuItem) {
  549. if let mainVC = self.mainViewController() {
  550. mainVC.menuItemAction_FontAction(menuItem.tag)
  551. }
  552. }
  553. @IBAction func menuItemAction_CustomFont(_ menuItem: NSMenuItem) {
  554. if let mainVC = self.mainViewController() {
  555. mainVC.menuItemAction_CustomFont(menuItem.tag)
  556. }
  557. }
  558. @IBAction func menuItemAction_FontAlign(_ menuItem: NSMenuItem) {
  559. if let mainVC = self.mainViewController() {
  560. mainVC.menuItemAction_FontAlign(menuItem.tag)
  561. }
  562. }
  563. }
  564. // MARK: - View Menu
  565. extension AppDelegate {
  566. func isViewMenuActions(sel: Selector?) -> Bool {
  567. guard let selector = sel else {
  568. return false
  569. }
  570. let selectors = [NSSelectorFromString("menuItemAction_ChangeDisplayMode:"),
  571. NSSelectorFromString("menuItemAction_ReadMode:"),
  572. NSSelectorFromString("menuItemAction_FullScreen:"),
  573. NSSelectorFromString("menuItemAction_Presentation:"),
  574. NSSelectorFromString("menuItemAction_SplitView:"),
  575. NSSelectorFromString("menuItemAction_BOTAMode:"),
  576. NSSelectorFromString("menuItemAction_Outline:"),
  577. NSSelectorFromString("menuItemAction_Notes:"),
  578. NSSelectorFromString("menuItemAction_Annotate:"),
  579. NSSelectorFromString("menuItemAction_Themes:"),
  580. NSSelectorFromString("menuItemAction_Zoom:"),
  581. NSSelectorFromString("menuItemAction_Rotate:"),
  582. NSSelectorFromString("menuItemAction_HighlightFormsField:"),
  583. NSSelectorFromString("menuItemAction_HighlightLinks:"),
  584. NSSelectorFromString("menuItemAction_ResetForm:"),
  585. NSSelectorFromString("menuItemAction_AutoScroll:")]
  586. if selectors.contains(selector) {
  587. return true
  588. }
  589. return false
  590. }
  591. func validateViewMenuItem(_ menuItem: NSMenuItem) -> Bool {
  592. let action = menuItem.action
  593. if let mainVC = self.mainViewController() {
  594. if action == NSSelectorFromString("menuItemAction_ChangeDisplayMode:") {
  595. menuItem.state = .off
  596. if menuItem.tag == 1 && mainVC.getPDFViewPageLayoutType() == .singlePage {
  597. menuItem.state = .on
  598. } else if menuItem.tag == 2 && mainVC.getPDFViewPageLayoutType() == .singlePageContinue {
  599. menuItem.state = .on
  600. } else if menuItem.tag == 3 && mainVC.getPDFViewPageLayoutType() == .twoPage {
  601. menuItem.state = .on
  602. } else if menuItem.tag == 4 && mainVC.getPDFViewPageLayoutType() == .twoPageContinue {
  603. menuItem.state = .on
  604. } else if menuItem.tag == 5 && mainVC.getPDFViewPageLayoutType() == .bookMode {
  605. menuItem.state = .on
  606. }
  607. } else if action == NSSelectorFromString("menuItemAction_ReadMode:") {
  608. menuItem.state = .off
  609. if mainVC.viewManager.isPDFReadMode == true {
  610. menuItem.state = .on
  611. }
  612. } else if action == NSSelectorFromString("menuItemAction_FullScreen:") {
  613. menuItem.state = .off
  614. if mainVC.view.window?.isFullScreen() == true {
  615. menuItem.state = .on
  616. }
  617. } else if action == NSSelectorFromString("menuItemAction_Presentation:") {
  618. } else if action == NSSelectorFromString("menuItemAction_SplitView:") {
  619. menuItem.state = .off
  620. if menuItem.tag == 0 && mainVC.listView.viewSplitMode == .vertical {
  621. menuItem.state = .on
  622. } else if menuItem.tag == 1 && mainVC.listView.viewSplitMode == .horizontal {
  623. menuItem.state = .on
  624. } else if menuItem.tag == 2 && mainVC.listView.viewSplitMode == .disable {
  625. menuItem.state = .on
  626. }
  627. } else if action == NSSelectorFromString("menuItemAction_BOTAMode:") {
  628. menuItem.state = .off
  629. if menuItem.tag == 0 && mainVC.viewManager.pdfSideBarType == .thumbnail {
  630. menuItem.state = .on
  631. } else if menuItem.tag == 1 && mainVC.viewManager.pdfSideBarType == .outline {
  632. menuItem.state = .on
  633. } else if menuItem.tag == 2 && mainVC.viewManager.pdfSideBarType == .bookmark {
  634. menuItem.state = .on
  635. } else if menuItem.tag == 3 && mainVC.viewManager.pdfSideBarType == .annotation {
  636. menuItem.state = .on
  637. }
  638. } else if action == NSSelectorFromString("menuItemAction_Themes:") {
  639. menuItem.state = .off
  640. if menuItem.tag == 0 && mainVC.listView.displayMode == .normal {
  641. menuItem.state = .on
  642. } else if menuItem.tag == 1 && mainVC.listView.displayMode == .soft {
  643. menuItem.state = .on
  644. } else if menuItem.tag == 2 && mainVC.listView.displayMode == .green {
  645. menuItem.state = .on
  646. } else if menuItem.tag == 3 && mainVC.listView.displayMode == .night {
  647. menuItem.state = .on
  648. }
  649. } else if action == NSSelectorFromString("menuItemAction_Zoom:") {
  650. } else if action == NSSelectorFromString("menuItemAction_Rotate:") {
  651. } else if action == NSSelectorFromString("menuItemAction_HighlightFormsField:") {
  652. let enabled = CPDFKitConfig.sharedInstance().enableFormFieldHighlight()
  653. menuItem.state = enabled ? .on : .off
  654. } else if action == NSSelectorFromString("menuItemAction_HighlightLinks:") {
  655. let enabled = CPDFKitConfig.sharedInstance().enableLinkFieldHighlight()
  656. menuItem.state = enabled ? .on : .off
  657. } else if action == NSSelectorFromString("menuItemAction_ResetForm:") {
  658. } else if action == NSSelectorFromString("menuItemAction_AutoScroll:") {
  659. menuItem.state = mainVC.isAutoFlowOn() ? .on : .off
  660. }
  661. return true
  662. }
  663. return false
  664. }
  665. //MARK: -IBAction
  666. @IBAction func menuItemAction_ChangeDisplayMode(_ sender: NSMenuItem) {
  667. if let mainVC = self.mainViewController() {
  668. if sender.tag == 1 {
  669. mainVC.updatePDFViewDisplayMode(viewMode: .singlePage)
  670. } else if sender.tag == 2 {
  671. mainVC.updatePDFViewDisplayMode(viewMode: .singlePageContinuous)
  672. } else if sender.tag == 3 {
  673. mainVC.updatePDFViewDisplayMode(viewMode: .twoUp)
  674. } else if sender.tag == 4 {
  675. mainVC.updatePDFViewDisplayMode(viewMode: .twoUpContinuous)
  676. } else if sender.tag == 5 {
  677. mainVC.updatePDFViewDisplayMode(isbookMode: true)
  678. }
  679. }
  680. }
  681. @IBAction func menuItemAction_ReadMode(_ sender: NSMenuItem) {
  682. if let mainVC = self.mainViewController() {
  683. mainVC.viewManager.isPDFReadMode = !mainVC.viewManager.isPDFReadMode
  684. if mainVC.viewManager.isPDFReadMode {
  685. mainVC.openPDFReadMode()
  686. } else {
  687. mainVC.exitPDFReadMode()
  688. }
  689. }
  690. }
  691. @IBAction func menuItemAction_FullScreen(_ sender: NSMenuItem) {
  692. if let mainVC = self.mainViewController() {
  693. mainVC.view.window?.toggleFullScreen(nil)
  694. }
  695. }
  696. @IBAction func menuItemAction_Presentation(_ sender: NSMenuItem) {
  697. if let mainVC = self.mainViewController() {
  698. mainVC.togglePresentation(nil)
  699. }
  700. }
  701. @IBAction func menuItemAction_SplitView(_ sender: NSMenuItem) {
  702. if let mainVC = self.mainViewController() {
  703. if sender.tag == 0 {
  704. mainVC.listView.viewSplitMode = .vertical
  705. } else if sender.tag == 1 {
  706. mainVC.listView.viewSplitMode = .horizontal
  707. } else if sender.tag == 2 {
  708. mainVC.listView.viewSplitMode = .disable
  709. }
  710. mainVC.reloadPDFSplitInfo()
  711. }
  712. }
  713. @IBAction func menuItemAction_BOTAMode(_ sender: NSMenuItem) {
  714. if let mainVC = self.mainViewController() {
  715. if sender.tag == 0 {
  716. if mainVC.viewManager.pdfSideBarType == .thumbnail {
  717. mainVC.viewManager.pdfSideBarType = .none
  718. } else {
  719. mainVC.viewManager.pdfSideBarType = .thumbnail
  720. }
  721. } else if sender.tag == 1 {
  722. if mainVC.viewManager.pdfSideBarType == .outline {
  723. mainVC.viewManager.pdfSideBarType = .none
  724. } else {
  725. mainVC.viewManager.pdfSideBarType = .outline
  726. }
  727. } else if sender.tag == 2 {
  728. if mainVC.viewManager.pdfSideBarType == .bookmark {
  729. mainVC.viewManager.pdfSideBarType = .none
  730. } else {
  731. mainVC.viewManager.pdfSideBarType = .bookmark
  732. }
  733. } else if sender.tag == 3 {
  734. if mainVC.viewManager.pdfSideBarType == .annotation {
  735. mainVC.viewManager.pdfSideBarType = .none
  736. } else {
  737. mainVC.viewManager.pdfSideBarType = .annotation
  738. }
  739. }
  740. if mainVC.viewManager.pdfSideBarType == .none {
  741. mainVC.toggleCloseLeftSide()
  742. } else {
  743. mainVC.toggleOpenLeftSide(pdfSideBarType: mainVC.viewManager.pdfSideBarType)
  744. }
  745. mainVC.reloadSideBar()
  746. }
  747. }
  748. @IBAction func menuItemAction_Themes(_ sender: NSMenuItem) {
  749. if let mainVC = self.mainViewController() {
  750. var model: KMPDFViewMode = .normal
  751. var color = NSColor.clear
  752. if sender.tag == 0 {
  753. model = .normal
  754. } else if sender.tag == 1 {
  755. model = .soft
  756. } else if sender.tag == 2 {
  757. model = .green
  758. } else if sender.tag == 3 {
  759. model = .night
  760. } else {
  761. model = .other
  762. }
  763. mainVC.listView.setPageBackgroundColorWith(color, viewMode: model)
  764. mainVC.updatePDFDisplaySettingView()
  765. }
  766. }
  767. @IBAction func menuItemAction_Zoom(_ sender: NSMenuItem) {
  768. if let mainVC = self.mainViewController() {
  769. var type: KMPDFZoomType = .width
  770. if sender.tag == 0 {
  771. type = .width
  772. } else if sender.tag == 1 {
  773. type = .fit
  774. } else if sender.tag == 2 {
  775. type = .actualSize
  776. } else if sender.tag == 3 {
  777. type = .zoom_In
  778. } else if sender.tag == 4 {
  779. type = .zoom_Out
  780. }
  781. mainVC.selectZoom(type)
  782. }
  783. }
  784. @IBAction func menuItemAction_Rotate(_ sender: NSMenuItem) {
  785. if let mainVC = self.mainViewController() {
  786. if sender.tag == 0 {
  787. mainVC.rotateLeft(page: mainVC.listView.currentPage(), listView: mainVC.listView)
  788. } else if sender.tag == 1 {
  789. mainVC.rotateRight(page: mainVC.listView.currentPage(), listView: mainVC.listView)
  790. }
  791. }
  792. }
  793. @IBAction func menuItemAction_HighlightFormsField(_ sender: NSMenuItem) {
  794. if let mainVC = self.mainViewController() {
  795. let enabled = CPDFKitConfig.sharedInstance().enableFormFieldHighlight()
  796. CPDFKitConfig.sharedInstance().setEnableFormFieldHighlight(!enabled)
  797. mainVC.listView.setNeedsDisplayForVisiblePages()
  798. mainVC.alertTipViewController.reloadFormAlertUI()
  799. }
  800. }
  801. @IBAction func menuItemAction_HighlightLinks(_ sender: NSMenuItem) {
  802. if let mainVC = self.mainViewController() {
  803. let enabled = CPDFKitConfig.sharedInstance().enableLinkFieldHighlight()
  804. CPDFAnnotation.updateLinkFieldHighlight(mainVC.listView, linkFieldHighlight: !enabled)
  805. }
  806. }
  807. @IBAction func menuItemAction_ResetForm(_ sender: NSMenuItem) {
  808. if let mainVC = self.mainViewController() {
  809. mainVC.listView.resetFormAnnotation()
  810. }
  811. }
  812. @IBAction func menuItemAction_AutoScroll(_ sender: NSMenuItem) {
  813. if let mainVC = self.mainViewController() {
  814. mainVC.toggleAutoFlow(nil)
  815. }
  816. }
  817. }
  818. // MARK: - Go Menu
  819. extension AppDelegate {
  820. func isGoMenuActions(sel: Selector?) -> Bool {
  821. guard let selector = sel else {
  822. return false
  823. }
  824. let selectors = [NSSelectorFromString("menuItemAction_Next:"),
  825. NSSelectorFromString("menuItemAction_Previous:"),
  826. NSSelectorFromString("menuItemAction_First:"),
  827. NSSelectorFromString("menuItemAction_Last:"),
  828. NSSelectorFromString("menuItemAction_GotoPage:"),
  829. NSSelectorFromString("menuItemAction_Back:"),
  830. NSSelectorFromString("menuItemAction_Forward:")]
  831. if selectors.contains(selector) {
  832. return true
  833. }
  834. return false
  835. }
  836. func validateGoMenuItem(_ menuItem: NSMenuItem) -> Bool {
  837. let action = menuItem.action
  838. if let mainVC = self.mainViewController() {
  839. if action == NSSelectorFromString("menuItemAction_Next:") {
  840. if mainVC.listView.isEditing() && mainVC.listView.isEditable() {
  841. return false
  842. }
  843. return (mainVC.pdfViewCanHorizontalScroll() == false && mainVC.listView.canGoToNextPage())
  844. } else if action == NSSelectorFromString("menuItemAction_Previous:") {
  845. if mainVC.listView.isEditing() && mainVC.listView.isEditable() {
  846. return false
  847. }
  848. return (mainVC.pdfViewCanHorizontalScroll() == false && mainVC.listView.canGoToPreviousPage())
  849. } else if action == NSSelectorFromString("menuItemAction_First:") {
  850. return mainVC.listView.canGoToFirstPage()
  851. } else if action == NSSelectorFromString("menuItemAction_Last:") {
  852. return mainVC.listView.canGoToLastPage()
  853. } else if action == NSSelectorFromString("menuItemAction_GotoPage:") {
  854. return true
  855. } else if action == NSSelectorFromString("menuItemAction_Back:") {
  856. return mainVC.listView.km_canGoBack()
  857. } else if action == NSSelectorFromString("menuItemAction_Forward:") {
  858. return mainVC.listView.km_canGoForward()
  859. }
  860. }
  861. return false
  862. }
  863. //MARK: -IBAction
  864. @IBAction func menuItemAction_Next(_ sender: NSMenuItem) {
  865. if let mainVC = self.mainViewController() {
  866. if (mainVC.listView.canGoToNextPage()) {
  867. mainVC.listView.goToNextPage(nil)
  868. }
  869. }
  870. }
  871. @IBAction func menuItemAction_Previous(_ sender: NSMenuItem) {
  872. if let mainVC = self.mainViewController() {
  873. if (mainVC.listView.canGoToPreviousPage()) {
  874. mainVC.listView.goToPreviousPage(nil)
  875. }
  876. }
  877. }
  878. @IBAction func menuItemAction_First(_ sender: NSMenuItem) {
  879. if let mainVC = self.mainViewController() {
  880. mainVC.listView.goToFirstPage(nil)
  881. }
  882. }
  883. @IBAction func menuItemAction_Last(_ sender: NSMenuItem) {
  884. if let mainVC = self.mainViewController() {
  885. mainVC.listView.goToLastPage(nil)
  886. }
  887. }
  888. @IBAction func menuItemAction_GotoPage(_ sender: NSMenuItem) {
  889. if let mainVC = self.mainViewController() {
  890. mainVC.gotoPage(nil)
  891. }
  892. }
  893. @IBAction func menuItemAction_Back(_ sender: NSMenuItem) {
  894. if let mainVC = self.mainViewController() {
  895. if (mainVC.listView.km_canGoBack()) {
  896. mainVC.listView.km_goBack(nil)
  897. }
  898. }
  899. }
  900. @IBAction func menuItemAction_Forward(_ sender: NSMenuItem) {
  901. if let mainVC = self.mainViewController() {
  902. if (mainVC.listView.km_canGoForward()) {
  903. mainVC.listView.km_goForward(nil)
  904. }
  905. }
  906. }
  907. }
  908. // MARK: - Window Menu
  909. extension AppDelegate {
  910. func isWindowMenuActions(sel: Selector?) -> Bool {
  911. guard let selector = sel else {
  912. return false
  913. }
  914. var selectors = [NSSelectorFromString("menuItemAction_showForwardTagPage:"),
  915. NSSelectorFromString("menuItemAction_showNextTagPage:"),
  916. NSSelectorFromString("menuItemAction_mergeAllWindow:")]
  917. if selectors.contains(selector) {
  918. return true
  919. }
  920. return false
  921. }
  922. func validateWindowMenuItem(_ menuItem: NSMenuItem) -> Bool {
  923. let action = menuItem.action
  924. if let browser = self.currentKMBrowser() {
  925. if action == NSSelectorFromString("menuItemAction_showForwardTagPage:") {
  926. menuItem.keyEquivalent = "\t"
  927. menuItem.keyEquivalentModifierMask = [.shift, .control]
  928. return browser.canSelectPreviousTab()
  929. } else if action == NSSelectorFromString("menuItemAction_showNextTagPage:") {
  930. return browser.canSelectNextTab()
  931. }
  932. }
  933. if let browserWC = self.currentBrowserWindowController() {
  934. if action == NSSelectorFromString("menuItemAction_mergeAllWindow:") {
  935. return browserWC.canMergeAllWindow()
  936. }
  937. }
  938. return true
  939. }
  940. //MARK: -IBAction
  941. @IBAction func menuItemAction_showForwardTagPage(_ sender: NSMenuItem) -> Void {
  942. if let browser = self.currentKMBrowser() {
  943. browser.selectPreviousTab()
  944. }
  945. }
  946. @IBAction func menuItemAction_showNextTagPage(_ sender: NSMenuItem) -> Void {
  947. if let browser = self.currentKMBrowser() {
  948. browser.selectNextTab()
  949. }
  950. }
  951. @IBAction func menuItemAction_mergeAllWindow(_ sender: NSMenuItem) -> Void {
  952. if let browserWC = self.currentBrowserWindowController() {
  953. browserWC.mergeAllWindow(sender)
  954. }
  955. }
  956. }
  957. // MARK: - help Menu
  958. extension AppDelegate {
  959. func isHelpMenuActions(sel: Selector?) -> Bool {
  960. guard let selector = sel else {
  961. return false
  962. }
  963. var selectors = [NSSelectorFromString("menuItemAction_APPWebSite:"),
  964. NSSelectorFromString("menuItemAction_quickStudy:"),
  965. NSSelectorFromString("menuItemAction_OnlineHelp:"),
  966. NSSelectorFromString("menuItemAction_Feedback:"),
  967. NSSelectorFromString("menuItemAction_FiveStar:"),
  968. NSSelectorFromString("menuItemAction_SubscribeUs:"),
  969. NSSelectorFromString("menuItemAction_CheckForUpdate:"),
  970. NSSelectorFromString("menuItemAction_VPP:"),
  971. NSSelectorFromString("menuItemAction_FreeTemplate:"),
  972. NSSelectorFromString("menuItemAction_MoreProducts:"),
  973. NSSelectorFromString("menuItemAction_PowerBy:"),
  974. NSSelectorFromString("menuItemAction_privacyPolicy:"),
  975. NSSelectorFromString("menuItemAction_TermsofService:")]
  976. if selectors.contains(selector) {
  977. return true
  978. }
  979. return false
  980. }
  981. func validateHelpMenuItem(_ menuItem: NSMenuItem) -> Bool {
  982. return true
  983. }
  984. //MARK: -IBAction
  985. @IBAction func menuItemAction_APPWebSite(_ sender: NSMenuItem) -> Void {
  986. KMTools.openURL(urlString: APPMain_Link)
  987. }
  988. @IBAction func menuItemAction_quickStudy(_ sender: NSMenuItem) -> Void {
  989. KMTools.openQuickStartStudy()
  990. }
  991. @IBAction func menuItemAction_OnlineHelp(_ sender: NSMenuItem) -> Void {
  992. KMTools.openFAQWebsite()
  993. }
  994. @IBAction func menuItemAction_Feedback(_ sender: NSMenuItem) -> Void {
  995. KMTools.feekback()
  996. }
  997. @IBAction func menuItemAction_FiveStar(_ sender: NSMenuItem) -> Void {
  998. KMTools.rateUs()
  999. }
  1000. @IBAction func menuItemAction_SubscribeUs(_ sender: NSMenuItem) -> Void {
  1001. KMEmailSubWindowController().showWindow(nil)
  1002. }
  1003. @IBAction func menuItemAction_CheckForUpdate(_ sender: NSMenuItem) -> Void {
  1004. #if VERSION_DMG
  1005. SUUpdater.shared().checkForUpdates(sender)
  1006. #endif
  1007. }
  1008. @IBAction func menuItemAction_VPP(_ sender: NSMenuItem) -> Void {
  1009. KMTools.openVPPWebSite()
  1010. }
  1011. @IBAction func menuItemAction_FreeTemplate(_ sender: NSMenuItem) -> Void {
  1012. KMTools.openFreePDFTemplatesWebsite()
  1013. }
  1014. @IBAction func menuItemAction_MoreProducts(_ sender: NSMenuItem) -> Void {
  1015. KMTools.openMoreProductWebsite()
  1016. }
  1017. @IBAction func menuItemAction_PowerBy(_ sender: NSMenuItem) -> Void {
  1018. KMTools.openComPDFKitPowerWebsite()
  1019. }
  1020. @IBAction func menuItemAction_privacyPolicy(_ sender: NSMenuItem) -> Void {
  1021. KMTools.openPrivacyPolicyWebSite()
  1022. }
  1023. @IBAction func menuItemAction_TermsofService(_ sender: NSMenuItem) -> Void {
  1024. KMTools.openTermOfServiceWebSite()
  1025. }
  1026. }