KMPageEditExtractSettingView.swift 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // KMPageEditExtractSettingView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/1/12.
  6. //
  7. class KMPageEditExtractSettingView: KMPageEditSettingBaseView {
  8. @IBOutlet weak var independentPerPageCheck: NSButton!
  9. @IBOutlet weak var extractAfterDeletePageCheck: NSButton!
  10. private var independentPerPageVC: KMDesignButton?
  11. private var _extractAfterDeletePageVC: KMDesignButton?
  12. var extractAfterDeletePageVC: KMDesignButton? {
  13. get {
  14. return self._extractAfterDeletePageVC
  15. }
  16. }
  17. var independentPerPageValue: Bool {
  18. get {
  19. if let state = self.independentPerPageVC?.state {
  20. return state == .Checked
  21. }
  22. return false
  23. }
  24. }
  25. var extractAfterDeletePageValue: Bool {
  26. get {
  27. if let state = self.extractAfterDeletePageVC?.state {
  28. return state == .Checked
  29. }
  30. return false
  31. }
  32. }
  33. override func awakeFromNib() {
  34. super.awakeFromNib()
  35. self.independentPerPageVC = KMDesignButton(withType: .CheckBox)
  36. self.independentPerPageCheck.addSubview(self.independentPerPageVC!.view)
  37. self.independentPerPageVC?.view.frame = self.independentPerPageCheck.bounds
  38. self.independentPerPageVC?.view.autoresizingMask = [.width, .height]
  39. self.independentPerPageVC?.target = self
  40. self.independentPerPageVC?.action = #selector(independentPerPageAction)
  41. self.independentPerPageVC?.stringValue = NSLocalizedString("Each page in a separate file", comment: "")
  42. self.independentPerPageVC?.checkbox_radio()
  43. self._extractAfterDeletePageVC = KMDesignButton(withType: .CheckBox)
  44. self.extractAfterDeletePageCheck.addSubview(self.extractAfterDeletePageVC!.view)
  45. self.extractAfterDeletePageVC?.view.frame = self.extractAfterDeletePageCheck.bounds
  46. self.extractAfterDeletePageVC?.view.autoresizingMask = [.width, .height]
  47. self.extractAfterDeletePageVC?.target = self
  48. self.extractAfterDeletePageVC?.action = #selector(extractAfterDeletePageAction)
  49. self.extractAfterDeletePageVC?.stringValue = NSLocalizedString("Delete pages after extraction", comment: "")
  50. self.extractAfterDeletePageVC?.checkbox_radio()
  51. }
  52. @objc private func independentPerPageAction() {
  53. if let state = self.independentPerPageVC?.state {
  54. self.independentPerPageVC?.state = state == .Checked ? .Norm : .Checked
  55. } else {
  56. self.independentPerPageVC?.state = .Norm
  57. }
  58. guard let callback = self.itemClick else {
  59. return
  60. }
  61. var value = false
  62. if let state = self.independentPerPageVC?.state {
  63. value = state == .Checked
  64. }
  65. callback(1, value)
  66. }
  67. @objc private func extractAfterDeletePageAction() {
  68. if let state = self.extractAfterDeletePageVC?.state {
  69. self.extractAfterDeletePageVC?.state = state == .Checked ? .Norm : .Checked
  70. } else {
  71. self.extractAfterDeletePageVC?.state = .Norm
  72. }
  73. guard let callback = self.itemClick else {
  74. return
  75. }
  76. var value = false
  77. if let state = self.extractAfterDeletePageVC?.state {
  78. value = state == .Checked
  79. }
  80. callback(2, value)
  81. }
  82. }