KMPropertiesViewPopController.swift 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // KMPropertiesViewPopController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/10/12.
  6. //
  7. import Cocoa
  8. @objcMembers class KMPropertiesViewPopController: NSViewController {
  9. @IBOutlet var titleLabel: NSTextField!
  10. @IBOutlet var titlesubLabel: NSTextField!
  11. @IBOutlet var closeBtn: NSButton!
  12. var guideInfoWindowController: KMGuideInfoWindowController?
  13. var popOver: NSPopover?
  14. var block: (() -> Void)?
  15. // class func defaultManager() -> KMPropertiesViewPopController {
  16. // let singleton = KMPropertiesViewPopController()
  17. // return singleton
  18. // }
  19. static let defaultManager = KMPropertiesViewPopController()
  20. class func showChangeColorDetails() -> Bool {
  21. // let isOpenConvertDetails = UserDefaults.standard.bool(forKey: "KMPropertiesHaveChangeColorDetails")
  22. // if !isOpenConvertDetails {
  23. return true
  24. // }
  25. // return false
  26. }
  27. func showChangeColorDetailsView(_ view: NSView) {
  28. DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
  29. if KMGuideInfoWindowController.availableShow(.customColor) {
  30. self.guideInfoWindowController = KMGuideInfoWindowController.currentWC()
  31. guard let guideWC = self.guideInfoWindowController else { return }
  32. guideWC.type = .customColor
  33. guideWC.digitalBoxRect = view.superview?.convert(view.frame, to: view.window?.contentView) ?? .zero
  34. var beh = view.window?.collectionBehavior ?? []
  35. beh.insert(.canJoinAllSpaces)
  36. guideWC.window?.collectionBehavior = beh
  37. var rect = view.window?.frame ?? .zero
  38. rect.size.height -= 20
  39. guideWC.window?.setFrame(rect, display: false)
  40. guideWC.window?.minSize = rect.size
  41. guideWC.window?.maxSize = rect.size
  42. view.window?.addChildWindow(guideWC.window!, ordered: .above)
  43. guideWC.show()
  44. }
  45. }
  46. }
  47. override func viewDidLoad() {
  48. super.viewDidLoad()
  49. view.wantsLayer = true
  50. view.layer?.backgroundColor = NSColor.gray.cgColor
  51. titleLabel.stringValue = NSLocalizedString("Customize colors", comment: "")
  52. titlesubLabel.stringValue = NSLocalizedString("Right click a color and select \"Change Color...\".", comment: "")
  53. closeBtn.title = NSLocalizedString("Close", comment: "")
  54. closeBtn.wantsLayer = true
  55. closeBtn.layer?.cornerRadius = 1.0
  56. closeBtn.layer?.backgroundColor = NSColor.gray.cgColor
  57. closeBtn.contentTintColor = NSColor.white
  58. }
  59. @IBAction func buttonItemClick_Close(_ sender: Any) {
  60. block?()
  61. block = nil
  62. }
  63. }