// // IdentifyPreferense.swift // PDF Reader Pro // // Created by Niehaoyu on 2024/6/28. // import Cocoa class IdentifyPreferense: NSViewController { @IBOutlet var contendView: NSView! @IBOutlet var loginLabel: NSTextField! @IBOutlet var loginValueLabel: NSTextField! @IBOutlet var nameLabel: NSTextField! @IBOutlet var nameField: NSTextField! @IBOutlet var headNameLabel: NSTextField! @IBOutlet var headNameField: NSTextField! @IBOutlet var organizeNameLabel: NSTextField! @IBOutlet var organizeNameField: NSTextField! @IBOutlet var organizePartLabel: NSTextField! @IBOutlet var organizePartField: NSTextField! @IBOutlet var emailLabel: NSTextField! @IBOutlet var emailField: NSTextField! @IBOutlet var descriptionLabel: NSTextField! override var nibName: NSNib.Name? { return "IdentifyPreferense" } override func loadView() { super.loadView() } override func viewDidLoad() { super.viewDidLoad() // Do view setup here. let loginName = NSFullUserName() if loginName.isEmpty == false { self.loginValueLabel.stringValue = loginName } else { self.loginValueLabel.stringValue = "" } self.loginLabel.stringValue = NSLocalizedString("Login Name", comment: "") + ":" self.nameLabel.stringValue = NSLocalizedString("Name", comment: "") + ":" self.headNameLabel.stringValue = NSLocalizedString("Title", comment: "") + ":" self.organizeNameLabel.stringValue = NSLocalizedString("Organization Name", comment: "") + ":" self.organizePartLabel.stringValue = NSLocalizedString("Organization Unit", comment: "") + ":" self.emailLabel.stringValue = NSLocalizedString("Email Address", comment: "") + ":" self.descriptionLabel.stringValue = NSLocalizedString("Your identifying information will be used for annotations, comments, and digital signatures. The information will only be used for this program and will not be transmitted outside without your permission.", comment: "") self.nameField.stringValue = KMProfileInfo.shared().fullName self.headNameField.stringValue = KMProfileInfo.shared().headName self.organizeNameField.stringValue = KMProfileInfo.shared().OrganizeName self.organizePartField.stringValue = KMProfileInfo.shared().OrganizePart self.emailField.stringValue = KMProfileInfo.shared().email // self.nameField.font = NSFont.SFProTextRegularFont(14) // self.headNameField.font = NSFont.SFProTextRegularFont(14) // self.organizeNameField.font = NSFont.SFProTextRegularFont(14) // self.organizePartField.font = NSFont.SFProTextRegularFont(14) // self.emailField.font = NSFont.SFProTextRegularFont(14) // self.descriptionLabel.font = NSFont.SFProTextRegularFont(14) self.nameField.textColor = KMAppearance.Layout.h0Color() self.headNameField.textColor = KMAppearance.Layout.h0Color() self.organizeNameField.textColor = KMAppearance.Layout.h0Color() self.organizePartField.textColor = KMAppearance.Layout.h0Color() self.emailField.textColor = KMAppearance.Layout.h0Color() self.descriptionLabel.textColor = KMAppearance.Layout.h0Color() self.nameField.delegate = self self.headNameField.delegate = self self.organizeNameField.delegate = self self.organizePartField.delegate = self self.emailField.delegate = self } override var title: String? { set { super.title = newValue } get { return KMLocalizedString("Identity", "Preference pane label") } } } extension IdentifyPreferense: KMPreferencePane { func defaultsDidRevert() { self.nameField.stringValue = KMProfileInfo.shared().fullName self.headNameField.stringValue = KMProfileInfo.shared().headName self.organizeNameField.stringValue = KMProfileInfo.shared().OrganizeName self.organizePartField.stringValue = KMProfileInfo.shared().OrganizePart self.emailField.stringValue = KMProfileInfo.shared().email } } extension IdentifyPreferense: NSTextFieldDelegate { func controlTextDidEndEditing(_ obj: Notification) { if let textView = obj.object as? NSTextField, textView == self.nameField { KMProfileInfo.shared().fullName = self.nameField.stringValue } else if let textView = obj.object as? NSTextField, textView == self.headNameField { KMProfileInfo.shared().headName = self.headNameField.stringValue } else if let textView = obj.object as? NSTextField, textView == self.organizeNameField { KMProfileInfo.shared().OrganizeName = self.organizeNameField.stringValue } else if let textView = obj.object as? NSTextField, textView == self.organizePartField { KMProfileInfo.shared().OrganizePart = self.organizePartField.stringValue } else if let textView = obj.object as? NSTextField, textView == self.emailField { KMProfileInfo.shared().email = self.emailField.stringValue } } }