KMMainViewController+UI.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. //
  2. // KMMainViewController+UI.swift
  3. // PDF Master
  4. //
  5. // Created by wanjun on 2022/12/15.
  6. //
  7. import Foundation
  8. extension KMMainViewController {
  9. func showChildToolbar(showToolbar:Bool) {
  10. if showToolbar == true && self.isReadMode == false {
  11. self.view.addSubview(self.childToolbarController.view)
  12. } else {
  13. self.childToolbarController.view.removeFromSuperview()
  14. }
  15. self.updateTopView()
  16. }
  17. private func updateTopView () {
  18. let frame = self.view.frame
  19. if self.childToolbarController.view.superview != nil {
  20. let toolbarFrame = self.childToolbarController.view.frame;
  21. self.childToolbarController.view.frame = CGRect(x: 0, y: (frame.size.height ?? 0)-toolbarFrame.size.height, width: frame.size.width ?? 0, height: toolbarFrame.size.height)
  22. self.childToolbarController.view.autoresizingMask = [.width,.minYMargin]
  23. self.toplayoutConstraint.constant = toolbarFrame.size.height
  24. } else {
  25. self.toplayoutConstraint.constant = 0
  26. }
  27. }
  28. //通知
  29. func preferenceDidChangeNotification(notification:Notification) {
  30. let info : [AnyHashable : Any] = notification.userInfo ?? [:]
  31. if info.keys.contains(KMPreference.viewZoomScaleTypeKey) {
  32. self.selectZoom(KMPreferenceManager.shared.viewZoomScaleType)
  33. }
  34. if notification.name.rawValue == "pdfViewDocumentDidLoaded" || info.keys.contains(KMPreference.viewPageDisplayTypeKey) {
  35. self.selectDisplay(display: KMPreferenceManager.shared.viewPageDisplayType)
  36. }
  37. if info.keys.contains(KMPreference.displayBackgroundNormalColorKey) || notification.name.rawValue == "pdfViewDocumentDidLoaded" {
  38. self.listView.backgroundColor = KMPreferenceManager.shared.displayBackgroundNormalColor
  39. self.listView.layoutDocumentView()
  40. }
  41. self.updatePageIndicatoreType()
  42. if (info.keys.contains(KMPreference.generalAuthorNameKey)) { // 作者名称
  43. CPDFKitConfig.sharedInstance().setAnnotationAuthor((info[KMPreference.generalAuthorNameKey] as! String))
  44. }
  45. if (info.keys.contains(KMPreference.highlightLinksKey)) {
  46. let hlLink = info[KMPreference.highlightLinksKey] as? Bool
  47. CPDFKitConfig.sharedInstance().setEnableLinkFieldHighlight(hlLink == nil ? false : hlLink!)
  48. self.listView.setNeedsDisplayForVisiblePages()
  49. }
  50. if (info.keys.contains(KMPreference.autoSaveKey) || info.keys.contains(KMPreference.autoSavePerNumberMinuteKey)) {
  51. self.autoSaveTimeStartOrStopIfNeed()
  52. }
  53. }
  54. //刷新页面显示器
  55. func updatePageIndicatoreType () {
  56. if self.isReadMode {
  57. self.pageNumberDisplayView.dismiss()
  58. } else {
  59. if self.listView.document != nil {
  60. self.pageNumberDisplayView.totalPagesCount = Int(self.listView.document.pageCount)
  61. }
  62. self.pageNumberDisplayView.currentPageIndex = self.listView.currentPageIndex
  63. self.pageNumberDisplayView.displayType = KMPreferenceManager.shared.pageIndicatorType
  64. self.readContentView.addSubview(self.tipCurrentPageBox, positioned: .above, relativeTo: self.readContentView)
  65. }
  66. }
  67. }
  68. extension KMMainViewController: KMToolbarControllerDelegate {
  69. func toolbarController(_ viewController: KMToolbarController, heightOffsetChange heightOffset: Float) {
  70. if self.isReadMode {
  71. self.heightOffset.constant = CGFloat(0)
  72. } else {
  73. self.heightOffset.constant = CGFloat(heightOffset)
  74. }
  75. self.refreshListViewToolMode()
  76. self.trackEvent(toolMode: self.listView.toolMode)
  77. if self.listView.annotationType == .editTextImage ||
  78. self.listView.annotationType == .addText ||
  79. self.listView.annotationType == .addImage {
  80. self.closeRightPane()
  81. }
  82. self.listView.annotationType = .unkown
  83. // self.rightSideViewController.view.isHidden = true
  84. // self.rightSideViewController.isHidden = true
  85. // if self.toolbarController.toolbarType != .LeftPanel {
  86. // self.closeRightPane()
  87. // }
  88. }
  89. func changeAnnotationModeAction(item: KMToolbarClickButton){
  90. if let type = CAnnotationType(rawValue: item.tag) {
  91. self.trackEvent(annotationType: type)
  92. }
  93. if (self.rightMouseEventing) {
  94. self.rightMouseEventing = false
  95. }
  96. if (self.toolbarController.ignoreCurrentAnnotationTypeChange) {
  97. self.toolbarController.ignoreCurrentAnnotationTypeChange = false
  98. }
  99. var currentType = self.listView.annotationType
  100. if (currentType == .eraser) {
  101. currentType = .ink
  102. }
  103. var isSelected = (currentType == CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown) && ((self.listView.toolMode == .noteToolMode) || (self.listView.toolMode == .selfSignMode))
  104. var editSelectd = false
  105. if self.listView.annotationType == CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown && self.listView.toolMode == .editPDFToolMode {
  106. editSelectd = true
  107. }
  108. //多边形工具栏点击特殊处理
  109. if (self.listView.annotationType == .square ||
  110. self.listView.annotationType == .circle ||
  111. self.listView.annotationType == .arrow ||
  112. self.listView.annotationType == .line) {
  113. if CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown == .square ||
  114. CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown == .circle ||
  115. CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown == .arrow ||
  116. CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown == .line {
  117. isSelected = true
  118. }
  119. } else if (item.tag > 3 && item.tag < 8) {
  120. let shape = UserDefaults.standard.object(forKey: KMToolBarToolPDFShapeStyle)
  121. item.tag = shape as? Int ?? item.tag
  122. }
  123. if isSelected {
  124. self.listView.toolMode = .textToolMode
  125. self.listView.annotationType = .unkown
  126. self.closeRightPane()
  127. } else {
  128. if self.listView.currentSelection != nil {
  129. let annotation = self.listView.addAnnotation(with: CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown, selection: self.listView.currentSelection, page: self.listView.currentSelection.page, bounds: self.listView.currentSelection.bounds)
  130. if((annotation != nil) &&
  131. !self.listView.activeAnnotations.contains(annotation ?? self.listView.activeAnnotation)) {
  132. var newAnnonations : [CPDFAnnotation] = []
  133. newAnnonations.append(annotation!)
  134. self.listView.updateActiveAnnotations(newAnnonations)
  135. self.listView.setNeedsDisplayAnnotationViewFor(annotation?.page)
  136. }
  137. }
  138. self.refreshListViewToolMode()
  139. let type = CAnnotationType(rawValue: item.tag) ?? CAnnotationType.unkown
  140. var annotations: [CPDFAnnotation] = []
  141. if (type == .link) {
  142. for annotation in self.listView.activeAnnotations {
  143. if ((annotation is CPDFLinkAnnotation) == false) {
  144. continue
  145. }
  146. annotations.append(annotation as! CPDFAnnotation)
  147. }
  148. }
  149. self.listView.annotationType = type
  150. if (type == .link && annotations.count > 0) {
  151. self.listView.updateActiveAnnotations(annotations)
  152. }
  153. }
  154. if self.listView.toolMode != .editPDFToolMode && self.listView.annotationType != .unkown {
  155. // self.rightSideViewController.view.isHidden = false
  156. self.rightSideViewController.isHidden = false
  157. self.rightSideViewController.subViewType = .AnnotationProperts
  158. self.openRightPane()
  159. } else if self.listView.toolMode == .editPDFToolMode {
  160. if editSelectd {
  161. // self.rightSideViewController.view.isHidden = true
  162. self.rightSideViewController.isHidden = true
  163. self.listView.setShouAddEdit([])
  164. self.listView.change([.text, .image])
  165. self.listView.annotationType = .editTextImage
  166. self.closeRightPane()
  167. } else if self.listView.annotationType == .addText {
  168. // self.rightSideViewController.view.isHidden = false
  169. self.rightSideViewController.isHidden = false
  170. self.openRightPane()
  171. self.rightSideViewController.subViewType = .EditPDFAddText
  172. self.listView.setShouAddEdit(.text)
  173. self.listView.change(.text)
  174. } else if self.listView.annotationType == .addImage {
  175. // self.rightSideViewController.isHidden = false
  176. self.closeRightPane()
  177. self.rightSideViewController.subViewType = .EditPDFAddImage
  178. self.listView.setShouAddEdit(.image)
  179. self.listView.change(.image)
  180. }
  181. } else {
  182. // self.rightSideViewController.view.isHidden = true
  183. self.rightSideViewController.isHidden = true
  184. self.closeRightPane()
  185. }
  186. }
  187. func refreshListViewToolMode () {
  188. if self.toolbarController.toolbarType == .Annatiton {
  189. self.listView.toolMode = .noteToolMode
  190. } else if self.toolbarController.toolbarType == .Move {
  191. self.listView.toolMode = .moveToolMode
  192. } else if self.toolbarController.toolbarType == .Magnify {
  193. self.listView.toolMode = .magnifyToolMode
  194. } else if self.toolbarController.toolbarType == .Select {
  195. self.listView.toolMode = .selectToolMode
  196. } else if self.toolbarController.toolbarType == .SelectZoom {
  197. self.listView.toolMode = .selectZoomToolMode
  198. } else if self.toolbarController.toolbarType == .Page {
  199. } else if self.toolbarController.toolbarType == .Form {
  200. self.listView.toolMode = .formToolMode
  201. self.rightSideViewController.subViewType = .AnnotationProperts
  202. } else if self.toolbarController.toolbarType == .FillSign {
  203. self.listView.toolMode = .selfSignMode
  204. self.rightSideViewController.subViewType = .AnnotationProperts
  205. } else if self.toolbarController.toolbarType == .editPDF {
  206. self.listView.toolMode = .editPDFToolMode
  207. // self.listView.editingConfig().isShowEditingAreaHover = true
  208. // self.listView.editingConfig().editingBorderWidth = 1
  209. // self.listView.editingConfig().editingCenterRadius = 5
  210. // self.listView.editingConfig().editAreaMargin = 2
  211. // self.listView.editingConfig().editingHoverBorderColor = NSColor.init(red: 0, green: 136.0/255.0, blue: 1.0, alpha: 0.5)
  212. // self.listView.editingConfig().editingBorderColor = NSColor.init(red: 0, green: 0, blue: 0, alpha: 0.4)
  213. // self.listView.editingConfig().addEditAreaColor = NSColor.init(red: 23.0/255.0, green: 112.0/255.0, blue: 244.0/255.0, alpha: 0.5)
  214. // self.listView.editingConfig().editAreaMoveFillColor = NSColor.init(red: 23.0/255.0, green: 112.0/255.0, blue: 244.0/255.0, alpha: 0.1)
  215. self.listView.setShouAddEdit([])
  216. }else if self.toolbarController.toolbarType == .LeftPanel {
  217. self.toggleLeftPane()
  218. self.leftSideViewController.showPanelView(show: true)
  219. }else {
  220. // if self.leftSideViewController.isShowPanel {
  221. // self.leftSideViewController.showPanelView(show: false)
  222. // }
  223. self.listView.toolMode = .textToolMode
  224. }
  225. }
  226. func showPDFLayoutModeAction(show: Bool) {
  227. self.listView.annotationType = .unkown
  228. self.showOrHideNotes()
  229. }
  230. func toolbarViewController(_ viewController: KMToolbarViewController, rightPanel toolbarItem: KMToolBoxItem) {
  231. self.toggleRightPane()
  232. }
  233. func toolbarViewController(_ viewController: KMToolbarViewController, leftPanel toolbarItem: KMToolBoxItem) {
  234. self.toggleLeftPane()
  235. self.leftSideViewController.showPanelView(show: toolbarItem.isSelected)
  236. }
  237. }
  238. extension KMMainViewController : NSSplitViewDelegate {
  239. func splitView(_ splitView: NSSplitView, canCollapseSubview subview: NSView) -> Bool {
  240. if splitView == self.mianSplitView {
  241. // return (subview == self.listView) == false
  242. }
  243. return false
  244. }
  245. func splitView(_ splitView: NSSplitView, shouldCollapseSubview subview: NSView, forDoubleClickOnDividerAt dividerIndex: Int) -> Bool {
  246. return false
  247. }
  248. func splitView(_ splitView: NSSplitView, shouldHideDividerAt dividerIndex: Int) -> Bool {
  249. return splitView == self.mianSplitView
  250. }
  251. func splitView(_ splitView: NSSplitView, constrainMaxCoordinate proposedMaximumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {
  252. if splitView == mianSplitView {
  253. let splitViewWidth = splitView.frame.width
  254. let dividerIndexX0 = panelWidth + functionWidth
  255. if dividerIndex == 0 {
  256. if leftPanelOpen {
  257. return CGFloat(dividerIndexX0 * 1.5)
  258. } else {
  259. return functionWidth
  260. }
  261. } else if dividerIndex == 1 {
  262. return splitViewWidth
  263. }
  264. }
  265. return proposedMaximumPosition
  266. }
  267. func splitView(_ splitView: NSSplitView, constrainMinCoordinate proposedMinimumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {
  268. if splitView == mianSplitView {
  269. let splitViewWidth = splitView.frame.width
  270. let dividerIndexX1 = splitViewWidth - defaultRightWidth
  271. if dividerIndex == 0 {
  272. return functionWidth
  273. } else if dividerIndex == 1 {
  274. return dividerIndexX1
  275. }
  276. }
  277. return proposedMinimumPosition
  278. }
  279. func splitView(_ splitView: NSSplitView, resizeSubviewsWithOldSize oldSize: NSSize) {
  280. if splitView.isEqual(to: mianSplitView) {
  281. let leftView = splitView.subviews[0]
  282. let centerView = splitView.subviews[1]
  283. let rightView = splitView.subviews[2]
  284. let leftCollapsed = splitView.isSubviewCollapsed(leftView)
  285. let rightCollapsed = splitView.isSubviewCollapsed(rightView)
  286. var leftSize = leftView.frame.size
  287. var mainSize = centerView.frame.size
  288. var rightSize = rightView.frame.size
  289. var contentWidth = splitView.frame.width
  290. if leftCollapsed {
  291. leftSize.width = 0.0
  292. } else {
  293. contentWidth = contentWidth - splitView.dividerThickness
  294. }
  295. if rightCollapsed {
  296. rightSize.width = 0.0
  297. } else {
  298. contentWidth = contentWidth - splitView.dividerThickness
  299. }
  300. if contentWidth < leftSize.width + rightSize.width {
  301. var oldContentWidth = oldSize.width
  302. if leftCollapsed == false {
  303. oldContentWidth = oldContentWidth - splitView.dividerThickness
  304. }
  305. if rightCollapsed == false {
  306. oldContentWidth = oldContentWidth - splitView.dividerThickness
  307. }
  308. let resizeFactor = contentWidth / oldContentWidth
  309. leftSize.width = floor(resizeFactor*leftSize.width)
  310. rightSize.width = floor(resizeFactor*rightSize.width)
  311. }
  312. mainSize.width = contentWidth - leftSize.width - rightSize.width
  313. leftSize.height = splitView.frame.height
  314. rightSize.height = splitView.frame.height
  315. mainSize.height = splitView.frame.height
  316. if leftCollapsed == false {
  317. leftView.setFrameSize(leftSize)
  318. }
  319. if rightCollapsed == false {
  320. rightView.setFrameSize(rightSize)
  321. }
  322. centerView.setFrameSize(mainSize)
  323. }
  324. splitView.adjustSubviews()
  325. }
  326. func splitViewWillResizeSubviews(_ notification: Notification) {
  327. let defaultView = KMSplitView()
  328. let sender : NSSplitView = notification.object as? NSSplitView ?? defaultView
  329. if (sender == self.mianSplitView || sender == defaultView) && self.view.window?.frameAutosaveName != nil{
  330. let leftWidth = self.mianSplitView.isSubviewCollapsed(self.leftView) ? 0.0 : leftSideViewController.view.frame.width
  331. if leftPanelOpen {
  332. // if leftWidth < 100 && lastLeftPanWidth > functionWidth{
  333. // self.closeLeftPane()
  334. // }
  335. }
  336. }
  337. }
  338. func splitViewDidResizeSubviews(_ notification: Notification) {
  339. self.locationPageView.frame = CGRect(x: 0, y: self.listView.frame.maxY-32, width: self.listView.frame.width, height: 32)
  340. let defaultView = KMSplitView()
  341. let sender : NSSplitView = notification.object as? NSSplitView ?? defaultView
  342. if (sender == self.mianSplitView || sender == defaultView) && self.view.window?.frameAutosaveName != nil{
  343. let leftWidth = self.mianSplitView.isSubviewCollapsed(self.leftView) ? 0.0 : leftSideViewController.view.frame.width
  344. let rightWidth = self.mianSplitView.isSubviewCollapsed(self.rightView) ? 0.0 : rightSideViewController.view.frame.width
  345. UserDefaults.standard.set(leftWidth, forKey: CPDFOfficeLeftSidePaneWidthKey)
  346. UserDefaults.standard.set(rightWidth, forKey: CPDFOfficeRightSidePaneWidthKey)
  347. }
  348. }
  349. func splitView(_ splitView: NSSplitView, constrainSplitPosition proposedPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {
  350. if dividerIndex == 0 {
  351. if leftPanelOpen {
  352. //当左边栏开启式,拖拽时不改变宽度,当宽度达到原宽度的一半时关闭窗口
  353. //如果 isShowPanel 为 true 那么将不会收缩
  354. if (proposedPosition < functionWidth + panelWidth * 0.5) && !self.leftSideViewController.isShowPanel {
  355. self.closeLeftPane()
  356. self.leftSideViewController.refreshMethodType(methodType: .None)
  357. return functionWidth
  358. } else if proposedPosition > panelWidth + functionWidth {
  359. return proposedPosition
  360. } else {
  361. return panelWidth + functionWidth
  362. }
  363. } else {
  364. return functionWidth
  365. }
  366. }
  367. return proposedPosition
  368. }
  369. }
  370. extension KMMainViewController: KMLeftSideViewControllerDelegate {
  371. func controlStateChange(_ obj: KMLeftSideViewController, show: Bool) {
  372. if show {
  373. self.openLeftPane()
  374. } else {
  375. self.closeLeftPane()
  376. }
  377. }
  378. func enterEditMode(_ obj: KMLeftSideViewController, _ pages: [Int]) {
  379. let item : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentPageToolbarItemIdentifier))!
  380. self.toolbarController.mainToolBarView?.delegate?.toolbarViewController?(self.toolbarController.mainToolBarView!, clickMode: .Page, toolbar: item, pages)
  381. }
  382. func searchAction(searchString: String,isCase:Bool) {
  383. self.search(searchString: searchString,isCase: isCase)
  384. }
  385. func controller(_ controller: KMLeftSideViewController, dispayDidChange dispay: KMPDFDisplayType) {
  386. self.selectDisplay(display: dispay, viewSettingIsReload: false)
  387. }
  388. func controller(controller: KMLeftSideViewController, itemClick item: Any?, itemKey: KMItemKey, params: Any?) {
  389. if (itemKey == .print) { // 打印
  390. var pageRange: KMPrintPageRange = KMPrintPageRange(type: .allPage, selectPages: [], reversePrintOrder: false)
  391. if (params != nil) {
  392. pageRange.type = .custom
  393. pageRange.selectPages = params as! [Int]
  394. }
  395. self.showPrintWindow(pageRange: pageRange)
  396. } else if (itemKey == .cut || itemKey == .paste || itemKey == .delete || itemKey == .leftRotate || itemKey == .rightRotate) {
  397. self.recordIsPDFDocumentEdited(type: itemKey.toSubscribeWaterMarkType())
  398. }
  399. }
  400. func controller(controller: KMLeftSideViewController, bookMarkDidChange bookMarks: [KMBookMarkItem]) {
  401. self.needSave = true
  402. self.recordIsPDFDocumentEdited()
  403. }
  404. func controller(controller: KMLeftSideViewController, rotateType: KMRotateType) {
  405. if rotateType == .clockwise {
  406. self.menuItemAction_rotateRight((Any).self)
  407. } else if rotateType == .anticlockwise {
  408. self.menuItemAction_rotateLeft((Any).self)
  409. }
  410. }
  411. }
  412. //MARK: ReadModel
  413. extension KMMainViewController {
  414. @objc func openReadModel() {
  415. //保存进入阅读模式之前的状态
  416. readLeftMethodType = self.leftSideViewController.type.methodType
  417. readLeftPanelOpen = leftPanelOpen
  418. readLastLeftPanWidth = lastLeftPanWidth
  419. readLeftViewShowPanel = self.leftSideViewController.isShowPanel
  420. readRightPanelOpen = rightPanelIsOpen
  421. readToolbarType = self.toolbarController.toolbarType
  422. readToolbarItemIdentifier = self.toolbarController.lastItemBox.itemIdentifier
  423. readToolMode = self.listView.toolMode
  424. readAnnotationType = self.listView.annotationType
  425. readSubViewType = self.rightSideViewController.subViewType ?? .None
  426. //设置阅读模式
  427. self.isReadMode = true
  428. self.readModelView.isHidden = false
  429. //顶部菜单栏状态清空
  430. self.toolbarController.toolbarType = .None
  431. self.toolbarController.cancelSelected(KMLeftControlToolbarItemIdentifier)
  432. self.toolbarController.cancelSelected(KMRightControlToolbarItemIdentifier)
  433. self.toolbarController.lastItemBox.isSelected = false
  434. //左侧菜单栏情况
  435. self.leftPanelOpen = false
  436. self.lastLeftPanWidth = 0
  437. self.leftSideViewController.refreshMethodType(methodType: .None)
  438. //阅读界面初始化
  439. self.readModelView.isHidden = false
  440. self.readModelView.currentPageIndex = self.listView.currentPageIndex
  441. self.readModelView.totalPagesCount = Int(self.listView.document.pageCount)
  442. self.readModelView.beginTimer()
  443. // self.listView.autoScales = true
  444. // self.readModelView.scaleType = .autoSize
  445. self.readModelView.zoomButton.stringValue = (NSString(format: "%.0f", self.listView.scaleFactor * 100) as String) + "%"
  446. //关闭左侧右侧菜单栏
  447. self.closeLeftPane()
  448. self.closeRightPane()
  449. self.leftSideViewController.showPanelView(show: false)
  450. self.leftView.isHidden = true
  451. //弹出提示框
  452. let alertView = CustomAlertView(message: NSLocalizedString("Read mode on, you can press ESC to exit.", comment: ""), from: self.view, with: .blue, backgroundColor: NSColor(hex: "#36383B"))
  453. }
  454. @objc func closeReadModel() {
  455. if self.isReadMode {
  456. self.isShowBOTA = false
  457. self.readModelView.isHidden = true
  458. self.isReadMode = false
  459. self.readModelView.isHidden = true
  460. self.leftSideViewController.refreshMethodType(methodType: readLeftMethodType)
  461. self.leftPanelOpen = readLeftPanelOpen
  462. self.rightPanelIsOpen = readRightPanelOpen
  463. self.lastLeftPanWidth = readLastLeftPanWidth
  464. if self.leftPanelOpen {
  465. self.openLeftPane()
  466. }
  467. if self.rightPanelIsOpen {
  468. self.rightPanelIsOpen = false
  469. // self.toolbarController.selectItem(KMRightControlToolbarItemIdentifier)
  470. self.openRightPane()
  471. }
  472. self.leftSideViewController.showPanelView(show: readLeftViewShowPanel)
  473. if readLeftViewShowPanel {
  474. self.toolbarController.selectItem(KMLeftControlToolbarItemIdentifier)
  475. }
  476. self.toolbarController.selectItem(readToolbarItemIdentifier)
  477. // self.toolbarController.toolbarType = .Annatiton
  478. self.listView.toolMode = readToolMode
  479. self.listView.annotationType = readAnnotationType
  480. } else {
  481. self.toolbarController.toolbarType = .None
  482. }
  483. let alertView = CustomAlertView(message: NSLocalizedString("Read Mode Off", comment: ""), from: self.view, with: .blue, backgroundColor: NSColor(hex: "#36383B"))
  484. }
  485. @objc func highlightLinks() {
  486. let highlightLinks = KMPreferenceManager.shared.highlightLinks
  487. KMPreferenceManager.shared.highlightLinks = !highlightLinks
  488. }
  489. }