KMBatchCompressView.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // KMBatchCompressView.swift
  3. // PDF Master
  4. //
  5. // Created by lizhe on 2023/1/16.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. class KMBatchCompressView: KMBatchSettingItemView {
  10. @IBOutlet weak var titleLabel: NSTextField!
  11. @IBOutlet weak var titleContentView: NSView!
  12. @IBOutlet weak var applyButton: ComponentButton!
  13. @IBOutlet weak var compressView: KMCompressContentView!
  14. var data: KMCompressSettingModel = KMCompressSettingModel(modelsType: .standard)
  15. override func draw(_ dirtyRect: NSRect) {
  16. super.draw(dirtyRect)
  17. // Drawing code here.
  18. }
  19. override func setup() {
  20. self.titleContentView.border(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"), 0.5, 0)
  21. self.applyButton.properties = ComponentButtonProperty(type: .primary,
  22. size: .m,
  23. state: .normal,
  24. buttonText: KMLocalizedString("Apply"),
  25. keepPressState: false)
  26. self.applyButton.setTarget(self, action: #selector(compressButtonAction(_:)))
  27. self.applyButton.reloadData()
  28. self.compressView.selectTypeAction = {[unowned self] view, tModel in
  29. self.data = tModel
  30. }
  31. }
  32. override func reloadData() {
  33. }
  34. override func bacthProcessingNotification() {
  35. if KMBatchManager.manager.state == .processing {
  36. self.applyButton.properties.isDisabled = true
  37. } else {
  38. self.applyButton.properties.isDisabled = false
  39. }
  40. self.applyButton.reloadData()
  41. }
  42. }
  43. protocol KMBatchCompressViewAction {}
  44. extension KMBatchCompressView: KMBatchCompressViewAction {
  45. func compressButtonAction(_ sender: Any) {
  46. self.data = self.compressView.model
  47. if self.batchExport != nil {
  48. self.batchExport!(self, self.data)
  49. }
  50. }
  51. }