KMBrowserWindowController.swift 64 KB

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