KMPrintBottomView.swift 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // KMPrintBottomView.swift
  3. // PDF Reader Pro
  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. @IBOutlet weak var posterButton: NSButton!
  14. @IBOutlet weak var multipleButton: NSButton!
  15. @IBOutlet weak var bookletButton: NSButton!
  16. @IBOutlet weak var cancelButtonRightConstraint: NSLayoutConstraint!
  17. var delegate: KMPrintBottomViewDelegate?
  18. var type: KMPrintModelType = .size {
  19. didSet {
  20. self.updateButtonState()
  21. }
  22. }
  23. // lazy var presenter: KMImageToPDFChoosePresenter! = KMImageToPDFChoosePresenter()
  24. // lazy var OCRPresenter: KMOCRPresenter! = KMOCRPresenter()
  25. // lazy var data: KMImageToPDFChooseModel! = KMImageToPDFChooseModel()
  26. deinit {
  27. // self.delegate = nil
  28. }
  29. override func draw(_ dirtyRect: NSRect) {
  30. super.draw(dirtyRect)
  31. // Drawing code here.
  32. }
  33. override func setup() {
  34. self.updateButtonState()
  35. self.printButton.title = NSLocalizedString("Printer", comment: "")
  36. self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
  37. self.savePDFButton.title = NSLocalizedString("Save", comment: "")
  38. self.posterButton.title = NSLocalizedString("Poster", comment: "")
  39. self.bookletButton.title = NSLocalizedString("Booklet", comment: "")
  40. self.multipleButton.title = NSLocalizedString("Multiple", comment: "")
  41. }
  42. //刷新界面UI 和 数据
  43. override func reloadData() {
  44. super.reloadData()
  45. // let exporkOptions = self.data.options ?? .PDF
  46. // let exportType = self.data.exportPDFType ?? .new
  47. //
  48. // if exporkOptions.contains(.PDF) {
  49. //
  50. // }
  51. //
  52. // if exporkOptions.contains(.OCR) {
  53. // self.selectLanguageButton.isEnabled = true
  54. // self.saveTXTButton.isEnabled = true
  55. // } else {
  56. // self.selectLanguageButton.isEnabled = false
  57. // self.saveTXTButton.isEnabled = false
  58. // }
  59. //
  60. // if exportType == .new {
  61. // self.newPDFButton.state = .on
  62. // self.mergePDFButton.isEnabled = true
  63. //
  64. // self.insertPDFButton.state = .off
  65. // self.exportSelectFileButton.isEnabled = false
  66. // } else if exportType == .insert {
  67. // self.newPDFButton.state = .off
  68. // self.mergePDFButton.isEnabled = false
  69. //
  70. // self.insertPDFButton.state = .on
  71. // self.exportSelectFileButton.isEnabled = true
  72. // }
  73. //
  74. // self.selectLanguageButton.title = self.data.OCRModel.languageDic[KMGOCRLanguageStringKey] as! String
  75. //
  76. // self.exportSelectFileButton.title = self.data.insertFilePath
  77. //
  78. }
  79. func updateButtonState() {
  80. switch type {
  81. case .size:
  82. self.cancelButtonRightConstraint.constant = 20
  83. self.savePDFButton.isHidden = true
  84. self.posterButton.isHidden = false
  85. self.multipleButton.isHidden = false
  86. self.bookletButton.isHidden = false
  87. case .poster, .multipage, .pamphlet:
  88. self.cancelButtonRightConstraint.constant = 109
  89. self.savePDFButton.isHidden = false
  90. self.posterButton.isHidden = true
  91. self.multipleButton.isHidden = true
  92. self.bookletButton.isHidden = true
  93. default:
  94. break
  95. }
  96. }
  97. @IBAction func printerAction(_ sender: Any) {
  98. if self.delegate != nil {
  99. self.delegate?.printerAction()
  100. }
  101. }
  102. @IBAction func cancelAction(_ sender: Any) {
  103. if self.delegate != nil {
  104. self.delegate?.cancelAction()
  105. }
  106. }
  107. @IBAction func printAction(_ sender: Any) {
  108. if self.delegate != nil {
  109. self.delegate?.printAction()
  110. }
  111. }
  112. @IBAction func savePDFAction(_ sender: Any) {
  113. if self.delegate != nil {
  114. self.delegate?.savePDFAction()
  115. }
  116. }
  117. @IBAction func bookletButtonAction(_ sender: Any) {
  118. self.delegate?.bookletAction()
  119. }
  120. @IBAction func multipleButtonAction(_ sender: Any) {
  121. self.delegate?.multipageAction()
  122. }
  123. @IBAction func poseterButtonAction(_ sender: Any) {
  124. self.delegate?.posterAction()
  125. }
  126. }
  127. protocol KMPrintBottomViewDelegate {
  128. func printerAction()
  129. func cancelAction()
  130. func printAction()
  131. func savePDFAction()
  132. func posterAction()
  133. func multipageAction()
  134. func bookletAction()
  135. }