KMPrintBottomView.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // KMPrintBottomView.swift
  3. // PDF Master
  4. //
  5. // Created by lizhe on 2022/12/9.
  6. //
  7. import Cocoa
  8. class KMPrintBottomView: KMBaseXibView {
  9. @IBOutlet weak var printerButton: NSButton!
  10. @IBOutlet weak var savePDFButton: NSButton!
  11. @IBOutlet weak var cancelButton: NSButton!
  12. @IBOutlet weak var printButton: NSButton!
  13. var delegate: KMPrintBottomViewDelegate?
  14. // lazy var presenter: KMImageToPDFChoosePresenter! = KMImageToPDFChoosePresenter()
  15. // lazy var OCRPresenter: KMOCRPresenter! = KMOCRPresenter()
  16. // lazy var data: KMImageToPDFChooseModel! = KMImageToPDFChooseModel()
  17. deinit {
  18. // self.delegate = nil
  19. }
  20. override func draw(_ dirtyRect: NSRect) {
  21. super.draw(dirtyRect)
  22. // Drawing code here.
  23. }
  24. override func setup() {
  25. super.setup()
  26. self.printerButton.wantsLayer = true
  27. self.printerButton.layer?.borderWidth = 1
  28. self.printerButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
  29. self.printerButton.layer?.cornerRadius = 4
  30. self.printerButton.title = NSLocalizedString("Printer", comment: "")
  31. self.printerButton.font = NSFont.SFProTextRegularFont(14)
  32. self.printerButton.contentTintColor = NSColor.km_init(hex: "#252629")
  33. self.cancelButton.wantsLayer = true
  34. self.cancelButton.layer?.borderWidth = 1
  35. self.cancelButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
  36. self.cancelButton.layer?.cornerRadius = 4
  37. self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
  38. self.cancelButton.font = NSFont.SFProTextRegularFont(14)
  39. self.cancelButton.contentTintColor = NSColor.km_init(hex: "#252629")
  40. self.savePDFButton.wantsLayer = true
  41. self.savePDFButton.layer?.borderWidth = 1
  42. self.savePDFButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
  43. self.savePDFButton.layer?.cornerRadius = 4
  44. self.savePDFButton.title = NSLocalizedString("Save as PDF", comment: "")
  45. self.savePDFButton.font = NSFont.SFProTextRegularFont(14)
  46. self.savePDFButton.contentTintColor = NSColor.km_init(hex: "#252629")
  47. self.printButton.wantsLayer = true
  48. self.printButton.layer?.backgroundColor = NSColor.km_init(hex: "#1770F4").cgColor
  49. self.printButton.layer?.cornerRadius = 4
  50. self.printButton.title = NSLocalizedString("Printer", comment: "")
  51. self.printButton.font = NSFont.SFProTextRegularFont(14)
  52. self.printButton.contentTintColor = NSColor.km_init(hex: "#FFFFFF")
  53. }
  54. //刷新界面UI 和 数据
  55. override func reloadData() {
  56. super.reloadData()
  57. // let exporkOptions = self.data.options ?? .PDF
  58. // let exportType = self.data.exportPDFType ?? .new
  59. //
  60. // if exporkOptions.contains(.PDF) {
  61. //
  62. // }
  63. //
  64. // if exporkOptions.contains(.OCR) {
  65. // self.selectLanguageButton.isEnabled = true
  66. // self.saveTXTButton.isEnabled = true
  67. // } else {
  68. // self.selectLanguageButton.isEnabled = false
  69. // self.saveTXTButton.isEnabled = false
  70. // }
  71. //
  72. // if exportType == .new {
  73. // self.newPDFButton.state = .on
  74. // self.mergePDFButton.isEnabled = true
  75. //
  76. // self.insertPDFButton.state = .off
  77. // self.exportSelectFileButton.isEnabled = false
  78. // } else if exportType == .insert {
  79. // self.newPDFButton.state = .off
  80. // self.mergePDFButton.isEnabled = false
  81. //
  82. // self.insertPDFButton.state = .on
  83. // self.exportSelectFileButton.isEnabled = true
  84. // }
  85. //
  86. // self.selectLanguageButton.title = self.data.OCRModel.languageDic[KMGOCRLanguageStringKey] as! String
  87. //
  88. // self.exportSelectFileButton.title = self.data.insertFilePath
  89. //
  90. }
  91. @IBAction func printerAction(_ sender: Any) {
  92. if self.delegate != nil {
  93. self.delegate?.printerAction()
  94. }
  95. }
  96. @IBAction func cancelAction(_ sender: Any) {
  97. if self.delegate != nil {
  98. self.delegate?.cancelAction()
  99. }
  100. }
  101. @IBAction func printAction(_ sender: Any) {
  102. if self.delegate != nil {
  103. self.delegate?.printAction()
  104. }
  105. }
  106. @IBAction func savePDFAction(_ sender: Any) {
  107. if self.delegate != nil {
  108. self.delegate?.savePDFAction()
  109. }
  110. }
  111. }
  112. protocol KMPrintBottomViewDelegate {
  113. func printerAction()
  114. func cancelAction()
  115. func printAction()
  116. func savePDFAction()
  117. }