KMMainViewController+UI.swift 25 KB

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