KMMainViewController+UI.swift 25 KB

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