IdentifyPreferense.swift 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // IdentifyPreferense.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/6/28.
  6. //
  7. import Cocoa
  8. class IdentifyPreferense: NSViewController {
  9. @IBOutlet var contendView: NSView!
  10. @IBOutlet var loginLabel: NSTextField!
  11. @IBOutlet var loginValueLabel: NSTextField!
  12. @IBOutlet var nameLabel: NSTextField!
  13. @IBOutlet var nameField: NSTextField!
  14. @IBOutlet var headNameLabel: NSTextField!
  15. @IBOutlet var headNameField: NSTextField!
  16. @IBOutlet var organizeNameLabel: NSTextField!
  17. @IBOutlet var organizeNameField: NSTextField!
  18. @IBOutlet var organizePartLabel: NSTextField!
  19. @IBOutlet var organizePartField: NSTextField!
  20. @IBOutlet var emailLabel: NSTextField!
  21. @IBOutlet var emailField: NSTextField!
  22. @IBOutlet var descriptionLabel: NSTextField!
  23. override var nibName: NSNib.Name? {
  24. return "IdentifyPreferense"
  25. }
  26. override func loadView() {
  27. super.loadView()
  28. }
  29. override func viewDidLoad() {
  30. super.viewDidLoad()
  31. // Do view setup here.
  32. let loginName = NSFullUserName()
  33. if loginName.isEmpty == false {
  34. self.loginValueLabel.stringValue = loginName
  35. } else {
  36. self.loginValueLabel.stringValue = ""
  37. }
  38. self.loginLabel.stringValue = NSLocalizedString("Login Name", comment: "") + ":"
  39. self.nameLabel.stringValue = NSLocalizedString("Name", comment: "") + ":"
  40. self.headNameLabel.stringValue = NSLocalizedString("Title", comment: "") + ":"
  41. self.organizeNameLabel.stringValue = NSLocalizedString("Organization Name", comment: "") + ":"
  42. self.organizePartLabel.stringValue = NSLocalizedString("Organization Unit", comment: "") + ":"
  43. self.emailLabel.stringValue = NSLocalizedString("Email Address", comment: "") + ":"
  44. 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: "")
  45. self.nameField.stringValue = KMProfileInfo.shared().fullName
  46. self.headNameField.stringValue = KMProfileInfo.shared().headName
  47. self.organizeNameField.stringValue = KMProfileInfo.shared().OrganizeName
  48. self.organizePartField.stringValue = KMProfileInfo.shared().OrganizePart
  49. self.emailField.stringValue = KMProfileInfo.shared().email
  50. // self.nameField.font = NSFont.SFProTextRegularFont(14)
  51. // self.headNameField.font = NSFont.SFProTextRegularFont(14)
  52. // self.organizeNameField.font = NSFont.SFProTextRegularFont(14)
  53. // self.organizePartField.font = NSFont.SFProTextRegularFont(14)
  54. // self.emailField.font = NSFont.SFProTextRegularFont(14)
  55. // self.descriptionLabel.font = NSFont.SFProTextRegularFont(14)
  56. self.nameField.textColor = KMAppearance.Layout.h0Color()
  57. self.headNameField.textColor = KMAppearance.Layout.h0Color()
  58. self.organizeNameField.textColor = KMAppearance.Layout.h0Color()
  59. self.organizePartField.textColor = KMAppearance.Layout.h0Color()
  60. self.emailField.textColor = KMAppearance.Layout.h0Color()
  61. self.descriptionLabel.textColor = KMAppearance.Layout.h0Color()
  62. self.nameField.delegate = self
  63. self.headNameField.delegate = self
  64. self.organizeNameField.delegate = self
  65. self.organizePartField.delegate = self
  66. self.emailField.delegate = self
  67. }
  68. override var title: String? {
  69. set {
  70. super.title = newValue
  71. }
  72. get {
  73. return KMLocalizedString("Identity", "Preference pane label")
  74. }
  75. }
  76. }
  77. extension IdentifyPreferense: KMPreferencePane {
  78. func defaultsDidRevert() {
  79. self.nameField.stringValue = KMProfileInfo.shared().fullName
  80. self.headNameField.stringValue = KMProfileInfo.shared().headName
  81. self.organizeNameField.stringValue = KMProfileInfo.shared().OrganizeName
  82. self.organizePartField.stringValue = KMProfileInfo.shared().OrganizePart
  83. self.emailField.stringValue = KMProfileInfo.shared().email
  84. }
  85. }
  86. extension IdentifyPreferense: NSTextFieldDelegate {
  87. func controlTextDidEndEditing(_ obj: Notification) {
  88. if let textView = obj.object as? NSTextField, textView == self.nameField {
  89. KMProfileInfo.shared().fullName = self.nameField.stringValue
  90. } else if let textView = obj.object as? NSTextField, textView == self.headNameField {
  91. KMProfileInfo.shared().headName = self.headNameField.stringValue
  92. } else if let textView = obj.object as? NSTextField, textView == self.organizeNameField {
  93. KMProfileInfo.shared().OrganizeName = self.organizeNameField.stringValue
  94. } else if let textView = obj.object as? NSTextField, textView == self.organizePartField {
  95. KMProfileInfo.shared().OrganizePart = self.organizePartField.stringValue
  96. } else if let textView = obj.object as? NSTextField, textView == self.emailField {
  97. KMProfileInfo.shared().email = self.emailField.stringValue
  98. }
  99. }
  100. }