KMHomeQuickToolsWindowController.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // KMHomeQuickToolsWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/10/31.
  6. //
  7. import Cocoa
  8. typealias KMHomeQuickToolsWindowControllerDataDidChange = (_ controller: KMHomeQuickToolsWindowController) ->Void
  9. class KMHomeQuickToolsWindowController: NSWindowController {
  10. @IBOutlet weak var collectionView: KMHomeQuickToolsCollectionView!
  11. static var sharedHomeQuickTools: KMHomeQuickToolsWindowController = KMHomeQuickToolsWindowController.init(windowNibName: NSNib.Name("KMHomeQuickToolsWindowController"))
  12. var dataChange: KMHomeQuickToolsWindowControllerDataDidChange?
  13. override func windowDidLoad() {
  14. self.window?.title = NSLocalizedString("Advanced Editing Tools", comment: "")
  15. let showType = KMQucikToolsModel.showType()
  16. var showTypeArray: [NSNumber] = []
  17. for index in showType {
  18. showTypeArray.append(index.rawValue as NSNumber)
  19. }
  20. let hiddenType = KMQucikToolsModel.hiddenType()
  21. var hiddenTypeArray: [NSNumber] = []
  22. for index in hiddenType {
  23. hiddenTypeArray.append(index.rawValue as NSNumber)
  24. }
  25. collectionView.showData(showArr: showTypeArray, hideArr: hiddenTypeArray)
  26. collectionView.dataChange = { [unowned self] view, showData in
  27. KMQucikToolsModel.saveShowType(data: showData)
  28. guard let callBack = self.dataChange else { return }
  29. callBack(self)
  30. }
  31. }
  32. }