KMConvertWordSettingView.swift 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // KMConvertWordSettingView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2022/12/6.
  6. //
  7. import KMComponentLibrary
  8. class KMConvertWordSettingView: KMConvertSettingView {
  9. @IBOutlet weak var pageSettingTitleLabel: NSTextField!
  10. @IBOutlet weak var saveFlowTextRadio: ComponentRadio!
  11. @IBOutlet weak var savePageLayoutRadio: ComponentRadio!
  12. @IBOutlet weak var textOCRBox: NSBox!
  13. @IBOutlet weak var pageRangeBox: NSBox!
  14. // 流排 0 框排 1
  15. var pageSettingSelectedIndex: Int = 0
  16. override func awakeFromNib() {
  17. super.awakeFromNib()
  18. saveFlowTextRadio.properties = ComponentCheckBoxProperty(size: .s,
  19. state: .normal,
  20. isDisabled: false,
  21. showhelp: false,
  22. text: NSLocalizedString("Retain Flowing Text", comment: ""),
  23. checkboxType: .normal)
  24. saveFlowTextRadio.setTarget(self, action: #selector(saveFlowTextRadioAction))
  25. savePageLayoutRadio.properties = ComponentCheckBoxProperty(size: .s,
  26. state: .normal,
  27. isDisabled: false,
  28. showhelp: false,
  29. text: NSLocalizedString("Retain Page Layout", comment: ""),
  30. checkboxType: .normal)
  31. savePageLayoutRadio.setTarget(self, action: #selector(savePageLayoutRadioAction))
  32. self._flowTextAction()
  33. }
  34. override func initSubViews() {
  35. super.initSubViews()
  36. self.tipView?.km_add_left_constraint(constant: 8)
  37. self.tipView?.km_add_top_constraint(equalTo: self.pageRangeBox, attribute: .bottom, constant: -5)
  38. self.tipView?.km_add_right_constraint()
  39. self.tipView?.km_add_height_constraint(constant: 16+20+16)
  40. }
  41. override func initDefaultVlaue() {
  42. super.initDefaultVlaue()
  43. self.pageSettingTitleLabel.stringValue = NSLocalizedString("Layout Settings", comment: "")
  44. self.pageSettingTitleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
  45. }
  46. override func viewDidMoveToWindow() {
  47. super.viewDidMoveToWindow()
  48. if (self.ocrItemView == nil) {
  49. self.ocrItemView = KMConvertOCRSettingItemView.createFromNib()
  50. self.textOCRBox.contentView = self.ocrItemView
  51. self.ocrItemView?.titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
  52. self.ocrItemView?.titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
  53. }
  54. self.ocrItemView?.languageIndex = self.ocrLanuguageIndex
  55. if (self.pageRangeItemView == nil) {
  56. self.pageRangeItemView = KMConvertPageRangeSettingItemView.createFromNib()
  57. self.pageRangeBox.contentView = self.pageRangeItemView
  58. self.pageRangeItemView?.titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
  59. self.pageRangeItemView?.titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
  60. }
  61. }
  62. @objc func saveFlowTextRadioAction(sender: AnyObject) {
  63. self._flowTextAction()
  64. }
  65. @objc func savePageLayoutRadioAction(sender: AnyObject) {
  66. self._pageLayoutAction()
  67. }
  68. // MARK: - Private Methods
  69. private func _flowTextAction() {
  70. self.saveFlowTextRadio.properties.checkboxType = .selected
  71. self.saveFlowTextRadio.reloadData()
  72. self.savePageLayoutRadio.properties.checkboxType = .normal
  73. self.savePageLayoutRadio.reloadData()
  74. self.pageSettingSelectedIndex = 0
  75. }
  76. private func _pageLayoutAction() {
  77. self.savePageLayoutRadio.properties.checkboxType = .selected
  78. self.savePageLayoutRadio.reloadData()
  79. self.saveFlowTextRadio.properties.checkboxType = .normal
  80. self.saveFlowTextRadio.reloadData()
  81. self.pageSettingSelectedIndex = 1
  82. }
  83. }