123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- //
- // KMConvertJsonSettingView.swift
- // PDF Reader Pro
- //
- // Created by User-Tangchao on 2024/10/29.
- //
- import Cocoa
- import KMComponentLibrary
- class KMConvertJsonSettingView: KMConvertSettingView {
- @IBOutlet weak var setBox: NSBox!
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var extractTextRadio: ComponentRadio!
- @IBOutlet weak var extactTableRadio: ComponentRadio!
- @IBOutlet weak var ocrBox: NSBox!
- @IBOutlet weak var pageRangeBox: NSBox!
-
- var extractIndex = 0
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- static func json_createFromNib(in bundle: Bundle = Bundle.main) -> Self? {
- let nibName = "KMConvertJsonSettingView"
- var topLevelArray: NSArray? = nil
- bundle.loadNibNamed(NSNib.Name(nibName), owner: nil, topLevelObjects: &topLevelArray)
- guard let results = topLevelArray else { return nil }
- let views = Array<Any>(results).filter { $0 is Self }
- return views.last as? Self
- }
-
- override func initSubViews() {
- super.initSubViews()
-
- extractTextRadio.properties = ComponentCheckBoxProperty(size: .s,
- state: .normal,
- isDisabled: false,
- showhelp: false,
- text: NSLocalizedString("Extract Text", comment: ""),
- checkboxType: .normal)
- extractTextRadio.setTarget(self, action: #selector(radioAction))
-
- extactTableRadio.properties = ComponentCheckBoxProperty(size: .s,
- state: .normal,
- isDisabled: false,
- showhelp: false,
- text: NSLocalizedString("Extract Tables", comment: ""),
- checkboxType: .normal)
- extactTableRadio.setTarget(self, action: #selector(radioAction))
-
- self.radioAction(sender: self.extractTextRadio)
- }
-
- override func initDefaultVlaue() {
- super.initDefaultVlaue()
-
- self.titleLabel.stringValue = NSLocalizedString("Json Worksheet Settings", comment: "")
- self.titleLabel.textColor = NSColor.km_init(hex: "#616469")
- self.titleLabel.font = .SFProTextRegularFont(12)
-
- self.setBox.borderWidth = 0
- self.ocrBox.borderWidth = 0
- self.pageRangeBox.borderWidth = 0
- }
-
- override func viewDidMoveToWindow() {
- super.viewDidMoveToWindow()
-
- if (self.ocrItemView == nil) {
- self.ocrItemView = KMConvertOCRSettingItemView.createFromNib()
- self.ocrBox.contentView = self.ocrItemView
- }
- self.ocrItemView?.languageIndex = self.ocrLanuguageIndex
- if (self.pageRangeItemView == nil) {
- self.pageRangeItemView = KMConvertPageRangeSettingItemView.createFromNib()
- self.pageRangeBox.contentView = self.pageRangeItemView
- }
- }
-
- @objc func radioAction(sender: ComponentRadio) {
- for radio in [self.extractTextRadio, self.extactTableRadio] {
- if sender.isEqual(to: radio) {
- radio?.properties.checkboxType = .selected
- } else {
- radio?.properties.checkboxType = .normal
- }
- radio?.reloadData()
- }
-
- if sender.isEqual(to: self.extractTextRadio) {
- self.extractIndex = 0
- } else if sender.isEqual(to: self.extactTableRadio) {
- self.extractIndex = 1
- }
- }
- }
|