KMConvertCSVSettingView.swift 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // KMConvertCSVSettingView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2022/12/6.
  6. //
  7. import Cocoa
  8. class KMConvertCSVSettingView: KMConvertSettingView {
  9. @IBOutlet weak var oneFileForPageComboBox: NSButton!
  10. @IBOutlet weak var onlyGetTableBox: NSBox!
  11. @IBOutlet weak var tableSheetComboBox: NSComboBox!
  12. @IBOutlet weak var pageRangeBox: NSBox!
  13. var selectedSettingIndex: Int = 0
  14. var selectedTableFormatIndex: Int = 0
  15. var onlyGetTableVC: KMDesignButton?
  16. override func awakeFromNib() {
  17. super.awakeFromNib()
  18. }
  19. override func initSubViews() {
  20. super.initSubViews()
  21. self.oneFileForPageComboBox.title = NSLocalizedString("Excel Worksheet Settings", comment: "")
  22. self.oneFileForPageComboBox.font = .SFProTextSemiboldFont(12)
  23. self.oneFileForPageComboBox.setTitleColor(color: NSColor.km_init(hex: "#616469"))
  24. self.onlyGetTableVC = KMDesignButton.init(withType: .CheckBox)
  25. self.onlyGetTableBox.contentView = self.onlyGetTableVC!.view
  26. self.onlyGetTableVC?.target = self
  27. self.onlyGetTableVC?.action = #selector(self.radioAction(sender:))
  28. self.tipView?.km_add_left_constraint(constant: 8)
  29. self.tipView?.km_add_top_constraint(equalTo: self.pageRangeBox, attribute: .bottom, constant: -5)
  30. self.tipView?.km_add_right_constraint()
  31. self.tipView?.km_add_height_constraint(constant: 16+20+16)
  32. }
  33. override func initDefaultVlaue() {
  34. super.initDefaultVlaue()
  35. self.onlyGetTableBox.fillColor = .clear
  36. self.onlyGetTableVC?.stringValue = NSLocalizedString("Only Table", comment: "")
  37. }
  38. override func viewDidMoveToWindow() {
  39. super.viewDidMoveToWindow()
  40. if (self.pageRangeItemView == nil) {
  41. self.pageRangeItemView = KMConvertPageRangeSettingItemView.createFromNib()
  42. self.pageRangeBox.contentView = self.pageRangeItemView
  43. }
  44. self.pageRangeItemView?.isHidden = self.isBatch
  45. }
  46. @objc func radioAction(sender: NSButton) {
  47. for radio in [self.onlyGetTableVC] {
  48. if ((radio?.button.isEqual(to: sender))!) {
  49. if radio?.state == .Checked {
  50. radio?.state = .Norm
  51. } else {
  52. radio?.state = .Checked
  53. }
  54. }
  55. }
  56. if let state = self.onlyGetTableVC?.state, state == .Checked {
  57. self.selectedSettingIndex = 1
  58. } else {
  59. self.selectedSettingIndex = 0
  60. }
  61. }
  62. }