AppDelegate.swift 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. //
  2. // AppDelegate.swift
  3. // PDF Master
  4. //
  5. // Created by Niehaoyu on 2022/9/23.
  6. //
  7. import Cocoa
  8. import KMAdvertisement
  9. @main
  10. class AppDelegate: NSObject, NSApplicationDelegate {
  11. func applicationWillBecomeActive(_ notification: Notification) {
  12. // NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMApplicationWillBecomeActive"), object: nil)
  13. }
  14. func applicationDidBecomeActive(_ notification: Notification) {
  15. }
  16. func applicationWillFinishLaunching(_ notification: Notification) {
  17. let appTarget = KMTools_OC.getAppTarget()
  18. if (appTarget == .free) {
  19. CPDFKit.setLicenseKey("cdq2EJ0yq9HmBQy/AlHPtC/+pnZCKi9HaV8t+N2McjPDNTB0Z8xK+4hw4/xn55GNsnWlNbSB7RTkRMQ45T0IZ4Bhsb2wTjMKZgLHXOYCVs+y/A54hwA/v1fm5F6/mdCjqyFpy2uq7LVxNwsCbVVT+PuHmXDUuWqkErl02537Y3E=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4p9ms/F1zY6gZ1RBu8mNJH8VDCh7HQsi+BJS7RukFVBsD3jYTYlv7OHV9TgoY0SmO6Ptvguf6vCH30IoM4xINMau4aGVjtYuk+Uxs/kosIBwyxQV1SVCQFsC27oMGz5P/rBQYv0T/D0N0z+Um3U+I+tTRwFO+iE6+0emjaIlX2OMDXw8/CDEmc6oakb9zq80YfY7KtZ0LxrqSdyM0ZMT4i8IZqTxD9KkvMj3/O+zX155uoFv1BTjCeXlkEOSDvmglU=")
  20. CPDFConvertKit.setLicenseKey("HcZ7sehqdnIvgtFnAF85D2B6tQjbMAklBEZyrSKYYSY/bdNOfGvcNIKpDTUchwAtZLw1fkJ3uN49bgUVSz8UEHm2LpoXPcRK9b+laQ17UHE7qFx6twVZ2IIyEURhMClmFSDD5yAxxpndYl8mmwjIoWspgAdDGX8pixFDQUE3/9w=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4qccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8GohiEHQBcAOj1ste3ppDvnC1Ca6fL/tThqwHk5EkhX8DeDWXm8oYxIQxh+yoOd+MxU9avJIxe/9rGTVfLJgjbpoOXUTNa/8X/QbDtDTanKkAwWgQy2MrGRWbL6WItb270=")
  21. } else if (appTarget == .DMG) {
  22. CPDFKit.setLicenseKey("anWsjwnFLewcxYRZbdvBVgX9bZ2Ofz9Yy+tje+KJ6BktwciBCx51vZBUDXpFdUrDugu0t4yVSEh+yOhXXRPgiaeCh1dJX+IR7ztnArFoCS8HQDk3ROXjYWkFOmWioOljbNuORZ/zrsv8l0jRNMLUCPxPbga271sOcUVDeHNn/8c=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4rCrm/O2+fI9yUYXNZ/JY1KPbFCeKgG+lEVwrbGHrpAyXATqjrt8ApqRYhafFooQjwAFgayISwZT/pa4NjR459gu4aGVjtYuk+Uxs/kosIBw9vgMz/YdzEMZoMhFEbmUEc6H4o/0cJmYd/bLPc1WFIlJ3VN41JnIqAKG97dQtCXYUplTxrh5mQs6SZcN0B2PF/dEupdk9Zstt+VbVf6kPXvj9NGZMFeJwC3Ilgq78L0gg==")
  23. CPDFConvertKit.setLicenseKey("SVRr1XuTMVrF85Sp+DpK2q/NpcumFDTxBWajzl08eWpk7DomcFajxwMpgfhLCSCNn5jgMumR/diO8X+tZhrBuPs0UP2gYX1lstnpKPqRx8ZnHCTFMyS06zkIrVGTghH+DHNWyXfMFVGQtIVO/+X77wGOtmn5S4/uUHLJDSgLkmw=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4qccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8GohiEHQBcAOj1ste3ppDvnC1Ca6fL/tThqwHk5EkhX8DeDWXm8oYxIQxh+yoOd+MwekFC/LCdvQ96bASGL15ECoOXUTNa/8X/QbDtDTanKkAwWgQy2MrGRWbL6WItb270=")
  24. } else {
  25. CPDFKit.setLicenseKey("cdq2EJ0yq9HmBQy/AlHPtC/+pnZCKi9HaV8t+N2McjPDNTB0Z8xK+4hw4/xn55GNsnWlNbSB7RTkRMQ45T0IZ4Bhsb2wTjMKZgLHXOYCVs+y/A54hwA/v1fm5F6/mdCjqyFpy2uq7LVxNwsCbVVT+PuHmXDUuWqkErl02537Y3E=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4p9ms/F1zY6gZ1RBu8mNJH8VDCh7HQsi+BJS7RukFVBsD3jYTYlv7OHV9TgoY0SmO6Ptvguf6vCH30IoM4xINMau4aGVjtYuk+Uxs/kosIBwyxQV1SVCQFsC27oMGz5P/rBQYv0T/D0N0z+Um3U+I+tTRwFO+iE6+0emjaIlX2OMDXw8/CDEmc6oakb9zq80YfY7KtZ0LxrqSdyM0ZMT4i8IZqTxD9KkvMj3/O+zX155uoFv1BTjCeXlkEOSDvmglU=")
  26. CPDFConvertKit.setLicenseKey("HcZ7sehqdnIvgtFnAF85D2B6tQjbMAklBEZyrSKYYSY/bdNOfGvcNIKpDTUchwAtZLw1fkJ3uN49bgUVSz8UEHm2LpoXPcRK9b+laQ17UHE7qFx6twVZ2IIyEURhMClmFSDD5yAxxpndYl8mmwjIoWspgAdDGX8pixFDQUE3/9w=", secret: "mG0c3O3Mzeu5dkZJW3gpqh188cTuhYlGRPrbR/gfX4qccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8GohiEHQBcAOj1ste3ppDvnC1Ca6fL/tThqwHk5EkhX8DeDWXm8oYxIQxh+yoOd+MxU9avJIxe/9rGTVfLJgjbpoOXUTNa/8X/QbDtDTanKkAwWgQy2MrGRWbL6WItb270=")
  27. }
  28. // CDocumentAIKit.sharedInstance().setLicenseKey("1F8B081800599C640000616C7068610034413635373236463644363535393631364536370001F0010FFE33C3D4634F3E0B148EA10B8E59B57FA6B17EC34749CDBBD02D697F1A481C00666DCDDC517B4F576C4F8A9961080E556DF332DA7C816D3A3C212DCBE34749B6845E561A60C7E13BF8F84EC77FCF314333E1DFFC92E88A6CD97F65F6153452E9677F7A248FD45C98E87647367A29D678DA15EECB5E28854C674FE4DFE810740CB43F4DC1A7444B1EFA3C8C3E3F4D5859A9BAEDF1CF87917E86E6541B924A1AD0FBEC61BDFA0886A1E8FDFECCDE64FCCB645A89323F0177FE0B3CB7E3D72EA9A3DE1823FEB5D967F90751F46B6C97A1C250B669FD145747ADF6571859F78FDA05DA5B963B799DA5CC53ECE0FB8D53165EB3B0188FF8BB201D8AD7A34F01EC1BA855378F2CB8B9176EE463B1F2B1D8BD776113BAEF4C9A78EE7BC12EF192DABD2FBAB2E252A09B38A85BFCD76B4AFBEFF5A4E9FFE499A77B76E97B9C01CC7485688CD696FD1145D47AD969074FD300783583B70460617A0EC2D7579D0EC5AC33DB3F32E0CC920AC25B6D8F177D2F73FF26457534D6233844BEB4B223A37AA59EFB3D2469C8367C0CBF29C8A3E505AA53E62661FFC59771E77C3C274B51E2C066E87C796BA6AC2D2567D25560A7E9DFE3433FC5233A2C0CB4320D57EB8C0422B416CB5E25F94DB1CC0DCE1A39684827B61BCAE552A05607748113F3D6194A29A8C5C400A02FE3C69204D754550FA5E24BC3FF068B99DDF0010000")
  29. ComPDFUIConfig.initializeUIConfig();
  30. KMDesignToken.shared.parserExcel(withPath: "")
  31. }
  32. func applicationDidFinishLaunching(_ aNotification: Notification) {
  33. // Insert code here to initialize your application
  34. #if VERSION_DMG
  35. let updater = SUUpdater.shared()
  36. updater.delegate = true
  37. updater.automaticallyChecksForUpdates = true
  38. #endif
  39. // MARK: 广告数据初始化
  40. KMAdvertisementManager.manager.initConfig(appName: .PDFReaderProMac,
  41. subscribeType: .unsubscribed,
  42. platform: .Mac)
  43. // 测试模式,默认false
  44. KMAdvertisementManager.manager.debug = true
  45. // 初版不支持暗黑模式
  46. NSApp.appearance = NSAppearance(named: .aqua)
  47. //第一次开启app
  48. var info = UserDefaults.standard.value(forKey: "kFirstOpenAppCount")
  49. var count = 0
  50. if info != nil {
  51. count = info as? Int ?? 0
  52. }
  53. count += 1
  54. UserDefaults.standard.set(count, forKey: "kFirstOpenAppCount")
  55. UserDefaults.standard.synchronize()
  56. self.initMainMenu()
  57. /// pro
  58. // [DBClientsManager setupWithAppKeyDesktop:@"amipzwtlg9lrwyl"];
  59. DBClientsManager.setup(withAppKeyDesktop: "jxjlqfm1cfp2mjj")
  60. reopenDocument(forPaths: [])
  61. KMPreferenceManager.shared.author = NSFullUserName()
  62. }
  63. func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  64. }
  65. func application(_ application: NSApplication, didReceiveRemoteNotification userInfo: [String : Any]) {
  66. }
  67. func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
  68. if !flag {
  69. let browser: KMBrowser = KMBrowser.init()
  70. browser.windowController = KMBrowserWindowController.init(browser: browser)
  71. browser.addHomeTabContents()
  72. browser.windowController.showWindow(self)
  73. }
  74. return flag
  75. }
  76. func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
  77. if (KMPreferenceManager.shared.openLastUnclosedDocumentWhenAppStart == false) {
  78. return false
  79. }
  80. let filepaths = KMPreferenceManager.shared.lastOpenFilepaths
  81. if (filepaths == nil || filepaths!.count == 0) {
  82. return false
  83. }
  84. DispatchQueue.main.async {
  85. for filepath in filepaths! {
  86. if filepath.isPDFValid() {
  87. NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: filepath), display: true) { document, result, error in
  88. }
  89. } else {
  90. let alert = NSAlert()
  91. alert.alertStyle = .critical
  92. alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
  93. alert.runModal()
  94. }
  95. }
  96. }
  97. return false
  98. }
  99. func applicationWillTerminate(_ aNotification: Notification) {
  100. if (NSApp.orderedDocuments.count > 0) {
  101. var filepaths: [String] = []
  102. for document in NSApp.orderedDocuments {
  103. // KMPrint(document.fileURL as Any)
  104. if (document.fileURL?.path != nil) {
  105. filepaths.append((document.fileURL?.path)!)
  106. }
  107. }
  108. KMPreferenceManager.shared.lastOpenFilepaths = filepaths
  109. } else {
  110. KMPreferenceManager.shared.lastOpenFilepaths = nil
  111. }
  112. }
  113. func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
  114. return true
  115. }
  116. // MARK: private
  117. func reopenDocument(forPaths paths: [String]) -> Void {
  118. let browser = KMBrowser.init() as KMBrowser
  119. browser.windowController = KMBrowserWindowController.init(browser: browser)
  120. browser.addHomeTabContents()
  121. browser.windowController.showWindow(self)
  122. }
  123. // MARK: Menu
  124. func initMainMenu() {
  125. // 处理菜单栏多语
  126. let mainMenu = NSApp.mainMenu
  127. if (mainMenu == nil) {
  128. return
  129. }
  130. for menu in mainMenu!.items {
  131. let subMenu = menu.submenu
  132. for item in subMenu!.items {
  133. item.title = NSLocalizedString(item.title, comment: "")
  134. let itemSubMenu = item.submenu
  135. if (itemSubMenu == nil) {
  136. continue
  137. }
  138. for item in itemSubMenu!.items {
  139. item.title = NSLocalizedString(item.title, comment: "")
  140. }
  141. }
  142. }
  143. let PDFOfficeMenu = mainMenu?.item(at: 0)?.submenu
  144. let appTarget = KMTools_OC.getAppTarget()
  145. if (appTarget == .DMG) {
  146. PDFOfficeMenu?.insertItem(withTitle: NSLocalizedString("Check for Updates", comment: ""), action: #selector(checkForUpdates), target: self, at: 1)
  147. }
  148. if let items = PDFOfficeMenu?.items {
  149. for menu in items {
  150. let ranges = menu.title.ranges(of: "PDF Master")
  151. let appTarget = KMTools_OC.getAppTarget()
  152. var appName = "PDF Master"
  153. if (appTarget == .pro) {
  154. appName = "PDF Master Pro"
  155. } else if (appTarget == .DMG) {
  156. // appName = "PDF Master DMG"
  157. appName = "PDF Master"
  158. }
  159. if let _range = ranges.range.first {
  160. menu.title.replaceSubrange(_range, with: appName)
  161. }
  162. }
  163. }
  164. let fileMenu = mainMenu?.item(at: 1)?.submenu
  165. let shareItem: NSMenuItem = NSMenuItem(title: NSLocalizedString("Share", comment: ""), action: nil, target: nil)
  166. fileMenu!.insertItem(shareItem, at: (fileMenu?.items.count)!-1)
  167. shareItem.submenu = NSSharingServicePicker.menu(forSharingItems: [""], subjectContext: "", withTarget: self, selector: #selector(sharePageItemAction), serviceDelegate: nil)
  168. let viewMenu = mainMenu?.item(at: 3)?.submenu
  169. var zoomMenu: NSMenu?
  170. for item in viewMenu!.items {
  171. if (item.title == NSLocalizedString("Zoom", comment: "")) {
  172. zoomMenu = item.submenu
  173. break
  174. }
  175. }
  176. if (zoomMenu != nil) {
  177. for item in zoomMenu!.items {
  178. if (item.title == NSLocalizedString("Zoom In", comment: "")) {
  179. item.keyEquivalent = "+"
  180. item.keyEquivalentModifierMask = [.command]
  181. break
  182. }
  183. }
  184. }
  185. }
  186. @objc func sharePageItemAction(sender: NSMenuItem) {
  187. if ((NSApp.mainWindow?.windowController is KMBrowserWindowController) == false) {
  188. return
  189. }
  190. let windowControler = NSApp.mainWindow?.windowController as! KMBrowserWindowController
  191. let model: CTTabStripModel = windowControler.browser.tabStripModel
  192. if (model.count() <= 0) {
  193. return
  194. }
  195. if (model.activeTabContents().isHome) {
  196. return
  197. }
  198. let document: KMMainDocument = model.activeTabContents() as! KMMainDocument
  199. let represent : NSSharingService = sender.representedObject as! NSSharingService
  200. represent.perform(withItems: [document.fileURL as Any])
  201. }
  202. // MARK: PDF Master Menu
  203. @IBAction func openPreferenceWindow(_ sender: Any) {
  204. KMPreferenceWindowController.shared.showWindow(nil)
  205. }
  206. @objc @IBAction func manageAcctounMenuAction(_ sender: Any) {
  207. if KMLightMemberManager.manager.isLogin() {
  208. KMAccountInfoWindowController.show(window: NSApp.mainWindow!)
  209. }
  210. }
  211. @IBAction func loginMenuItemAction(_ sender: Any) {
  212. // Login & Logout
  213. if KMLightMemberManager.manager.isLogin() {
  214. } else {
  215. KMLoginWindowController.show(window: NSApp.mainWindow!)
  216. }
  217. }
  218. @IBAction func logoutMenuItemAction(_ sender: Any) {
  219. // Login & Logout
  220. if KMLightMemberManager.manager.isLogin() {
  221. KMRequestServerManager.manager.logout { success, result in
  222. if success {
  223. print("登出成功")
  224. }
  225. }
  226. }
  227. }
  228. @objc func showAccount() {
  229. }
  230. @objc func resumePurchase() {
  231. }
  232. // MARK: help Menu
  233. @IBAction func menuItemAction_quickStudy(_ sender: NSMenuItem) -> Void {
  234. KMTools.openQuickStartStudy()
  235. }
  236. @IBAction func menuItemAction_onlineHelp(_ sender: NSMenuItem) -> Void {
  237. KMTools.openFAQWebsite()
  238. }
  239. @IBAction func menuItemAction_morePudact(_ sender: NSMenuItem) -> Void {
  240. KMTools.openMoreProductWebsite()
  241. }
  242. @IBAction func menuItemAction_freePDFTemplate(_ sender: NSMenuItem) -> Void {
  243. KMTools.openFreePDFTemplatesWebsite()
  244. }
  245. @IBAction func menuItemAction_payEmail(_ sender: NSMenuItem) -> Void {
  246. KMEmailSubWindowController().showWindow(nil)
  247. }
  248. @IBAction func menuItemAction_poweredByComPDFKit(_ sender: NSMenuItem) -> Void {
  249. KMTools.openComPDFKitPowerWebsite()
  250. }
  251. @IBAction func menuItemAction_feekback(_ sender: NSMenuItem) -> Void {
  252. KMTools.feekback()
  253. }
  254. @IBAction func menuItemAction_giveFiveStar(_ sender: NSMenuItem) -> Void {
  255. }
  256. // MARK:- DMG
  257. @objc func checkForUpdates(_ sender: NSMenuItem) {
  258. let appTarget = KMTools_OC.getAppTarget()
  259. if (appTarget != .DMG) {
  260. return
  261. }
  262. SUUpdater.shared().checkForUpdates(sender)
  263. }
  264. #if VERSION_DMG
  265. func updaterWillRelaunchApplication(_ updater: SUUpdater) {
  266. print("111")
  267. }
  268. func feedURLStringForUpdater(_ updater: SUUpdater) -> String {
  269. #if DEBUG
  270. return "http://test-pdf-pro.kdan.cn:3021/downloads/pdfmasterprocast.xml"
  271. #else
  272. return "https://www.pdfreaderpro.com/downloads/pdfmasterprocast.xml"
  273. #endif
  274. }
  275. func updaterShouldPromptForPermissionToCheckForUpdates(_ updater: SUUpdater) -> Bool {
  276. return false
  277. }
  278. func upgradeAPPWithUpdater(_ updater: SUUpdater) {
  279. let string = "macappstore://apps.apple.com/cn/app/pdf-master-ai-pdf/id6446781258?mt=12"
  280. let url: URL = URL(string: string)
  281. NSWorkspace.shared.open(url)
  282. }
  283. func upgradeButtonStringForUpdater(_ updater: SUUpdater) -> String {
  284. return NSLocalizedString("PDF Master", comment: "")
  285. }
  286. #endif
  287. }
  288. extension AppDelegate : NSMenuDelegate,NSMenuItemValidation {
  289. func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
  290. let action = menuItem.action
  291. if action == #selector(manageAcctounMenuAction) {
  292. self.updateLoginMenuItem()
  293. return KMLightMemberManager.manager.isLogin()
  294. }
  295. if action == #selector(loginMenuItemAction) {
  296. self.updateLoginMenuItem()
  297. return !KMLightMemberManager.manager.isLogin()
  298. }
  299. if action == #selector(logoutMenuItemAction) {
  300. self.updateLoginMenuItem()
  301. return KMLightMemberManager.manager.isLogin()
  302. }
  303. return true
  304. }
  305. func updateLoginMenuItem() {
  306. let firstItem = NSApp.mainMenu?.item(at: 0)?.submenu
  307. if firstItem != nil {
  308. let item1 = firstItem?.item(withTag: 11)
  309. let item2 = firstItem?.item(withTag: 12)
  310. let item3 = firstItem?.item(withTag: 13)
  311. let item4 = firstItem?.item(withTag: 14)
  312. if KMLightMemberManager.manager.isLogin() {
  313. item1?.title = KMLightMemberManager.manager.info.email
  314. item1?.isHidden = false
  315. item2?.isHidden = true
  316. item3?.isHidden = false
  317. item4?.isHidden = false
  318. } else {
  319. item1?.isHidden = true
  320. item2?.isHidden = false
  321. item3?.isHidden = true
  322. item4?.isHidden = true
  323. }
  324. }
  325. }
  326. @objc func clickOutline(menuItem: NSMenuItem) {
  327. print("更新菜单栏")
  328. }
  329. func menuNeedsUpdate(_ menu: NSMenu) {
  330. print("menuNeedsUpdate")
  331. // menu.removeAllItems()
  332. //
  333. // var item = NSMenuItem()
  334. // item = menu.addItem(withTitle: NSLocalizedString("Insert", comment: ""), action: nil, target: self)
  335. // item.representedObject = row
  336. //
  337. // var subMenu = NSMenu()
  338. // var subitem = NSMenuItem()
  339. // subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert File", comment: ""), action: #selector(insertPageItemAction), target: self, tag:0)
  340. // subitem.representedObject = row
  341. // subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert blank page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:1)
  342. // subitem.representedObject = row
  343. // subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:2)
  344. // subitem.representedObject = row
  345. // item.submenu = subMenu
  346. //
  347. // item = menu.addItem(withTitle: NSLocalizedString("Extract", comment: ""), action: #selector(extractPageItemAction), target: self)
  348. // item.representedObject = row
  349. // item = menu.addItem(withTitle: NSLocalizedString("Delete Page", comment: ""), action: #selector(deletePageItemAction), target: self)
  350. // item.representedObject = row
  351. // item = menu.addItem(withTitle: NSLocalizedString("Page Edit", comment: ""), action: #selector(pageEditItemAction), target: self)
  352. // item.representedObject = row
  353. //
  354. // menu.addItem(NSMenuItem.separator())
  355. //
  356. // item = menu.addItem(withTitle: NSLocalizedString("90 Rotate", comment: ""), action: #selector(rotatePageItemAction), target: self)
  357. // item.representedObject = row
  358. // item = menu.addItem(withTitle: NSLocalizedString("-90 Rotate", comment: ""), action: #selector(leftRotatePageItemAction), target: self)
  359. // item.representedObject = row
  360. //
  361. // menu.addItem(NSMenuItem.separator())
  362. //
  363. // item = menu.addItem(withTitle: NSLocalizedString("copy", comment: ""), action: #selector(copyItemAction), target: self)
  364. // item.representedObject = row
  365. // item = menu.addItem(withTitle: NSLocalizedString("cut", comment: ""), action: #selector(cutItemAction), target: self)
  366. // item.representedObject = row
  367. // item = menu.addItem(withTitle: NSLocalizedString("paste", comment: ""), action: #selector(pastePageItemAction), target: self)
  368. //
  369. // menu.addItem(NSMenuItem.separator())
  370. //
  371. // item = menu.addItem(withTitle: NSLocalizedString("print", comment: ""), action: #selector(printItemAction), target: self)
  372. //
  373. // item = menu.addItem(withTitle: NSLocalizedString("Share", comment: ""), action: nil, target: self)
  374. //
  375. // item.submenu = NSSharingServicePicker.menu(forSharingItems: [self.listView.document.documentURL ?? ""], subjectContext: "", withTarget: self, selector: #selector(sharePageItemAction), serviceDelegate: nil)
  376. // }
  377. }
  378. func menu(_ menu: NSMenu, update item: NSMenuItem, at index: Int, shouldCancel: Bool) -> Bool {
  379. return true
  380. }
  381. }