KMHomeRightView.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. //
  2. // KMHomeRightView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/10/10.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. @objc public protocol KMHomeRightViewDelegate: AnyObject {
  10. //点击管理快捷工具按钮
  11. @objc optional func homeRightViewDidManageQuickTools(_ view: KMHomeRightView)
  12. //点击快捷工具列表中的某一项
  13. @objc optional func homeRightViewDidQuickToolsItemClicked(_ view: KMHomeRightView, _ toolType: HomeQuickToolType)
  14. //最近文件列表删除更新结束后回调
  15. @objc optional func homeRightViewDidRecentFilesUpdated(_ view: KMHomeRightView)
  16. //选择打开文件
  17. @objc optional func homeRightViewDidChooseFileToOpen(_ view: KMHomeRightView, _ fileURL: URL)
  18. }
  19. public class KMHomeRightView: BaseXibView {
  20. @IBOutlet var scrollView: NSScrollView!
  21. @IBOutlet var collectionView: NSCollectionView!
  22. var filesHeaderView: KMHomeFilesHeaderView = KMHomeFilesHeaderView()
  23. var quickToolsView: KMHomeQuickToolsView = KMHomeQuickToolsView()
  24. var filesEmptyView: KMHistoryEmptyView = KMHistoryEmptyView()
  25. var groupView: ComponentGroup!
  26. var menuActionIndexPaths: Set<IndexPath> = []
  27. var groupActionView: NSView?
  28. var groupViewPoint: CGPoint = CGPointZero
  29. var refreshItemData: Bool = true
  30. weak open var delegate: KMHomeRightViewDelegate?
  31. //MARK: - func
  32. public override func draw(_ dirtyRect: NSRect) {
  33. super.draw(dirtyRect)
  34. // Drawing code here.
  35. }
  36. public required init?(coder decoder: NSCoder) {
  37. super.init(coder: decoder)
  38. }
  39. override init(frame frameRect: NSRect) {
  40. super.init(frame: frameRect)
  41. }
  42. public override func awakeFromNib() {
  43. super.awakeFromNib()
  44. configUI()
  45. }
  46. override func updateUIThemeColor() {
  47. super.updateUIThemeColor()
  48. self.reloadData()
  49. }
  50. override func updateUILanguage() {
  51. super.updateUILanguage()
  52. self.reloadData()
  53. }
  54. public func resetScrollerStyle() {
  55. DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
  56. self.scrollView.scrollerStyle = .overlay
  57. }
  58. }
  59. func configUI() {
  60. collectionView.backgroundColors = [NSColor.clear]
  61. collectionView.wantsLayer = true
  62. collectionView.layer?.backgroundColor = NSColor.clear.cgColor
  63. collectionView.delegate = self
  64. collectionView.dataSource = self
  65. collectionView.allowsEmptySelection = true
  66. collectionView.register(KMHistoryFileThumbItem.self, forItemWithIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMHistoryFileThumbItem"))
  67. collectionView.register(KMHistoryFileListItem.self, forItemWithIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMHistoryFileListItem"))
  68. collectionView.register(KMHomeQuickToolsView.self, forSupplementaryViewOfKind: NSCollectionView.elementKindSectionHeader, withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "kmHomeQuickToolsView"))
  69. collectionView.register(KMHomeFilesHeaderView.self, forSupplementaryViewOfKind: NSCollectionView.elementKindSectionHeader, withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "kmHomeFilesHeaderView"))
  70. collectionView.register(KMHomeFilesEmptyHeaderView.self, forSupplementaryViewOfKind: NSCollectionView.elementKindSectionHeader, withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMHomeFilesEmptyHeaderView"))
  71. collectionView.register(KMHomeFilesEmptyHeaderView.self, forSupplementaryViewOfKind: NSCollectionView.elementKindSectionFooter, withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMHomeFilesEmptyHeaderView"))
  72. }
  73. //刷新所有数据
  74. public func reloadData() {
  75. HistoryFilesManager.manager.refreshHistoryFile()
  76. collectionView.reloadData()
  77. filesHeaderView.updateDeleteButtonState()
  78. collectionViewSelectedChanged()
  79. }
  80. //刷新列表文件UI
  81. public func updateHistoryFileListItemUI() {
  82. if HistoryFilesManager.manager.showMode == .List {
  83. refreshItemData = false
  84. collectionView.reloadItems(at: collectionView.indexPathsForVisibleItems())
  85. DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
  86. self.refreshItemData = true
  87. }
  88. }
  89. }
  90. //刷新快捷工具列表
  91. public func reloadQuickTools() {
  92. quickToolsView.reloadData()
  93. }
  94. public func updateQuickToolsUI() {
  95. quickToolsView.refreshUI()
  96. }
  97. //窗口大小变化时调用此方法
  98. public func windowFrameUpdated() {
  99. updateHistoryFileListItemUI()
  100. updateQuickToolsUI()
  101. }
  102. //MARK: - Private
  103. private func collectionViewSelectedChanged() {
  104. let indexs = collectionView.selectionIndexPaths
  105. HistoryFilesManager.manager.selectFiles.removeAll()
  106. if indexs.count >= 0 {
  107. for index in indexs {
  108. let url = HistoryFilesManager.manager.files[index.item]
  109. HistoryFilesManager.manager.selectFiles.append(url)
  110. }
  111. }
  112. filesHeaderView.updateDeleteButtonState()
  113. }
  114. //显示右键菜单
  115. func showFileMoreActionMenu(point: CGPoint, _ actionView: NSView? = nil) {
  116. var viewHeight: CGFloat = 8
  117. var menuItemArr: [ComponentMenuitemProperty] = []
  118. var items: [(String, String)] = [("Show in Finder", "ShowInFinderKey"),
  119. ("Remove from Recents", "RemovefromRecentKey"),
  120. (" ", " "),
  121. ("Share", "ShareKey")]
  122. if collectionView.selectionIndexPaths.count > 1 {
  123. items = [("Show in Finder", "ShowInFinderKey"),
  124. ("Remove from Recents", "RemovefromRecentKey"),
  125. (" ", " "),
  126. ("Share", "ShareKey")]
  127. }
  128. for (i, value) in items {
  129. if i == " " {
  130. let property: ComponentMenuitemProperty = ComponentMenuitemProperty.divider()
  131. menuItemArr.append(property)
  132. viewHeight += 8
  133. } else {
  134. var stringValue = KMLocalizedString(i)
  135. if(value == "ShareKey") {
  136. stringValue = KMLocalizedString(i) + "..."
  137. }
  138. let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
  139. itemSelected: false,
  140. isDisabled: false,
  141. keyEquivalent: nil,
  142. text: stringValue,
  143. identifier: value)
  144. if value == "FileInformationKey" {
  145. properties_Menuitem.keyEquivalent = "⌘ D"
  146. } else if value == "PrintKey" {
  147. properties_Menuitem.keyEquivalent = "⌘ P"
  148. }
  149. menuItemArr.append(properties_Menuitem)
  150. viewHeight += 36
  151. }
  152. }
  153. if groupView == nil {
  154. groupView = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
  155. }
  156. groupView.groupDelegate = self
  157. groupView?.frame = CGRectMake(0, 0, 180, viewHeight)
  158. groupView.updateGroupInfo(menuItemArr)
  159. if HistoryFilesManager.manager.showMode == .Thumbnail {
  160. groupView.showWithPoint(CGPoint(x: point.x, y: point.y - viewHeight), relativeTo: actionView)
  161. } else {
  162. groupView.showWithPoint(CGPoint(x: point.x, y: point.y - viewHeight), relativeTo: actionView)
  163. }
  164. menuActionIndexPaths = collectionView.selectionIndexPaths
  165. }
  166. //MARK: -删除文件列表
  167. func historyFileDeleteAction(_ indexPaths: [URL]) -> Void {
  168. self.fileDeleteAction()
  169. }
  170. @objc func emptyViewAddFileClicked(_ sender: NSView) {
  171. let openPanel = NSOpenPanel()
  172. openPanel.allowedFileTypes = ["pdf", "PDF"]
  173. openPanel.allowsMultipleSelection = false
  174. openPanel.beginSheetModal(for: self.window!) { [weak self] result in
  175. if result == NSApplication.ModalResponse.OK {
  176. if let url = openPanel.url {
  177. guard let weakSelf = self else { return }
  178. weakSelf.delegate?.homeRightViewDidChooseFileToOpen?(weakSelf, url)
  179. }
  180. }
  181. }
  182. }
  183. func fileDeleteAction() {
  184. if HistoryFilesManager.manager.selectFiles.count > 0 {
  185. if UserDefaults.standard.object(forKey: "HomeFilesDeleteConfirmKey") != nil {
  186. var selects: [URL] = []
  187. if HistoryFilesManager.manager.selectFiles.count > 0 {
  188. for selecturl in HistoryFilesManager.manager.selectFiles {
  189. selects.append(selecturl)
  190. }
  191. }
  192. HistoryFilesManager.manager.historyFileDeleteAction(selects)
  193. self.reloadData()
  194. return
  195. }
  196. let alert = NSAlert()
  197. alert.alertStyle = .informational
  198. alert.informativeText = KMLocalizedString("Remove Selected Files from your Recent Files?")
  199. alert.messageText = KMLocalizedString("The file will disappear from the recent list.")
  200. alert.addButton(withTitle: KMLocalizedString("Delete"))
  201. alert.addButton(withTitle: KMLocalizedString("Cancel"))
  202. alert.showsSuppressionButton = true
  203. let response = alert.runModal()
  204. if response.rawValue == 1000 {
  205. var selects: [URL] = []
  206. for selecturl in HistoryFilesManager.manager.selectFiles {
  207. selects.append(selecturl)
  208. }
  209. HistoryFilesManager.manager.historyFileDeleteAction(selects)
  210. DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
  211. self.reloadData()
  212. }
  213. if alert.suppressionButton?.state == .on {
  214. UserDefaults.standard.set("YES", forKey: "HomeFilesDeleteConfirmKey")
  215. UserDefaults.standard.synchronize()
  216. }
  217. }
  218. } else {
  219. //删除所有文件
  220. let alert = NSAlert()
  221. alert.alertStyle = .informational
  222. alert.informativeText = KMLocalizedString("Remove Files from your Recent Files?")
  223. alert.messageText = KMLocalizedString("The file will disappear from the recent list.")
  224. alert.addButton(withTitle: KMLocalizedString("Delete"))
  225. alert.addButton(withTitle: KMLocalizedString("Cancel"))
  226. let response = alert.runModal()
  227. if response.rawValue == 1000 {
  228. var selects: [URL] = []
  229. for selecturl in HistoryFilesManager.manager.files {
  230. selects.append(selecturl)
  231. }
  232. HistoryFilesManager.manager.historyFileDeleteAction(selects)
  233. self.reloadData()
  234. }
  235. }
  236. }
  237. //MARK: - MouseEvent
  238. public override func rightMouseDown(with event: NSEvent) {
  239. super.rightMouseDown(with: event)
  240. var point = convert(event.locationInWindow, from: nil)
  241. if HistoryFilesManager.manager.showMode == .List {
  242. point.x += 10
  243. }
  244. let collectionPoint = convert(point, to: collectionView)
  245. if let indexPath = collectionView.indexPathForItem(at: collectionPoint) {
  246. if collectionView.selectionIndexPaths.contains(indexPath) {
  247. } else {
  248. collectionView.deselectAll(nil)
  249. collectionView.selectItems(at: [indexPath], scrollPosition: .nearestHorizontalEdge)
  250. }
  251. groupActionView = collectionView.item(at: indexPath)?.view
  252. groupViewPoint = point
  253. showFileMoreActionMenu(point: event.locationInWindow)
  254. }
  255. collectionViewSelectedChanged()
  256. }
  257. }
  258. //MARK: - NSCollectionViewDelegate, NSCollectionViewDataSource
  259. extension KMHomeRightView: NSCollectionViewDelegate, NSCollectionViewDataSource, NSCollectionViewDelegateFlowLayout {
  260. public func numberOfSections(in collectionView: NSCollectionView) -> Int {
  261. return 2
  262. }
  263. public func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
  264. if section == 0 {
  265. return 0
  266. }
  267. return HistoryFilesManager.manager.files.count
  268. }
  269. public func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
  270. if indexPath.item >= HistoryFilesManager.manager.files.count {
  271. return NSCollectionViewItem()
  272. }
  273. if HistoryFilesManager.manager.showMode == .Thumbnail {
  274. let item: KMHistoryFileThumbItem = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMHistoryFileThumbItem"), for: indexPath) as! KMHistoryFileThumbItem
  275. item.fileURL = HistoryFilesManager.manager.files[indexPath.item]
  276. item.reloadData()
  277. item.delegate = self
  278. return item
  279. } else if HistoryFilesManager.manager.showMode == .List {
  280. let item: KMHistoryFileListItem = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMHistoryFileListItem"), for: indexPath) as! KMHistoryFileListItem
  281. item.fileURL = HistoryFilesManager.manager.files[indexPath.item]
  282. item.reloadData()
  283. item.delegate = self
  284. return item
  285. }
  286. return NSCollectionViewItem()
  287. }
  288. public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {
  289. if HistoryFilesManager.manager.showMode == .Thumbnail {
  290. return CGSize(width: 172, height: 248)
  291. } else if HistoryFilesManager.manager.showMode == .List {
  292. print(collectionView.frame.size.width, self.frame.size.width)
  293. return CGSize(width: collectionView.frame.size.width-80, height: 80)
  294. }
  295. return CGSize(width: 0.01, height: 0.01)
  296. }
  297. public func collectionView(_ collectionView: NSCollectionView, viewForSupplementaryElementOfKind kind: NSCollectionView.SupplementaryElementKind, at indexPath: IndexPath) -> NSView {
  298. if kind == NSCollectionView.elementKindSectionHeader {
  299. if indexPath.section == 0 {
  300. //quick tools
  301. quickToolsView = collectionView.makeSupplementaryView(ofKind: kind, withIdentifier: NSUserInterfaceItemIdentifier("kmHomeQuickToolsView"), for: indexPath) as! KMHomeQuickToolsView
  302. quickToolsView.delegate = self
  303. quickToolsView.reloadData()
  304. return quickToolsView
  305. } else if indexPath.section == 1 {
  306. //Recently
  307. filesHeaderView = collectionView.makeSupplementaryView(ofKind: kind, withIdentifier: NSUserInterfaceItemIdentifier("kmHomeFilesHeaderView"), for: indexPath) as! KMHomeFilesHeaderView
  308. filesHeaderView.delegate = self
  309. return filesHeaderView
  310. }
  311. } else if kind == NSCollectionView.elementKindSectionFooter {
  312. let view = collectionView.makeSupplementaryView(ofKind: kind, withIdentifier: NSUserInterfaceItemIdentifier("KMHomeFilesEmptyHeaderView"), for: indexPath) as! KMHomeFilesEmptyHeaderView
  313. if self.filesEmptyView.superview != nil {
  314. self.filesEmptyView.removeFromSuperview()
  315. }
  316. if indexPath.section == 1 &&
  317. HistoryFilesManager.manager.files.count == 0 {
  318. filesEmptyView.frame = CGRectMake((CGRectGetWidth(collectionView.frame)-520)/2, (344-184)/2, 520, 184)
  319. filesEmptyView.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
  320. filesEmptyView.emptyView.setTarget(self, action: #selector(emptyViewAddFileClicked(_:)))
  321. view.addSubview(filesEmptyView)
  322. }
  323. return view
  324. }
  325. return NSView()
  326. }
  327. public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
  328. return 8
  329. }
  330. public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
  331. return 0.01
  332. }
  333. public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> NSSize {
  334. if section == 0 {
  335. if KMNHomeQuickToolManager.defaultManager.collapseTools {
  336. if KMNHomeQuickToolManager.defaultManager.quickToolsItemMutableArray.count <= 4 {
  337. return NSSize(width: collectionView.frame.size.width, height: 172+32+2-60-14) //折叠
  338. }
  339. return NSSize(width: collectionView.frame.size.width, height: 172+32+2) //折叠
  340. } else {
  341. if KMNHomeQuickToolManager.defaultManager.quickToolsItemMutableArray.count <= 4 {
  342. return NSSize(width: collectionView.frame.size.width, height: 228+32-88-14)
  343. }
  344. return NSSize(width: collectionView.frame.size.width, height: 228+32)
  345. }
  346. } else if section == 1 {
  347. return NSSize(width: collectionView.frame.size.width, height: 28)
  348. }
  349. return NSSize(width: 0, height: 0.01)
  350. }
  351. public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, referenceSizeForFooterInSection section: Int) -> NSSize {
  352. if section == 0 {
  353. return NSSize(width: 0, height: 40-16)
  354. } else if section == 1 {
  355. if HistoryFilesManager.manager.files.count == 0 {
  356. return NSSize(width: collectionView.frame.size.width, height: 344)
  357. }
  358. }
  359. return NSSize(width: 0, height: 0.01)
  360. }
  361. public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, insetForSectionAt section: Int) -> NSEdgeInsets {
  362. return NSEdgeInsetsMake(12, 40, 0, 40)
  363. }
  364. public func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
  365. self.collectionViewSelectedChanged()
  366. }
  367. public func collectionView(_ collectionView: NSCollectionView, didDeselectItemsAt indexPaths: Set<IndexPath>) {
  368. self.collectionViewSelectedChanged()
  369. }
  370. }
  371. //MARK: - KMHomeFilesHeaderViewDelegate
  372. extension KMHomeRightView: KMHomeFilesHeaderViewDelegate {
  373. public func homeFilesShowModeDidUpdate(_ view: KMHomeFilesHeaderView) {
  374. self.reloadData()
  375. }
  376. public func homeFilesHeaderViewDeleteButtonClicked(_ view: KMHomeFilesHeaderView) {
  377. self.fileDeleteAction()
  378. }
  379. }
  380. //MARK: - KMHomeQuickToolsViewDelegate
  381. extension KMHomeRightView: KMHomeQuickToolsViewDelegate {
  382. public func homeQuickToolsViewDidCollapseStateChanged(_ view: KMHomeQuickToolsView) {
  383. DispatchQueue.main.async {
  384. self.reloadData()
  385. }
  386. }
  387. public func homeQuickToolsViewDidManageTools(_ view: KMHomeQuickToolsView) {
  388. DispatchQueue.main.async {
  389. self.delegate?.homeRightViewDidManageQuickTools?(self)
  390. }
  391. }
  392. public func homeQuickToolsViewDidItemClicked(_ view: KMHomeQuickToolsView, _ toolType: HomeQuickToolType) {
  393. DispatchQueue.main.async {
  394. self.delegate?.homeRightViewDidQuickToolsItemClicked?(self, toolType)
  395. }
  396. }
  397. }
  398. //MARK: - ComponentGroupDelegate
  399. extension KMHomeRightView: ComponentGroupDelegate {
  400. public func componentGroupDidSelect(group: ComponentGroup?, menuItemProperty: ComponentMenuitemProperty?) {
  401. var selects: [URL] = []
  402. let indexs = self.menuActionIndexPaths
  403. if indexs.count >= 0 {
  404. for index in indexs {
  405. let url = HistoryFilesManager.manager.files[index.item]
  406. selects.append(url)
  407. }
  408. }
  409. if menuItemProperty?.identifier == "ShowInFinderKey" {
  410. NSWorkspace.shared.activateFileViewerSelecting(selects)
  411. } else if menuItemProperty?.identifier == "FileInformationKey" {
  412. } else if menuItemProperty?.identifier == "RemovefromRecentKey" {
  413. self.historyFileDeleteAction(selects)
  414. } else if menuItemProperty?.identifier == "ShareKey" {
  415. let picker = NSSharingServicePicker.init(items: selects)
  416. if let actionView = self.groupActionView {
  417. picker.show(relativeTo: actionView.bounds, of: actionView, preferredEdge: NSRectEdge.minY)
  418. } else {
  419. picker.show(relativeTo: NSRect(x: self.groupViewPoint.x, y: self.groupViewPoint.y, width: 0, height: 0), of: self.collectionView, preferredEdge: NSRectEdge.minY)
  420. }
  421. } else if menuItemProperty?.identifier == "PrintKey" {
  422. }
  423. }
  424. }
  425. //MARK: - KMHistoryFileListItemDelegate
  426. extension KMHomeRightView: KMHistoryFileListItemDelegate {
  427. public func historyFileListItemDidClickedMore(_ view: KMHistoryFileListItem) {
  428. if let indexPath = collectionView.indexPath(for: view) {
  429. if collectionView.selectionIndexPaths.contains(indexPath) {
  430. } else {
  431. collectionView.deselectAll(nil)
  432. collectionView.selectItems(at: [indexPath], scrollPosition: .nearestHorizontalEdge)
  433. }
  434. }
  435. groupActionView = view.moreButton
  436. let point = view.moreButton.superview?.convert(view.moreButton.frame.origin, to: self) ?? CGPointZero
  437. showFileMoreActionMenu(point: point, groupActionView)
  438. }
  439. public func historyFileListItemDidDoubleClicked(_ view: KMHistoryFileListItem) {
  440. if let url = view.fileURL {
  441. delegate?.homeRightViewDidChooseFileToOpen?(self, url)
  442. }
  443. }
  444. }
  445. //MARK: - KMHistoryFileThumbItemDelegate
  446. extension KMHomeRightView: KMHistoryFileThumbItemDelegate {
  447. func historyFileThumbItemDidDoubleClicked(_ view: KMHistoryFileThumbItem) {
  448. if let url = view.fileURL {
  449. delegate?.homeRightViewDidChooseFileToOpen?(self, url)
  450. }
  451. }
  452. }