KMBatchCompressView.swift 2.1 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. titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/1")
  21. titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-medium")
  22. self.titleContentView.border(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"), 0.5, 0)
  23. self.applyButton.properties = ComponentButtonProperty(type: .primary,
  24. size: .m,
  25. state: .normal,
  26. buttonText: KMLocalizedString("Apply"),
  27. keepPressState: false)
  28. self.applyButton.setTarget(self, action: #selector(compressButtonAction(_:)))
  29. self.applyButton.reloadData()
  30. self.compressView.selectTypeAction = {[unowned self] view, tModel in
  31. self.data = tModel
  32. }
  33. }
  34. override func reloadData() {
  35. }
  36. override func bacthProcessingNotification() {
  37. self.compressView.isDisable = self.isDisable
  38. self.applyButton.properties.isDisabled = self.isDisable
  39. self.applyButton.reloadData()
  40. }
  41. }
  42. protocol KMBatchCompressViewAction {}
  43. extension KMBatchCompressView: KMBatchCompressViewAction {
  44. func compressButtonAction(_ sender: Any) {
  45. self.data = self.compressView.model
  46. if self.batchExport != nil {
  47. self.batchExport!(self, self.data)
  48. }
  49. }
  50. }