KMBrowserWindowController.swift 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862
  1. //
  2. // KMBrowserWindowController.swift
  3. // PDF Master
  4. //
  5. // Created by wanjun on 2022/12/9.
  6. //
  7. import Cocoa
  8. @objcMembers class KMBrowserWindowController: CTBrowserWindowController {
  9. var rightSegmentControl: KMSegmentedBox?
  10. var modeType: KMHomeToolState = .Home
  11. var filterType: Int = 0
  12. var mainViewController: NSViewController?
  13. var isShowingTokenTimeOutAlert: Bool = false
  14. var currentTimer: Timer?
  15. private(set) var isMultiTabMode: Bool = false
  16. private var homeVC: KMHomeViewController?
  17. override func windowDidLoad() {
  18. super.windowDidLoad()
  19. NSImage.makeTextAlignImages()
  20. window?.backgroundColor = NSColor.km_init(hex: "#DFE1E5")
  21. // window?.setFrameAutosaveName("")
  22. rightTabStripView_.delete = self
  23. homeRightTabStripView_.delete = self
  24. rightTabStripView_.updateView()
  25. fileUploadPanel.delete = self
  26. homeRightTabStripView_.homeRightSearchField.delegate = self
  27. isMultiTabMode = true
  28. addObserverForAppearanceChange()
  29. refreshToolBar(homeToolState: .Home)
  30. NotificationCenter.default.addObserver(self, selector: #selector(closeAllTabs(_:)), name: NSNotification.Name.init(rawValue: "KMTabControllerCloseAllTabs"), object: nil)
  31. NotificationCenter.default.addObserver(self, selector: #selector(openNewWindow(_:)), name: NSNotification.Name.init(rawValue: "KMTabControllerOpenNewWindow"), object: nil)
  32. // if (KMWelcomeWindowController.welcomeHasShow() == false) {
  33. // //AI 版本禁掉首次开启帮助文档
  34. //// KMTools.openQuickStartStudy()
  35. //
  36. // DispatchQueue.main.async {
  37. // let welcome = KMWelcomeWindowController()
  38. // self.km_beginSheet(windowC: welcome)
  39. // welcome.itemClick = { [weak self] idx, param in
  40. // if (idx == 1) { // 关闭
  41. // self?.km_endSheet()
  42. // } else if (idx == 2) { // 以后提醒
  43. // self?.km_endSheet()
  44. // } else if (idx == 3) { // 注册
  45. // self?.km_endSheet()
  46. //
  47. // guard let window_ = self?.window else {
  48. // return
  49. // }
  50. // _ = KMLoginWindowController.show(window: window_, .Batch, .register)
  51. // }
  52. // }
  53. // }
  54. // }
  55. }
  56. @objc func closeAction() {
  57. self.window?.performClose(nil)
  58. }
  59. override func windowShouldClose(_ sender: NSWindow) -> Bool {
  60. if self.browser.tabStripModel.count() > 1 {
  61. self.browser.windowDidBeginToClose()
  62. return false
  63. }
  64. return true
  65. }
  66. override func layoutSubviews() {
  67. super.layoutSubviews()
  68. if let button = (self.window as? CTBrowserWindow)?.standardWindowButton(.closeButton) {
  69. button.frame = NSMakeRect(button.frame.minX, 0, button.frame.width, button.frame.height)
  70. }
  71. if let button = (self.window as? CTBrowserWindow)?.standardWindowButton(.zoomButton) {
  72. button.frame = NSMakeRect(button.frame.minX, 0, button.frame.width, button.frame.height)
  73. }
  74. if let button = (self.window as? CTBrowserWindow)?.standardWindowButton(.miniaturizeButton) {
  75. button.frame = NSMakeRect(button.frame.minX, 0, button.frame.width, button.frame.height)
  76. }
  77. }
  78. // MARK: Dark&Light
  79. func addObserverForAppearanceChange() -> Void {
  80. window?.contentView!.addObserver(self, forKeyPath: "effectiveAppearance", options: .new, context: nil)
  81. }
  82. func removeObserverForAppearanceChange() -> Void {
  83. window?.contentView!.removeObserver(self, forKeyPath: "effectiveAppearance")
  84. }
  85. override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
  86. if keyPath == "effectiveAppearance" {
  87. updateViewColor()
  88. }
  89. }
  90. override func updateViewColor() {
  91. super.updateViewColor()
  92. window?.backgroundColor = KMTabAppearance.tabsViewBackgroundColor()
  93. }
  94. // MARK: Public Methods
  95. func refreshToolBar(homeToolState toolState: KMHomeToolState) -> Void {
  96. modeType = toolState
  97. let document = browser.activeTabContents()
  98. if document != nil {
  99. if document!.isHome {
  100. homeRightTabStripView_.isHidden = modeType == .Home
  101. } else {
  102. self.homeRightStripView.isHidden = true
  103. }
  104. } else {
  105. self.homeRightStripView.isHidden = true
  106. }
  107. homeRightTabStripView_.homeRefreshButton.isEnabled = true
  108. homeRightTabStripView_.homeUploadButton.isEnabled = true
  109. filterType = 0
  110. rightTabStripView_.sortPopUpButton.removeAllItems()
  111. rightTabStripView_.filterPopUpButton.removeAllItems()
  112. rightTabStripView_.updateView()
  113. }
  114. override var hasToolbar: Bool {
  115. get {
  116. return false
  117. }
  118. }
  119. var km_browser: KMBrowser? {
  120. get {
  121. return self.browser as? KMBrowser
  122. }
  123. }
  124. // MARK: Private Methods
  125. func openDocumentWindow() -> Void {
  126. // let panel = NSOpenPanel()
  127. // panel.allowsMultipleSelection = false
  128. // panel.allowedFileTypes = ["pdf"]
  129. // panel.beginSheetModal(for: NSApp.mainWindow!) { response in
  130. // if response == .OK {
  131. // let openPath = panel.url?.path
  132. // let selectDocument = self.selectTabContents(path: openPath!)
  133. // if selectDocument != nil {
  134. // let currentIndex = selectDocument!.browser.tabStripModel.index(of: selectDocument)
  135. // self.browser.tabStripModel.selectTabContents(at: Int32(currentIndex), userGesture: true)
  136. // return
  137. // }
  138. // if !panel.url!.path.isPDFValid() {
  139. // let alert = NSAlert()
  140. // alert.alertStyle = .critical
  141. // alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
  142. // alert.runModal()
  143. // return
  144. // }
  145. // NSDocumentController.shared.openDocument(withContentsOf: panel.url!, display: true) { pdfDocument, documentWasAlreadyOpen, error in
  146. // print("openDocumentWindow")
  147. // }
  148. // }
  149. // }
  150. // MARK TODO: + 号开启
  151. // self.browser.addHomeTabContents()
  152. self.km_browser?.addNewTabContents()
  153. }
  154. // override func openDocument(_ sender: Any!) {
  155. // self.openDocumentWindow()
  156. // }
  157. func selectTabContents(path filePath: String) -> KMMainDocument? {
  158. let document = NSDocumentController.shared.document(for: URL(fileURLWithPath: filePath))
  159. var selectDocument: KMMainDocument?
  160. if document != nil {
  161. if document!.isKind(of: KMMainDocument.self) {
  162. selectDocument = document as! KMMainDocument
  163. }
  164. }
  165. return selectDocument
  166. }
  167. // MARK: Getter
  168. override var rightStripView: NSView! {
  169. get {
  170. return rightTabStripView_
  171. }
  172. }
  173. override var homeRightStripView: NSView! {
  174. get {
  175. return homeRightTabStripView_
  176. }
  177. }
  178. // MARK: Button Action
  179. func commandDispatch(_ sender: Any) -> Void {
  180. openDocumentWindow()
  181. }
  182. func closeAllTabs(_ sender: Any) -> Void {
  183. if self.browser != nil {
  184. self.browser.closeAllTabs()
  185. }
  186. }
  187. func openNewWindow(_ sender: Any) -> Void {
  188. if let noti = sender as? NSNotification, noti.object is CTTabController {
  189. if let window_ = (noti.object as! CTTabController).view.window, window_.isEqual(to: self.window) == false {
  190. return
  191. }
  192. }
  193. if self.browser != nil {
  194. let activeInt = self.browser.activeTabIndex()
  195. let activeTab = self.browser.activeTabContents()
  196. self.browser.closeTab(at: activeInt, makeHistory: false)
  197. let browser: KMBrowser = KMBrowser.init()
  198. browser.windowController = KMBrowserWindowController.init(browser: browser)
  199. browser.addHomeTabContents()
  200. browser.windowController.showWindow(self)
  201. // browser.add(activeTab, inForeground: false)
  202. // browser.selectTab(at: 1)
  203. if activeTab?.fileURL == nil {
  204. return
  205. }
  206. let pdfDoc = CPDFDocument.init(url: (activeTab?.fileURL)!)
  207. let document = NSDocumentController.shared.document(for: (activeTab?.fileURL)!)
  208. KMMainDocument().tryToUnlockDocument(pdfDoc!)
  209. if ((pdfDoc?.isLocked)! == true) {
  210. KMPasswordInputWindow.openWindow(window: self.window!, url: (activeTab?.fileURL)!) { result, password in
  211. if result == .cancel { /// 关闭
  212. return
  213. }
  214. /// 解密成功
  215. var selectDocument: KMMainDocument? = nil
  216. if ((document?.isKind(of: KMMainDocument.self)) != nil) {
  217. selectDocument = (document as! KMMainDocument)
  218. }
  219. if selectDocument != nil {
  220. let currentIndex = selectDocument?.browser.tabStripModel.index(of: selectDocument)
  221. selectDocument?.browser.tabStripModel.selectTabContents(at: Int32(currentIndex!), userGesture: true)
  222. if (selectDocument?.browser.window.isVisible)! as Bool {
  223. selectDocument?.browser.window.orderFront(nil)
  224. } else if (selectDocument?.browser.window.isMiniaturized)! as Bool {
  225. selectDocument?.browser.window.orderFront(nil)
  226. }
  227. } else {
  228. NSDocumentController.shared.km_safe_openDocument(withContentsOf: (activeTab?.fileURL)!, display: true) { document, _, error in
  229. if (error == nil) {
  230. (document as! KMMainDocument).mainViewController?.password = password
  231. }
  232. }
  233. }
  234. }
  235. } else {
  236. var selectDocument: KMMainDocument? = nil
  237. if ((document?.isKind(of: KMMainDocument.self)) != nil) {
  238. selectDocument = (document as! KMMainDocument)
  239. }
  240. if selectDocument != nil {
  241. let currentIndex = selectDocument?.browser.tabStripModel.index(of: selectDocument)
  242. selectDocument?.browser.tabStripModel.selectTabContents(at: Int32(currentIndex!), userGesture: true)
  243. if (selectDocument?.browser.window.isVisible)! as Bool {
  244. selectDocument?.browser.window.orderFront(nil)
  245. } else if (selectDocument?.browser.window.isMiniaturized)! as Bool {
  246. selectDocument?.browser.window.orderFront(nil)
  247. }
  248. } else {
  249. NSDocumentController.shared.km_safe_openDocument(withContentsOf: (activeTab?.fileURL)!, display: true) { _, _, _ in
  250. }
  251. }
  252. }
  253. }
  254. }
  255. func canMergeAllWindow() -> Bool {
  256. return self.fetchBrowserWindowControllers().count > 0
  257. }
  258. fileprivate func fetchBrowserWindowControllers() -> [KMBrowserWindowController] {
  259. var windowArray: [KMBrowserWindowController] = []
  260. for window in NSApp.windows {
  261. guard let windowController = window.windowController, windowController is KMBrowserWindowController else {
  262. continue
  263. }
  264. if let _tabScripC = (windowController as? KMBrowserWindowController)?.tabStripController, _tabScripC.viewsCount() <= 1 {
  265. continue
  266. }
  267. if (window.isVisible && (windowController.isEqual(to: self) == false)) {
  268. windowArray.append(windowController as! KMBrowserWindowController)
  269. }
  270. }
  271. return windowArray
  272. }
  273. func mergeAllWindow(_ sender: Any) {
  274. let windowArray = self.fetchBrowserWindowControllers()
  275. if (windowArray.count <= 0) {
  276. return
  277. }
  278. for windowC in windowArray {
  279. // 拼接窗口 [拼接窗口里的标签,除了home标签]
  280. self.append(windowC, toTabView: NSView())
  281. if let browser = windowC.browser {
  282. if (browser.tabCount() <= 1 && browser.activeTabContents().isHome) {
  283. windowC.close()
  284. }
  285. }
  286. }
  287. }
  288. override func tabDidSelect(_ notification: Notification!) {
  289. super.tabDidSelect(notification)
  290. if let _userInfo = notification.userInfo, let _newContents = _userInfo[CTTabNewContentsUserInfoKey] as? KMMainDocument {
  291. _newContents.addWindowController(self)
  292. }
  293. }
  294. override func layoutTabContentArea(_ frame: NSRect) {
  295. super.layoutTabContentArea(frame)
  296. self.rightStripView.autoresizingMask = [.minXMargin, .minYMargin]
  297. }
  298. override func openDocument(_ sender: Any!) {
  299. guard let _window = self.window else {
  300. return
  301. }
  302. NSOpenPanel.km_open_pdf_multi_success(_window, panel: nil) { urls in
  303. for url in urls {
  304. NSDocumentController.shared.km_safe_openDocument(withContentsOf: url, display: true) { _, _, _ in
  305. }
  306. }
  307. }
  308. }
  309. }
  310. // MARK: - KMToolbarRightViewDelegate
  311. extension KMBrowserWindowController: KMToolbarRightViewDelegate {
  312. func pdfRightSegmentedControlAction(_ sender: KMSegmentedBox?) {
  313. self.trackEvent_upgrade()
  314. KMComparativeTableViewController.show(window: self.window!, .upgrade)
  315. }
  316. func userInfoButtonAction(_ sender: NSButton) {
  317. if KMLightMemberManager.manager.isLogin() {
  318. Task { @MainActor in
  319. if await KMLightMemberManager.manager.canUseAdvanced(needNetworking: true) {
  320. KMAccountInfoWindowController.show(window: self.window!)
  321. } else {
  322. KMLoginWindowController.show(window: self.window!)
  323. }
  324. }
  325. } else {
  326. KMLoginWindowController.show(window: self.window!)
  327. }
  328. }
  329. func homeRefreshButtonAction(_ sender: NSButton?) {
  330. self.layoutSubviews()
  331. }
  332. func homeUploadButtonAction(_ sender: NSButton) {
  333. }
  334. func homeMenuSortAction(_ sender: NSPopUpButton) {
  335. }
  336. func homeMenuFilterAction(_ sender: NSPopUpButton) {
  337. }
  338. }
  339. // MARK: - KMUploadFileDelegate
  340. extension KMBrowserWindowController: KMUploadFileDelegate {
  341. // override func cancelOperation(_ sender: Any?) {
  342. //
  343. // }
  344. }
  345. // MARK: - NSSearchFieldDelegate
  346. extension KMBrowserWindowController: NSSearchFieldDelegate {
  347. func controlTextDidChange(_ obj: Notification) {
  348. }
  349. func controlTextDidEndEditing(_ obj: Notification) {
  350. }
  351. func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
  352. var result = false
  353. return result
  354. }
  355. }
  356. // MARK: -
  357. // MARK: Menu Actions
  358. extension KMBrowserWindowController {
  359. func canResponseDocumentAction() -> Bool {
  360. if (self.browser == nil) {
  361. return false
  362. }
  363. guard let _ = self.browser.activeTabContents() as? KMMainDocument else {
  364. return false
  365. }
  366. return true
  367. }
  368. }
  369. // MARK: -
  370. // MARK: File Menu
  371. extension KMBrowserWindowController: NSMenuDelegate, NSMenuItemValidation {
  372. func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
  373. if (self.browser == nil) {
  374. return false
  375. }
  376. guard let action = menuItem.action else {
  377. return false
  378. }
  379. guard let document = self.browser.activeTabContents() as? KMMainDocument else {
  380. return false
  381. }
  382. if (KMSystemMenu.isFileSelector(sel: action)) {
  383. if (document.isHome) {
  384. if (menuItem.action == KMSystemMenu.File.closeTagPageSelector ||
  385. menuItem.action == KMSystemMenu.File.propertySelector ||
  386. menuItem.action == KMSystemMenu.File.showInFinderSelector ||
  387. menuItem.action == KMSystemMenu.File.printSelector ||
  388. menuItem.action == KMSystemMenu.File.saveAsFlattenedPDFSelector) {
  389. return false
  390. }
  391. return document.homeViewController!.validateMenuItem(menuItem)
  392. } else {
  393. return document.mainViewController!.validateMenuItem(menuItem)
  394. }
  395. }
  396. if (KMSystemMenu.isEditSelector(sel: action)) {
  397. return document.isHome ? false : document.mainViewController!.validateMenuItem(menuItem)
  398. }
  399. if (KMSystemMenu.isViewSelector(sel: action)) {
  400. return document.isHome ? false : document.mainViewController!.validateMenuItem(menuItem)
  401. }
  402. if (KMSystemMenu.isAnnotationSelector(sel: action)) {
  403. return document.isHome ? false : document.mainViewController!.validateMenuItem(menuItem)
  404. }
  405. if (KMSystemMenu.isGotoSelector(sel: action)) {
  406. return document.isHome ? false : document.mainViewController!.validateMenuItem(menuItem)
  407. }
  408. if (KMSystemMenu.isToolSelector(sel: action)) {
  409. return document.isHome ? false : document.mainViewController!.validateMenuItem(menuItem)
  410. }
  411. if (KMSystemMenu.isWindowSelector(sel: action)) {
  412. return document.isHome ? document.homeViewController!.validateMenuItem(menuItem) : document.mainViewController!.validateMenuItem(menuItem)
  413. }
  414. if action == #selector(redactAction) {
  415. return document.isHome ? false : true
  416. }
  417. return true
  418. }
  419. }
  420. extension KMBrowserWindowController {
  421. @IBAction func menuItemAction_openFile(_ sender: Any) {
  422. super.openDocument(sender)
  423. }
  424. @IBAction func importFromFile(_ sender: Any) {
  425. let document: KMMainDocument = self.browser.activeTabContents() as! KMMainDocument
  426. if (document.isHome) {
  427. document.homeViewController?.importFromFile(sender)
  428. } else {
  429. self.homeVC = KMHomeViewController()
  430. self.homeVC?.importFromFile(sender)
  431. }
  432. }
  433. @IBAction func openBlankPage(_ sender: Any) {
  434. let document: KMMainDocument = self.browser.activeTabContents() as! KMMainDocument
  435. if (document.isHome) {
  436. document.homeViewController?.openBlankPage()
  437. } else {
  438. self.homeVC = KMHomeViewController()
  439. self.homeVC?.openBlankPage()
  440. }
  441. }
  442. @IBAction func importFromScanner(_ sender: Any) {
  443. let document: KMMainDocument = self.browser.activeTabContents() as! KMMainDocument
  444. if (document.isHome) {
  445. document.homeViewController?.importFromScanner()
  446. } else {
  447. self.homeVC = KMHomeViewController()
  448. self.homeVC?.importFromScanner()
  449. }
  450. }
  451. @IBAction func menuItemAction_newTab(_ sender: Any) {
  452. self.openDocumentWindow()
  453. }
  454. /// New
  455. @IBAction func newDocumentFromClipboard(_ sender: Any?) {
  456. KMPrint("newDocumentFromClipboard")
  457. }
  458. @IBAction func newDocumentFromImage(_ sender: Any?) {
  459. KMPrint("importFromWebPage")
  460. }
  461. @IBAction func importFromWebPage(_ sender: Any?) {
  462. KMPrint("importFromWebPage")
  463. }
  464. /// screenShot
  465. @IBAction func screenShot_SelectArea(_ sender: Any?) {
  466. KMPrint("screenShot_SelectArea")
  467. }
  468. @IBAction func screenShot_Window(_ sender: Any?) {
  469. KMPrint("screenShot_Window")
  470. }
  471. @IBAction func screenShot_FullScreenDelay(_ sender: Any?) {
  472. KMPrint("screenShot_FullScreenDelay")
  473. }
  474. @IBAction func screenShot_FullScreen(_ sender: Any?) {
  475. KMPrint("screenShot_FullScreen")
  476. }
  477. @IBAction func pasteAsPlainText(_ sender: Any?) {
  478. KMPrint("pasteAsPlainText")
  479. }
  480. @IBAction func deselectAll(_ sender: Any?) {
  481. KMPrint("deselectAll")
  482. }
  483. @IBAction func searchPDF(_ sender: Any?) {
  484. KMPrint("searchPDF")
  485. }
  486. @IBAction func notesLink(_ sender: Any?) {
  487. KMPrint("notesLink")
  488. }
  489. @IBAction func notesStamp(_ sender: Any?) {
  490. KMPrint("notesStamp")
  491. }
  492. @IBAction func selectToolModel(_ sender: Any?) {
  493. KMPrint("selectToolModel")
  494. }
  495. @IBAction func table(_ sender: Any?) {
  496. KMPrint("table ...")
  497. }
  498. @IBAction func image(_ sender: Any?) {
  499. KMPrint("image ...")
  500. }
  501. @IBAction func addForm(_ sender: Any?) {
  502. KMPrint("addForm ...")
  503. }
  504. @IBAction func editNote(_ sender: Any?) {
  505. KMPrint("editNote ...")
  506. }
  507. @IBAction func togglePresentation(_ sender: Any?) {
  508. KMPrint("togglePresentation ...")
  509. }
  510. @IBAction func chooseTransition(_ sender: Any?) {
  511. KMPrint("chooseTransition ...")
  512. }
  513. @IBAction func toggleAutoFlow(_ sender: Any?) {
  514. KMPrint("toggleAutoFlow ...")
  515. }
  516. @IBAction func chooseAutoFlowSetting(_ sender: Any?) {
  517. KMPrint("chooseAutoFlowSetting ...")
  518. }
  519. @IBAction func toggleReadingBar(_ sender: Any?) {
  520. KMPrint("toggleReadingBar ...")
  521. }
  522. @IBAction func toggleLeftSidePane(_ sender: Any?) {
  523. KMPrint("toggleLeftSidePane ...")
  524. }
  525. @IBAction func changeLeftSidePaneState(_ sender: Any?) {
  526. KMPrint("changeLeftSidePaneState ...")
  527. }
  528. @IBAction func splitViewAction(_ sender: Any?) {
  529. KMPrint("splitViewAction ...")
  530. }
  531. @IBAction func themesColor(_ sender: Any?) {
  532. KMPrint("themesColor ...")
  533. }
  534. @IBAction func toggleStatusBar(_ sender: Any?) {
  535. KMPrint("toggleStatusBar ...")
  536. }
  537. @IBAction func toggleToolbarShow(_ sender: Any?) {
  538. KMPrint("toggleToolbarShow ...")
  539. }
  540. @IBAction func changeDisplayMode(_ sender: Any?) {
  541. KMPrint("changeDisplayMode ...")
  542. }
  543. @IBAction func toggleDisplayAsBook(_ sender: Any?) {
  544. KMPrint("toggleDisplayAsBook ...")
  545. }
  546. @IBAction func toggleDisplayPageBreaks(_ sender: Any?) {
  547. KMPrint("toggleDisplayPageBreaks ...")
  548. }
  549. @IBAction func changeDisplayBox(_ sender: Any?) {
  550. KMPrint("changeDisplayBox ...")
  551. }
  552. @IBAction func changeColor(_ sender: Any?) {
  553. KMPrint("changeColor ...")
  554. }
  555. @IBAction func changeFont(_ sender: Any?) {
  556. KMPrint("changeFont ...")
  557. }
  558. @IBAction func changeAttributes(_ sender: Any?) {
  559. KMPrint("changeAttributes ...")
  560. }
  561. @IBAction func alignLeft(_ sender: Any?) {
  562. KMPrint("alignLeft ...")
  563. }
  564. @IBAction func alignRight(_ sender: Any?) {
  565. KMPrint("alignRight ...")
  566. }
  567. @IBAction func alignCenter(_ sender: Any?) {
  568. KMPrint("alignCenter ...")
  569. }
  570. @IBAction func createNewNote(_ sender: Any?) {
  571. KMPrint("createNewNote ...")
  572. }
  573. @IBAction func toggleHideNotes(_ sender: Any?) {
  574. KMPrint("toggleHideNotes ...")
  575. }
  576. @IBAction func takeSnapshot(_ sender: Any?) {
  577. KMPrint("takeSnapshot ...")
  578. }
  579. @IBAction func takeSnapshotSelectContent(_ sender: Any?) {
  580. KMPrint("takeSnapshotSelectContent ...")
  581. }
  582. @IBAction func changeDisplaySinglePages(_ sender: Any?) {
  583. KMPrint("changeDisplaySinglePages ...")
  584. }
  585. @IBAction func changeDisplayContinuous(_ sender: Any?) {
  586. KMPrint("changeDisplayContinuous ...")
  587. }
  588. @IBAction func doGoToNextPage(_ sender: Any?) {
  589. KMPrint("doGoToNextPage ...")
  590. }
  591. @IBAction func doGoToPreviousPage(_ sender: Any?) {
  592. KMPrint("doGoToPreviousPage ...")
  593. }
  594. @IBAction func doGoToFirstPage(_ sender: Any?) {
  595. KMPrint("doGoToFirstPage ...")
  596. }
  597. @IBAction func doGoToLastPage(_ sender: Any?) {
  598. KMPrint("doGoToLastPage ...")
  599. }
  600. @IBAction func allGoToNextPage(_ sender: Any?) {
  601. KMPrint("allGoToNextPage ...")
  602. }
  603. @IBAction func allGoToPreviousPage(_ sender: Any?) {
  604. KMPrint("allGoToPreviousPage ...")
  605. }
  606. @IBAction func allGoToFirstPage(_ sender: Any?) {
  607. KMPrint("allGoToFirstPage ...")
  608. }
  609. @IBAction func allGoToLastPage(_ sender: Any?) {
  610. KMPrint("allGoToLastPage ...")
  611. }
  612. @IBAction func doGoToPage(_ sender: Any?) {
  613. KMPrint("doGoToPage ...")
  614. }
  615. @IBAction func doGoBack(_ sender: Any?) {
  616. KMPrint("doGoBack ...")
  617. }
  618. @IBAction func doGoForward(_ sender: Any?) {
  619. KMPrint("doGoForward ...")
  620. }
  621. @IBAction func goToMarkedPage(_ sender: Any?) {
  622. KMPrint("goToMarkedPage ...")
  623. }
  624. @IBAction func markPage(_ sender: Any?) {
  625. KMPrint("markPage ...")
  626. }
  627. @IBAction func doZoomIn(_ sender: Any?) {
  628. KMPrint("doZoomIn ...")
  629. }
  630. @IBAction func doZoomOut(_ sender: Any?) {
  631. KMPrint("doZoomOut ...")
  632. }
  633. @IBAction func doZoomToActualSize(_ sender: Any?) {
  634. KMPrint("doZoomToActualSize ...")
  635. }
  636. @IBAction func doZoomToPhysicalSize(_ sender: Any?) {
  637. KMPrint("doZoomToPhysicalSize ...")
  638. }
  639. @IBAction func doZoomToFit(_ sender: Any?) {
  640. KMPrint("doZoomToFit ...")
  641. }
  642. @IBAction func alternateZoomToFit(_ sender: Any?) {
  643. KMPrint("alternateZoomToFit ...")
  644. }
  645. @IBAction func doZoomToSelection(_ sender: Any?) {
  646. KMPrint("doZoomToSelection ...")
  647. }
  648. @IBAction func doMarqueeZoomTool(_ sender: Any?) {
  649. KMPrint("doMarqueeZoomTool ...")
  650. }
  651. @IBAction func doAutoScale(_ sender: Any?) {
  652. KMPrint("doAutoScale ...")
  653. }
  654. @IBAction func toggleAutoScale(_ sender: Any?) {
  655. KMPrint("toggleAutoScale ...")
  656. }
  657. @IBAction func rotateRight(_ sender: Any?) {
  658. KMPrint("rotateRight ...")
  659. }
  660. @IBAction func rotateLeft(_ sender: Any?) {
  661. KMPrint("rotateLeft ...")
  662. }
  663. @IBAction func rotateAllRight(_ sender: Any?) {
  664. KMPrint("rotateAllRight ...")
  665. }
  666. @IBAction func rotateAllLeft(_ sender: Any?) {
  667. KMPrint("rotateAllLeft ...")
  668. }
  669. @IBAction func crop(_ sender: Any?) {
  670. KMPrint("crop ...")
  671. }
  672. @IBAction func cropAll(_ sender: Any?) {
  673. KMPrint("cropAll ...")
  674. }
  675. @IBAction func autoCropAll(_ sender: Any?) {
  676. KMPrint("autoCropAll ...")
  677. }
  678. @IBAction func smartAutoCropAll(_ sender: Any?) {
  679. KMPrint("smartAutoCropAll ...")
  680. }
  681. @IBAction func cropOptionsModel(_ sender: Any?) {
  682. KMPrint("cropOptionsModel ...")
  683. }
  684. @IBAction func autoSelectContent(_ sender: Any?) {
  685. KMPrint("autoSelectContent ...")
  686. }
  687. @IBAction func getInfo(_ sender: Any?) {
  688. KMPrint("getInfo ...")
  689. }
  690. // @IBAction func delete(_ sender: Any?) {
  691. // KMPrint("delete ...")
  692. // }
  693. // @IBAction func paste(_ sender: Any?) {
  694. // KMPrint("paste ...")
  695. // }
  696. @IBAction func alternatePaste(_ sender: Any?) {
  697. KMPrint("alternatePaste ...")
  698. }
  699. @IBAction func copy(_ sender: Any?) {
  700. KMPrint("copy ...")
  701. }
  702. @IBAction func cut(_ sender: Any?) {
  703. KMPrint("cut ...")
  704. }
  705. @IBAction func changeToolMode(_ sender: Any?) {
  706. KMPrint("changeToolMode ...")
  707. }
  708. @IBAction func changeAnnotationMode(_ sender: Any?) {
  709. KMPrint("changeAnnotationMode ...")
  710. }
  711. @IBAction func toggleFullscreen(_ sender: Any?) {
  712. KMPrint("toggleFullscreen ...")
  713. }
  714. @IBAction func toggleRightSidePane(_ sender: Any?) {
  715. KMPrint("toggleRightSidePane ...")
  716. }
  717. @IBAction func performFit(_ sender: Any?) {
  718. KMPrint("performFit ...")
  719. }
  720. @IBAction func changeRightSidePaneState(_ sender: Any?) {
  721. KMPrint("changeRightSidePaneState ...")
  722. }
  723. @IBAction func changeFindPaneState(_ sender: Any?) {
  724. KMPrint("changeFindPaneState ...")
  725. }
  726. @IBAction func toggleSplitPDF(_ sender: Any?) {
  727. KMPrint("toggleSplitPDF ...")
  728. }
  729. @IBAction func search(_ sender: Any?) {
  730. KMPrint("search ...")
  731. }
  732. @IBAction func searchNotes(_ sender: Any?) {
  733. KMPrint("searchNotes ...")
  734. }
  735. @IBAction func password(_ sender: Any?) {
  736. KMPrint("password ...")
  737. }
  738. @IBAction func savePDFSettingToDefaults(_ sender: Any?) {
  739. KMPrint("savePDFSettingToDefaults ...")
  740. }
  741. @IBAction func toggleCaseInsensitiveSearch(_ sender: Any?) {
  742. KMPrint("toggleCaseInsensitiveSearch ...")
  743. }
  744. @IBAction func toggleWholeWordSearch(_ sender: Any?) {
  745. KMPrint("toggleWholeWordSearch ...")
  746. }
  747. @IBAction func toggleCaseInsensitiveNoteSearch(_ sender: Any?) {
  748. KMPrint("toggleCaseInsensitiveNoteSearch ...")
  749. }
  750. @IBAction func performFindPanelAction(_ sender: Any?) {
  751. KMPrint("performFindPanelAction ...")
  752. }
  753. @IBAction func scrollUp(_ sender: Any?) {
  754. KMPrint("scrollUp ...")
  755. }
  756. @IBAction func scrollDown(_ sender: Any?) {
  757. KMPrint("scrollDown ...")
  758. }
  759. @IBAction func scrollRight(_ sender: Any?) {
  760. KMPrint("scrollRight ...")
  761. }
  762. @IBAction func scrollLeft(_ sender: Any?) {
  763. KMPrint("scrollLeft ...")
  764. }
  765. @IBAction func selectSelectedNote(_ sender: Any?) {
  766. KMPrint("selectSelectedNote ...")
  767. }
  768. @IBAction func goToSelectedOutlineItem(_ sender: Any?) {
  769. KMPrint("goToSelectedOutlineItem ...")
  770. }
  771. @IBAction func goToSelectedFindResults(_ sender: Any?) {
  772. KMPrint("goToSelectedFindResults ...")
  773. }
  774. @IBAction func toggleSelectedSnapshots(_ sender: Any?) {
  775. KMPrint("toggleSelectedSnapshots ...")
  776. }
  777. @IBAction func selfSignProfile(_ sender: Any?) {
  778. KMPrint("selfSignProfile ...")
  779. }
  780. @IBAction func highlightFormFiled(_ sender: Any?) {
  781. KMPrint("highlightFormFiled ...")
  782. }
  783. @IBAction func highlightLinks(_ sender: Any?) {
  784. KMPrint("highlightLinks ...")
  785. }
  786. @IBAction func resetForm(_ sender: Any?) {
  787. KMPrint("resetForm ...")
  788. }
  789. @IBAction func removeAllAnnotation(_ sender: Any?) {
  790. KMPrint("removeAllAnnotation ...")
  791. }
  792. @IBAction func link(_ sender: Any?) {
  793. KMPrint("link ...")
  794. }
  795. @IBAction func addWatermark(_ sender: Any?) {
  796. KMPrint("addWatermark ...")
  797. }
  798. @IBAction func convert(_ sender: Any?) {
  799. KMPrint("convert ...")
  800. }
  801. @IBAction func imageToPDF(_ sender: Any?) {
  802. KMPrint("imageToPDF ...")
  803. }
  804. @IBAction func pageEdit(_ sender: Any?) {
  805. KMPrint("pageEdit ...")
  806. }
  807. @IBAction func ocr(_ sender: Any?) {
  808. KMPrint("ocr ...")
  809. }
  810. @IBAction func insertPage(_ sender: Any?) {
  811. KMPrint("insertPage ...")
  812. }
  813. @IBAction func merge(_ sender: Any?) {
  814. KMPrint("merge ...")
  815. }
  816. @IBAction func split(_ sender: Any?) {
  817. KMPrint("split ...")
  818. }
  819. @IBAction func compression(_ sender: Any?) {
  820. KMPrint("compression ...")
  821. }
  822. @IBAction func comparison(_ sender: Any?) {
  823. KMPrint("comparison ...")
  824. }
  825. @IBAction func contentComparison(_ sender: Any?) {
  826. KMPrint("contentComparison ...")
  827. }
  828. @IBAction func coverageComparison(_ sender: Any?) {
  829. KMPrint("coverageComparison ...")
  830. }
  831. @IBAction func extractImage(_ sender: Any?) {
  832. KMPrint("extractImage ...")
  833. }
  834. @IBAction func security(_ sender: Any?) {
  835. KMPrint("security ...")
  836. }
  837. @IBAction func addBackground(_ sender: Any?) {
  838. KMPrint("addBackground ...")
  839. }
  840. @IBAction func removeBackground(_ sender: Any?) {
  841. KMPrint("removeBackground ...")
  842. }
  843. @IBAction func addHeaderFooter(_ sender: Any?) {
  844. KMPrint("addHeaderFooter ...")
  845. }
  846. @IBAction func removeHeaderFooter(_ sender: Any?) {
  847. KMPrint("removeHeaderFooter ...")
  848. }
  849. @IBAction func addHeaderFooterBates(_ sender: Any?) {
  850. KMPrint("addHeaderFooterBates ...")
  851. }
  852. @IBAction func removeHeaderFooterBates(_ sender: Any?) {
  853. KMPrint("removeHeaderFooterBates ...")
  854. }
  855. @IBAction func editWatermark(_ sender: Any?) {
  856. KMPrint("editWatermark ...")
  857. }
  858. @IBAction func batchAddWatermark(_ sender: Any?) {
  859. KMPrint("batchAddWatermark ...")
  860. }
  861. @IBAction func batchRemoveWatermark(_ sender: Any?) {
  862. KMPrint("batchRemoveWatermark ...")
  863. }
  864. @IBAction func removeWatermark(_ sender: Any?) {
  865. KMPrint("removeWatermark ...")
  866. }
  867. @IBAction func templateWatermark(_ sender: Any?) {
  868. KMPrint("templateWatermark ...")
  869. }
  870. @IBAction func batchAddBackground(_ sender: Any?) {
  871. KMPrint("batchAddBackground ...")
  872. }
  873. @IBAction func batchRemoveBackground(_ sender: Any?) {
  874. KMPrint("batchRemoveBackground ...")
  875. }
  876. @IBAction func templateBackground(_ sender: Any?) {
  877. KMPrint("templateBackground ...")
  878. }
  879. @IBAction func batchAddHeaderFooter(_ sender: Any?) {
  880. KMPrint("batchAddHeaderFooter ...")
  881. }
  882. @IBAction func batchRemoveHeaderFooter(_ sender: Any?) {
  883. KMPrint("batchRemoveHeaderFooter ...")
  884. }
  885. @IBAction func templateHeaderFooter(_ sender: Any?) {
  886. KMPrint("templateHeaderFooter ...")
  887. }
  888. @IBAction func batchAddBates(_ sender: Any?) {
  889. KMPrint("batchAddBates ...")
  890. }
  891. @IBAction func batchRemoveBates(_ sender: Any?) {
  892. KMPrint("batchRemoveBates ...")
  893. }
  894. @IBAction func templateBates(_ sender: Any?) {
  895. KMPrint("templateBates ...")
  896. }
  897. @IBAction func togglePoster(_ sender: Any?) {
  898. KMPrint("togglePoster ...")
  899. }
  900. @IBAction func toggleMultiple(_ sender: Any?) {
  901. KMPrint("toggleMultiple ...")
  902. }
  903. @IBAction func toggleBooklet(_ sender: Any?) {
  904. KMPrint("toggleBooklet ...")
  905. }
  906. @IBAction func decryption(_ sender: Any?) {
  907. KMPrint("decryption ...")
  908. }
  909. @IBAction func readMode(_ sender: Any?) {
  910. KMPrint("readMode ...")
  911. }
  912. @IBAction func changeFormType(_ sender: Any?) {
  913. KMPrint("changeFormType ...")
  914. }
  915. @IBAction func changeSelfSignType(_ sender: Any?) {
  916. KMPrint("changeSelfSignType ...")
  917. }
  918. @IBAction func clearAllForm(_ sender: Any?) {
  919. KMPrint("clearAllForm ...")
  920. }
  921. @IBAction func thumbnailSizeScaling(_ sender: Any?) {
  922. KMPrint("thumbnailSizeScaling ...")
  923. }
  924. @IBAction func textEditAction(_ sender: Any?) {
  925. KMPrint("textEditAction ...")
  926. }
  927. @IBAction func redactAction(_ sender: Any?) {
  928. if (self.canResponseDocumentAction() == false) {
  929. return
  930. }
  931. if let document = self.browser.activeTabContents() as? KMMainDocument {
  932. if document.isHome == false {
  933. document.mainViewController?.menuItemAction_redact(sender)
  934. }
  935. }
  936. }
  937. }
  938. // MARK: - KMSystemFileMenuProtocol
  939. extension KMBrowserWindowController: KMSystemFileMenuProtocol {
  940. func menuItemClick_saveAsFlattenedPDF(_ sender: Any) {
  941. if (self.canResponseDocumentAction() == false) {
  942. return
  943. }
  944. if let document = self.browser.activeTabContents() as? KMMainDocument {
  945. if (document.isHome) {
  946. // document.homeViewController?.menuItemClick_mergePDF(sender)
  947. } else {
  948. document.mainViewController?.menuItemClick_saveAsFlattenedPDF(sender)
  949. }
  950. }
  951. }
  952. func menuItemClick_mergePDF(_ sender: Any) {
  953. if (self.canResponseDocumentAction() == false) {
  954. return
  955. }
  956. if let document = self.browser.activeTabContents() as? KMMainDocument {
  957. if (document.isHome) {
  958. document.homeViewController?.menuItemClick_mergePDF(sender)
  959. } else {
  960. document.mainViewController?.menuItemClick_mergePDF(sender)
  961. }
  962. }
  963. }
  964. func menuItemClick_Compress(_ sender: Any) {
  965. if (self.canResponseDocumentAction() == false) {
  966. return
  967. }
  968. if let document = self.browser.activeTabContents() as? KMMainDocument {
  969. if (document.isHome) {
  970. document.homeViewController?.menuItemClick_Compress(sender)
  971. } else {
  972. document.mainViewController?.menuItemClick_Compress(sender)
  973. }
  974. }
  975. }
  976. func menuItemAction_ConvertToWord(_ sender: Any) {
  977. if (self.canResponseDocumentAction() == false) {
  978. return
  979. }
  980. if let document = self.browser.activeTabContents() as? KMMainDocument {
  981. if (document.isHome) {
  982. document.homeViewController?.menuItemAction_ConvertToWord(sender)
  983. } else {
  984. document.mainViewController?.menuItemAction_ConvertToWord(sender)
  985. }
  986. }
  987. }
  988. func menuItemAction_ConvertToExcel(_ sender: Any) {
  989. if (self.canResponseDocumentAction() == false) {
  990. return
  991. }
  992. if let document = self.browser.activeTabContents() as? KMMainDocument {
  993. if (document.isHome) {
  994. document.homeViewController?.menuItemAction_ConvertToExcel(sender)
  995. } else {
  996. document.mainViewController?.menuItemAction_ConvertToExcel(sender)
  997. }
  998. }
  999. }
  1000. func menuItemAction_ConvertToPPT(_ sender: Any) {
  1001. if (self.canResponseDocumentAction() == false) {
  1002. return
  1003. }
  1004. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1005. if (document.isHome) {
  1006. document.homeViewController?.menuItemAction_ConvertToPPT(sender)
  1007. } else {
  1008. document.mainViewController?.menuItemAction_ConvertToPPT(sender)
  1009. }
  1010. }
  1011. }
  1012. func menuItemAction_ConvertToRTF(_ sender: Any) {
  1013. if (self.canResponseDocumentAction() == false) {
  1014. return
  1015. }
  1016. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1017. if (document.isHome) {
  1018. document.homeViewController?.menuItemAction_ConvertToRTF(sender)
  1019. } else {
  1020. document.mainViewController?.menuItemAction_ConvertToRTF(sender)
  1021. }
  1022. }
  1023. }
  1024. func menuItemAction_ConvertToHTML(_ sender: Any) {
  1025. if (self.canResponseDocumentAction() == false) {
  1026. return
  1027. }
  1028. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1029. if (document.isHome) {
  1030. document.homeViewController?.menuItemAction_ConvertToHTML(sender)
  1031. } else {
  1032. document.mainViewController?.menuItemAction_ConvertToHTML(sender)
  1033. }
  1034. }
  1035. }
  1036. func menuItemAction_ConvertToText(_ sender: Any) {
  1037. if (self.canResponseDocumentAction() == false) {
  1038. return
  1039. }
  1040. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1041. if (document.isHome) {
  1042. document.homeViewController?.menuItemAction_ConvertToText(sender)
  1043. } else {
  1044. document.mainViewController?.menuItemAction_ConvertToText(sender)
  1045. }
  1046. }
  1047. }
  1048. func menuItemAction_ConvertToCSV(_ sender: Any) {
  1049. if (self.canResponseDocumentAction() == false) {
  1050. return
  1051. }
  1052. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1053. if (document.isHome) {
  1054. document.homeViewController?.menuItemAction_ConvertToCSV(sender)
  1055. } else {
  1056. document.mainViewController?.menuItemAction_ConvertToCSV(sender)
  1057. }
  1058. }
  1059. }
  1060. func menuItemAction_ConvertToImage(_ sender: Any) {
  1061. if (self.canResponseDocumentAction() == false) {
  1062. return
  1063. }
  1064. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1065. if (document.isHome) {
  1066. document.homeViewController?.menuItemAction_ConvertToImage(sender)
  1067. } else {
  1068. document.mainViewController?.menuItemAction_ConvertToImage(sender)
  1069. }
  1070. }
  1071. }
  1072. func menuItemClick_SettingPassword(_ sender: Any) {
  1073. if (self.canResponseDocumentAction() == false) {
  1074. return
  1075. }
  1076. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1077. if (document.isHome) {
  1078. document.homeViewController?.menuItemClick_SettingPassword(sender)
  1079. } else {
  1080. document.mainViewController?.menuItemClick_SettingPassword(sender)
  1081. }
  1082. }
  1083. }
  1084. func menuItemClick_RemovePassword(_ sender: Any) {
  1085. if (self.canResponseDocumentAction() == false) {
  1086. return
  1087. }
  1088. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1089. document.mainViewController?.menuItemClick_RemovePassword(sender)
  1090. }
  1091. }
  1092. func menuItemAction_closeWindow(_ sender: Any) {
  1093. if (self.canResponseDocumentAction() == false) {
  1094. return
  1095. }
  1096. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1097. if (document.isHome) {
  1098. document.homeViewController?.menuItemAction_closeWindow(sender)
  1099. } else {
  1100. document.mainViewController?.menuItemAction_closeWindow(sender)
  1101. }
  1102. }
  1103. }
  1104. func menuItemAction_closeAllWindows(_ sender: Any) {
  1105. if (self.canResponseDocumentAction() == false) {
  1106. return
  1107. }
  1108. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1109. if (document.isHome) {
  1110. document.homeViewController?.menuItemAction_closeAllWindows(sender)
  1111. } else {
  1112. document.mainViewController?.menuItemAction_closeAllWindows(sender)
  1113. }
  1114. }
  1115. }
  1116. func menuItemAction_closeTagPage(_ sender: Any) {
  1117. if (self.canResponseDocumentAction() == false) {
  1118. return
  1119. }
  1120. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1121. document.mainViewController?.menuItemAction_closeTagPage(sender)
  1122. }
  1123. }
  1124. func menuItemAction_showInFinder(_ sender: Any) {
  1125. if (self.canResponseDocumentAction() == false) {
  1126. return
  1127. }
  1128. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1129. document.mainViewController?.menuItemAction_showInFinder(sender)
  1130. }
  1131. }
  1132. func menuItemAction_property(_ sender: Any) {
  1133. if (self.canResponseDocumentAction() == false) {
  1134. return
  1135. }
  1136. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1137. document.mainViewController?.menuItemAction_property(sender)
  1138. }
  1139. }
  1140. func menuItemAction_print(_ sender: Any) {
  1141. if (self.canResponseDocumentAction() == false) {
  1142. return
  1143. }
  1144. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1145. document.mainViewController?.menuItemAction_print(sender)
  1146. }
  1147. }
  1148. }
  1149. // MARK: - KMSystemViewMenuProtocol
  1150. extension KMBrowserWindowController: KMSystemViewMenuProtocol {
  1151. func menuItemAction_adjustWidth(_ sender: Any) {
  1152. if (self.canResponseDocumentAction() == false) {
  1153. return
  1154. }
  1155. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1156. document.mainViewController?.menuItemAction_adjustWidth(sender)
  1157. }
  1158. }
  1159. func menuItemAction_adjustPage(_ sender: Any) {
  1160. if (self.canResponseDocumentAction() == false) {
  1161. return
  1162. }
  1163. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1164. document.mainViewController?.menuItemAction_adjustPage(sender)
  1165. }
  1166. }
  1167. func menuItemAction_size(_ sender: Any) {
  1168. if (self.canResponseDocumentAction() == false) {
  1169. return
  1170. }
  1171. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1172. document.mainViewController?.menuItemAction_size(sender)
  1173. }
  1174. }
  1175. func menuItemAction_zoomOut(_ sender: Any) {
  1176. if (self.canResponseDocumentAction() == false) {
  1177. return
  1178. }
  1179. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1180. document.mainViewController?.menuItemAction_zoomOut(sender)
  1181. }
  1182. }
  1183. func menuItemAction_zoomIn(_ sender: Any) {
  1184. if (self.canResponseDocumentAction() == false) {
  1185. return
  1186. }
  1187. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1188. document.mainViewController?.menuItemAction_zoomIn(sender)
  1189. }
  1190. }
  1191. func menuItemAction_singlePage(_ sender: Any) {
  1192. if (self.canResponseDocumentAction() == false) {
  1193. return
  1194. }
  1195. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1196. document.mainViewController?.menuItemAction_singlePage(sender)
  1197. }
  1198. }
  1199. func menuItemAction_singlePageContinue(_ sender: Any) {
  1200. if (self.canResponseDocumentAction() == false) {
  1201. return
  1202. }
  1203. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1204. document.mainViewController?.menuItemAction_singlePageContinue(sender)
  1205. }
  1206. }
  1207. func menuItemAction_doublePage(_ sender: Any) {
  1208. if (self.canResponseDocumentAction() == false) {
  1209. return
  1210. }
  1211. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1212. document.mainViewController?.menuItemAction_doublePage(sender)
  1213. }
  1214. }
  1215. func menuItemAction_doublePageContinue(_ sender: Any) {
  1216. if (self.canResponseDocumentAction() == false) {
  1217. return
  1218. }
  1219. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1220. document.mainViewController?.menuItemAction_doublePageContinue(sender)
  1221. }
  1222. }
  1223. func menuItemAction_bookMode(_ sender: Any) {
  1224. if (self.canResponseDocumentAction() == false) {
  1225. return
  1226. }
  1227. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1228. document.mainViewController?.menuItemAction_bookMode(sender)
  1229. }
  1230. }
  1231. func menuItemAction_readMode(_ sender: Any) {
  1232. if (self.canResponseDocumentAction() == false) {
  1233. return
  1234. }
  1235. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1236. document.mainViewController?.menuItemAction_readMode(sender)
  1237. }
  1238. }
  1239. func menuItemAction_showSplitPage(_ sender: Any) {
  1240. if (self.canResponseDocumentAction() == false) {
  1241. return
  1242. }
  1243. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1244. document.mainViewController?.menuItemAction_showSplitPage(sender)
  1245. }
  1246. }
  1247. func menuItemAction_rotateLeft(_ sender: Any) {
  1248. if (self.canResponseDocumentAction() == false) {
  1249. return
  1250. }
  1251. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1252. document.mainViewController?.menuItemAction_rotateLeft(sender)
  1253. }
  1254. }
  1255. func menuItemAction_rotateRight(_ sender: Any) {
  1256. if (self.canResponseDocumentAction() == false) {
  1257. return
  1258. }
  1259. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1260. document.mainViewController?.menuItemAction_rotateRight(sender)
  1261. }
  1262. }
  1263. func menuItemAction_rotateAllPageLeft(_ sender: Any) {
  1264. if (self.canResponseDocumentAction() == false) {
  1265. return
  1266. }
  1267. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1268. document.mainViewController?.menuItemAction_rotateAllPageLeft(sender)
  1269. }
  1270. }
  1271. func menuItemAction_rotateAllPageRight(_ sender: Any) {
  1272. if (self.canResponseDocumentAction() == false) {
  1273. return
  1274. }
  1275. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1276. document.mainViewController?.menuItemAction_rotateAllPageRight(sender)
  1277. }
  1278. }
  1279. func menuItemAction_view_readMode(_ sender: Any) {
  1280. if (self.canResponseDocumentAction() == false) {
  1281. return
  1282. }
  1283. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1284. document.mainViewController?.menuItemAction_view_readMode(sender)
  1285. }
  1286. }
  1287. func menuItemAction_hiddenLeftSide(_ sender: Any) {
  1288. if (self.canResponseDocumentAction() == false) {
  1289. return
  1290. }
  1291. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1292. document.mainViewController?.menuItemAction_hiddenLeftSide(sender)
  1293. }
  1294. }
  1295. func menuItemAction_hiddenRightSide(_ sender: Any) {
  1296. if (self.canResponseDocumentAction() == false) {
  1297. return
  1298. }
  1299. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1300. document.mainViewController?.menuItemAction_hiddenRightSide(sender)
  1301. }
  1302. }
  1303. func menuItemAction_thumai(_ sender: Any) {
  1304. if (self.canResponseDocumentAction() == false) {
  1305. return
  1306. }
  1307. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1308. document.mainViewController?.menuItemAction_thumai(sender)
  1309. }
  1310. }
  1311. func menuItemAction_outline(_ sender: Any) {
  1312. if (self.canResponseDocumentAction() == false) {
  1313. return
  1314. }
  1315. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1316. document.mainViewController?.menuItemAction_outline(sender)
  1317. }
  1318. }
  1319. func menuItemAction_bookmark(_ sender: Any) {
  1320. if (self.canResponseDocumentAction() == false) {
  1321. return
  1322. }
  1323. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1324. document.mainViewController?.menuItemAction_bookmark(sender)
  1325. }
  1326. }
  1327. func menuItemAction_annotation(_ sender: Any) {
  1328. if (self.canResponseDocumentAction() == false) {
  1329. return
  1330. }
  1331. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1332. document.mainViewController?.menuItemAction_annotation(sender)
  1333. }
  1334. }
  1335. func menuItemAction_search(_ sender: Any) {
  1336. if (self.canResponseDocumentAction() == false) {
  1337. return
  1338. }
  1339. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1340. document.mainViewController?.menuItemAction_search(sender)
  1341. }
  1342. }
  1343. func menuItemAction_hiddenPageIndicator(_ sender: Any) {
  1344. if (self.canResponseDocumentAction() == false) {
  1345. return
  1346. }
  1347. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1348. document.mainViewController?.menuItemAction_hiddenPageIndicator(sender)
  1349. }
  1350. }
  1351. }
  1352. // MARK: - KMSystemEditMenuProtocol
  1353. extension KMBrowserWindowController: KMSystemEditMenuProtocol {
  1354. func menuItemAction_find(_ sender: Any) {
  1355. if (self.canResponseDocumentAction() == false) {
  1356. return
  1357. }
  1358. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1359. document.mainViewController?.menuItemAction_find(sender)
  1360. }
  1361. }
  1362. }
  1363. // MARK: - Annotation Menu
  1364. extension KMBrowserWindowController {
  1365. @IBAction func menuItemAction_highlight(_ sender: Any) {
  1366. if (self.canResponseDocumentAction() == false) {
  1367. return
  1368. }
  1369. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1370. document.mainViewController?.menuItemAction_highlight(sender)
  1371. }
  1372. }
  1373. @IBAction func menuItemAction_underline(_ sender: Any) {
  1374. if (self.canResponseDocumentAction() == false) {
  1375. return
  1376. }
  1377. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1378. document.mainViewController?.menuItemAction_underline(sender)
  1379. }
  1380. }
  1381. @IBAction func menuItemAction_deleteLine(_ sender: Any) {
  1382. if (self.canResponseDocumentAction() == false) {
  1383. return
  1384. }
  1385. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1386. document.mainViewController?.menuItemAction_deleteLine(sender)
  1387. }
  1388. }
  1389. @IBAction func menuItemAction_freehand(_ sender: Any) {
  1390. if (self.canResponseDocumentAction() == false) {
  1391. return
  1392. }
  1393. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1394. document.mainViewController?.menuItemAction_freehand(sender)
  1395. }
  1396. }
  1397. @IBAction func menuItemAction_text(_ sender: Any) {
  1398. if (self.canResponseDocumentAction() == false) {
  1399. return
  1400. }
  1401. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1402. document.mainViewController?.menuItemAction_text(sender)
  1403. }
  1404. }
  1405. @IBAction func menuItemAction_note(_ sender: Any) {
  1406. if (self.canResponseDocumentAction() == false) {
  1407. return
  1408. }
  1409. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1410. document.mainViewController?.menuItemAction_note(sender)
  1411. }
  1412. }
  1413. @IBAction func menuItemAction_squre(_ sender: Any) {
  1414. if (self.canResponseDocumentAction() == false) {
  1415. return
  1416. }
  1417. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1418. document.mainViewController?.menuItemAction_squre(sender)
  1419. }
  1420. }
  1421. @IBAction func menuItemAction_circle(_ sender: Any) {
  1422. if (self.canResponseDocumentAction() == false) {
  1423. return
  1424. }
  1425. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1426. document.mainViewController?.menuItemAction_circle(sender)
  1427. }
  1428. }
  1429. @IBAction func menuItemAction_arrow(_ sender: Any) {
  1430. if (self.canResponseDocumentAction() == false) {
  1431. return
  1432. }
  1433. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1434. document.mainViewController?.menuItemAction_arrow(sender)
  1435. }
  1436. }
  1437. @IBAction func menuItemAction_line(_ sender: Any) {
  1438. if (self.canResponseDocumentAction() == false) {
  1439. return
  1440. }
  1441. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1442. document.mainViewController?.menuItemAction_line(sender)
  1443. }
  1444. }
  1445. // link
  1446. @IBAction func menuItemAction_link(_ sender: Any) {
  1447. if (self.canResponseDocumentAction() == false) {
  1448. return
  1449. }
  1450. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1451. document.mainViewController?.menuItemAction_link(sender)
  1452. }
  1453. }
  1454. @IBAction func menuItemAction_linkPage(_ sender: Any) {
  1455. if (self.canResponseDocumentAction() == false) {
  1456. return
  1457. }
  1458. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1459. document.mainViewController?.menuItemAction_linkPage(sender)
  1460. }
  1461. }
  1462. // stamp
  1463. @IBAction func menuItemAction_stamp(_ sender: Any) {
  1464. if (self.canResponseDocumentAction() == false) {
  1465. return
  1466. }
  1467. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1468. document.mainViewController?.menuItemAction_stamp(sender)
  1469. }
  1470. }
  1471. @IBAction func menuItemAction_signure(_ sender: Any) {
  1472. if (self.canResponseDocumentAction() == false) {
  1473. return
  1474. }
  1475. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1476. document.mainViewController?.menuItemAction_signure(sender)
  1477. }
  1478. }
  1479. @IBAction func menuItemAction_hiddenAllAnnotation(_ sender: Any) {
  1480. if (self.canResponseDocumentAction() == false) {
  1481. return
  1482. }
  1483. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1484. document.mainViewController?.menuItemAction_hiddenAllAnnotation(sender)
  1485. }
  1486. }
  1487. @IBAction func menuItemAction_clearAllAnnotation(_ sender: Any) {
  1488. if (self.canResponseDocumentAction() == false) {
  1489. return
  1490. }
  1491. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1492. document.mainViewController?.menuItemAction_clearAllAnnotation(sender)
  1493. }
  1494. }
  1495. }
  1496. // MARK: - KMSystemGotoMenuProtocol
  1497. extension KMBrowserWindowController: KMSystemGotoMenuProtocol {
  1498. func menuItemAction_nextPage(_ sender: Any) {
  1499. if (self.canResponseDocumentAction() == false) {
  1500. return
  1501. }
  1502. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1503. document.mainViewController?.menuItemAction_nextPage(sender)
  1504. }
  1505. }
  1506. func menuItemAction_forwardPage(_ sender: Any) {
  1507. if (self.canResponseDocumentAction() == false) {
  1508. return
  1509. }
  1510. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1511. document.mainViewController?.menuItemAction_forwardPage(sender)
  1512. }
  1513. }
  1514. func menuItemAction_firstPage(_ sender: Any) {
  1515. if (self.canResponseDocumentAction() == false) {
  1516. return
  1517. }
  1518. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1519. document.mainViewController?.menuItemAction_firstPage(sender)
  1520. }
  1521. }
  1522. func menuItemAction_lastPage(_ sender: Any) {
  1523. if (self.canResponseDocumentAction() == false) {
  1524. return
  1525. }
  1526. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1527. document.mainViewController?.menuItemAction_lastPage(sender)
  1528. }
  1529. }
  1530. func menuItemAction_forward(_ sender: Any) {
  1531. if (self.canResponseDocumentAction() == false) {
  1532. return
  1533. }
  1534. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1535. document.mainViewController?.menuItemAction_forward(sender)
  1536. }
  1537. }
  1538. func menuItemAction_goback(_ sender: Any) {
  1539. if (self.canResponseDocumentAction() == false) {
  1540. return
  1541. }
  1542. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1543. document.mainViewController?.menuItemAction_goback(sender)
  1544. }
  1545. }
  1546. func menuItemAction_gotoPage(_ sender: Any) {
  1547. if (self.canResponseDocumentAction() == false) {
  1548. return
  1549. }
  1550. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1551. document.mainViewController?.menuItemAction_gotoPage(sender)
  1552. }
  1553. }
  1554. }
  1555. // MARK: - KMSystemToolMenuProtocol
  1556. extension KMBrowserWindowController: KMSystemToolMenuProtocol {
  1557. func menuItemAction_scrolTool(_ sender: Any) {
  1558. if (self.canResponseDocumentAction() == false) {
  1559. return
  1560. }
  1561. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1562. document.mainViewController?.menuItemAction_scrolTool(sender)
  1563. }
  1564. }
  1565. func menuItemAction_zoomOutTool(_ sender: Any) {
  1566. if (self.canResponseDocumentAction() == false) {
  1567. return
  1568. }
  1569. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1570. document.mainViewController?.menuItemAction_zoomOutTool(sender)
  1571. }
  1572. }
  1573. func menuItemAction_selectTool(_ sender: Any) {
  1574. if (self.canResponseDocumentAction() == false) {
  1575. return
  1576. }
  1577. if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
  1578. document.mainViewController?.menuItemAction_selectTool(sender)
  1579. }
  1580. }
  1581. }
  1582. // MARK: - KMSystemWindowMenuRrotocol
  1583. extension KMBrowserWindowController: KMSystemWindowMenuRrotocol {
  1584. func menuItemAction_showForwardTagPage(_ sender: Any) {
  1585. if (self.canResponseDocumentAction() == false) {
  1586. return
  1587. }
  1588. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1589. if (document.isHome) {
  1590. document.homeViewController?.menuItemAction_showForwardTagPage(sender)
  1591. } else {
  1592. document.mainViewController?.menuItemAction_showForwardTagPage(sender)
  1593. }
  1594. }
  1595. }
  1596. func menuItemAction_showNextTagPage(_ sender: Any) {
  1597. if (self.canResponseDocumentAction() == false) {
  1598. return
  1599. }
  1600. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1601. if (document.isHome) {
  1602. document.homeViewController?.menuItemAction_showNextTagPage(sender)
  1603. } else {
  1604. document.mainViewController?.menuItemAction_showNextTagPage(sender)
  1605. }
  1606. }
  1607. }
  1608. func menuItemAction_newTagPageToNewWindow(_ sender: Any) {
  1609. if (self.canResponseDocumentAction() == false) {
  1610. return
  1611. }
  1612. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1613. if (document.isHome) {
  1614. document.homeViewController?.menuItemAction_newTagPageToNewWindow(sender)
  1615. } else {
  1616. document.mainViewController?.menuItemAction_newTagPageToNewWindow(sender)
  1617. }
  1618. }
  1619. }
  1620. func menuItemAction_mergeAllWindow(_ sender: Any) {
  1621. if (self.canResponseDocumentAction() == false) {
  1622. return
  1623. }
  1624. if let document = self.browser.activeTabContents() as? KMMainDocument {
  1625. if (document.isHome) {
  1626. document.homeViewController?.menuItemAction_mergeAllWindow(sender)
  1627. } else {
  1628. document.mainViewController?.menuItemAction_mergeAllWindow(sender)
  1629. }
  1630. }
  1631. }
  1632. }
  1633. // MARK: - Analytics (埋点)
  1634. extension KMBrowserWindowController {
  1635. func trackEvent_upgrade() -> Void {
  1636. KMAnalytics.trackEvent(eventName: "Btn_Tbr_Upgrade", parameters: [
  1637. KMAnalytics.Parameter.categoryKey : KMAnalytics.Category.tbr,
  1638. KMAnalytics.Parameter.labelKey : KMAnalytics.Label.tbr_Btn], platform: .AppCenter, appTarget: .all)
  1639. }
  1640. }