Browse Source

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

jiajie 1 year ago
parent
commit
5117017780
19 changed files with 1153 additions and 1095 deletions
  1. 24 10
      PDF Office/PDF Master.xcodeproj/project.pbxproj
  2. 0 32
      PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 2 2
      PDF Office/PDF Master/Class/Common/Category/NSUserDefaultsController+KMExtension.swift
  4. 59 6
      PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift
  5. 1 0
      PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.xib
  6. 16 1
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift
  7. 23 17
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift
  8. 7 6
      PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.xib
  9. 354 0
      PDF Office/PDF Master/Class/PDFTools/SelfSign/Tools/KMProfileInfo.swift
  10. 0 21
      PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.h
  11. 0 917
      PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.m
  12. 606 0
      PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift
  13. 5 5
      PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.xib
  14. 6 0
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  15. 3 1
      PDF Office/PDF Master/Class/Preference/Controller/KMDisplayPreferences.swift
  16. 7 12
      PDF Office/PDF Master/Class/Preference/Controller/KMGeneralPreferences.swift
  17. 3 1
      PDF Office/PDF Master/Class/Preference/Controller/KMNotesPreferences.swift
  18. 37 62
      PDF Office/PDF Master/Class/Preference/Window/KMPreferenceController.swift
  19. 0 2
      PDF Office/PDF Master/PDF_Master-Bridging-Header.h

+ 24 - 10
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -2261,9 +2261,6 @@
 		BB2F615B2966B69D001CB369 /* KMWatermarkPropertyHomeController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */; };
 		BB2F615C2966B69D001CB369 /* KMWatermarkPropertyHomeController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */; };
 		BB2F615D2966B69D001CB369 /* KMWatermarkPropertyHomeController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */; };
-		BB2F9AA32AFC8D5A00F9DD93 /* KMProfileInfoWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AA02AFC8D5900F9DD93 /* KMProfileInfoWindowController.m */; };
-		BB2F9AA42AFC8D5A00F9DD93 /* KMProfileInfoWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AA02AFC8D5900F9DD93 /* KMProfileInfoWindowController.m */; };
-		BB2F9AA52AFC8D5A00F9DD93 /* KMProfileInfoWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AA02AFC8D5900F9DD93 /* KMProfileInfoWindowController.m */; };
 		BB2F9AA62AFC8D5A00F9DD93 /* KMProfileInfoWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F9AA22AFC8D5900F9DD93 /* KMProfileInfoWindowController.xib */; };
 		BB2F9AA72AFC8D5A00F9DD93 /* KMProfileInfoWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F9AA22AFC8D5900F9DD93 /* KMProfileInfoWindowController.xib */; };
 		BB2F9AA82AFC8D5A00F9DD93 /* KMProfileInfoWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F9AA22AFC8D5900F9DD93 /* KMProfileInfoWindowController.xib */; };
@@ -2273,6 +2270,12 @@
 		BB2F9AAF2AFCAE1F00F9DD93 /* KMProfileTitleCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AAE2AFCAE1F00F9DD93 /* KMProfileTitleCellView.swift */; };
 		BB2F9AB02AFCAE1F00F9DD93 /* KMProfileTitleCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AAE2AFCAE1F00F9DD93 /* KMProfileTitleCellView.swift */; };
 		BB2F9AB12AFCAE1F00F9DD93 /* KMProfileTitleCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AAE2AFCAE1F00F9DD93 /* KMProfileTitleCellView.swift */; };
+		BB2F9AB32AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AB22AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift */; };
+		BB2F9AB42AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AB22AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift */; };
+		BB2F9AB52AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AB22AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift */; };
+		BB2F9AB82AFCC3AD00F9DD93 /* KMProfileInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AB72AFCC3AD00F9DD93 /* KMProfileInfo.swift */; };
+		BB2F9AB92AFCC3AD00F9DD93 /* KMProfileInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AB72AFCC3AD00F9DD93 /* KMProfileInfo.swift */; };
+		BB2F9ABA2AFCC3AD00F9DD93 /* KMProfileInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2F9AB72AFCC3AD00F9DD93 /* KMProfileInfo.swift */; };
 		BB3198122AC5142900107371 /* NSMenu+KMExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3198112AC5142900107371 /* NSMenu+KMExtension.swift */; };
 		BB3198132AC5142900107371 /* NSMenu+KMExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3198112AC5142900107371 /* NSMenu+KMExtension.swift */; };
 		BB3198142AC5142900107371 /* NSMenu+KMExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3198112AC5142900107371 /* NSMenu+KMExtension.swift */; };
@@ -4527,11 +4530,11 @@
 		BB2F614F2966A91D001CB369 /* KMBackgroundPropertyHomeController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMBackgroundPropertyHomeController.xib; sourceTree = "<group>"; };
 		BB2F61562966B69D001CB369 /* KMWatermarkPropertyHomeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWatermarkPropertyHomeController.swift; sourceTree = "<group>"; };
 		BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMWatermarkPropertyHomeController.xib; sourceTree = "<group>"; };
-		BB2F9AA02AFC8D5900F9DD93 /* KMProfileInfoWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMProfileInfoWindowController.m; sourceTree = "<group>"; };
-		BB2F9AA12AFC8D5900F9DD93 /* KMProfileInfoWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMProfileInfoWindowController.h; sourceTree = "<group>"; };
 		BB2F9AA22AFC8D5900F9DD93 /* KMProfileInfoWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMProfileInfoWindowController.xib; sourceTree = "<group>"; };
 		BB2F9AAA2AFCADA900F9DD93 /* KMProfileCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMProfileCellView.swift; sourceTree = "<group>"; };
 		BB2F9AAE2AFCAE1F00F9DD93 /* KMProfileTitleCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMProfileTitleCellView.swift; sourceTree = "<group>"; };
+		BB2F9AB22AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMProfileInfoWindowController.swift; sourceTree = "<group>"; };
+		BB2F9AB72AFCC3AD00F9DD93 /* KMProfileInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMProfileInfo.swift; sourceTree = "<group>"; };
 		BB3198112AC5142900107371 /* NSMenu+KMExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMenu+KMExtension.swift"; sourceTree = "<group>"; };
 		BB3198152AC55E6D00107371 /* CPDFDocument+KMExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFDocument+KMExtension.swift"; sourceTree = "<group>"; };
 		BB3198192AC567B500107371 /* CPDFSelection+PDFListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFSelection+PDFListView.swift"; sourceTree = "<group>"; };
@@ -7818,6 +7821,7 @@
 		BB2F9A9E2AFC8D1100F9DD93 /* SelfSign */ = {
 			isa = PBXGroup;
 			children = (
+				BB2F9AB62AFCC39800F9DD93 /* Tools */,
 				BB2F9AA92AFCAB1A00F9DD93 /* View */,
 				BB2F9A9F2AFC8D1100F9DD93 /* Window */,
 			);
@@ -7827,8 +7831,7 @@
 		BB2F9A9F2AFC8D1100F9DD93 /* Window */ = {
 			isa = PBXGroup;
 			children = (
-				BB2F9AA12AFC8D5900F9DD93 /* KMProfileInfoWindowController.h */,
-				BB2F9AA02AFC8D5900F9DD93 /* KMProfileInfoWindowController.m */,
+				BB2F9AB22AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift */,
 				BB2F9AA22AFC8D5900F9DD93 /* KMProfileInfoWindowController.xib */,
 			);
 			path = Window;
@@ -7843,6 +7846,14 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		BB2F9AB62AFCC39800F9DD93 /* Tools */ = {
+			isa = PBXGroup;
+			children = (
+				BB2F9AB72AFCC3AD00F9DD93 /* KMProfileInfo.swift */,
+			);
+			path = Tools;
+			sourceTree = "<group>";
+		};
 		BB32BF212A5EA02900D11348 /* Analytics */ = {
 			isa = PBXGroup;
 			children = (
@@ -11028,7 +11039,6 @@
 				AD68782129A5FADC005B5210 /* KMLightMemberCache.swift in Sources */,
 				AD8F06172999DB5900D93CBC /* KMPrintDrawPage.swift in Sources */,
 				BB14702F299DC0D100784A6A /* OIDTokenUtilities.m in Sources */,
-				BB2F9AA32AFC8D5A00F9DD93 /* KMProfileInfoWindowController.m in Sources */,
 				89752E042939DB42003FF08E /* KMToolbarViewController.swift in Sources */,
 				BB146FD5299DC0D100784A6A /* GTLRObject.m in Sources */,
 				8942F7F02926087200389627 /* KMSearchViewController.swift in Sources */,
@@ -11037,6 +11047,7 @@
 				9F1FE4AE29406E4700E952CA /* CTPresentationModeController.m in Sources */,
 				BB146FC0299DC0D100784A6A /* GTMSessionFetcherLogging.m in Sources */,
 				AD1CA4212A061D190070541F /* KMAnnotationScreenAuthorViewItem.swift in Sources */,
+				BB2F9AB82AFCC3AD00F9DD93 /* KMProfileInfo.swift in Sources */,
 				BBC3481C295593F0008D2CD1 /* KMBackgroundListController.swift in Sources */,
 				9F5664872988B16F00020985 /* KMTextfieldVC.swift in Sources */,
 				9F1F82DA292F84D60092C4B4 /* KMHomeInsertActionViewController.swift in Sources */,
@@ -11289,6 +11300,7 @@
 				BBB9B31C299A5D6D004F3235 /* KMCloudOperation.m in Sources */,
 				BB981E592AD4F70D001988CA /* KMWelcomeWindowController.swift in Sources */,
 				BB8B173C2907CDD9001C5EA5 /* NibLoadable.swift in Sources */,
+				BB2F9AB32AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift in Sources */,
 				ADE3C1AB29A4779E00793B13 /* KMPrintAccessoryController.swift in Sources */,
 				BB8F4557295AA1270037EA22 /* KMHeaderFooterPropertyInfoController.swift in Sources */,
 				BB6347C42AF24F6300F5438E /* KMBatchoperateConvertCollectionViewItem.swift in Sources */,
@@ -12059,7 +12071,6 @@
 				ADD1B6B829420B2300C3FFF7 /* KMPrintChooseView.swift in Sources */,
 				9FCFEC9D2AD152FA00EAD2CB /* CustomAlertView.swift in Sources */,
 				BB147000299DC0D100784A6A /* OIDRedirectHTTPHandler.m in Sources */,
-				BB2F9AA42AFC8D5A00F9DD93 /* KMProfileInfoWindowController.m in Sources */,
 				BB147003299DC0D100784A6A /* OIDScopeUtilities.m in Sources */,
 				AD867FA729DFB77500F00440 /* KMAnnotationOutlineView.swift in Sources */,
 				BBB9B32C299A5D6D004F3235 /* GTMOAuth2KeychainCompatibility.m in Sources */,
@@ -12108,6 +12119,7 @@
 				BB897225294B07960045787C /* KMWatermarkAdjectiveTopBarItemView.swift in Sources */,
 				ADDEEA6F2AD3E16100EF675D /* KMSigntureViewItem.swift in Sources */,
 				BB14703F299DC0D200784A6A /* OIDEndSessionResponse.m in Sources */,
+				BB2F9AB42AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift in Sources */,
 				BBFE6E802930EBD400142C01 /* KMCompressWindowController.swift in Sources */,
 				ADAFDA572AEB451600F084BC /* KMHomeContentView.swift in Sources */,
 				BBFE6E66293097A600142C01 /* KMPageRangePickerWindowController.swift in Sources */,
@@ -12173,6 +12185,7 @@
 				ADE8BC3F29F9458700570F89 /* KMRecommondInfo.m in Sources */,
 				ADDEEA672AD3C4BE00EF675D /* KMPDFSignatureImageView.swift in Sources */,
 				ADDEEA732AD3EFE200EF675D /* KMButton.swift in Sources */,
+				BB2F9AB92AFCC3AD00F9DD93 /* KMProfileInfo.swift in Sources */,
 				BB146FE5299DC0D100784A6A /* GTLRURITemplate.m in Sources */,
 				9F1FE4F129406E4700E952CA /* BackgroundGradientView.m in Sources */,
 				89E4E6E42963CD82002DBA6F /* KMGeneralAnnotationViewController.m in Sources */,
@@ -12307,6 +12320,7 @@
 				BBC745F9296178BD0072C2ED /* KMCropTools.swift in Sources */,
 				ADBC2D21299CDA29006280C8 /* NSView+Layer.swift in Sources */,
 				BB65A06D2AF8D8A1003A27A0 /* KMNotesPreferences.swift in Sources */,
+				BB2F9ABA2AFCC3AD00F9DD93 /* KMProfileInfo.swift in Sources */,
 				BB003028298CF7EC002DD1A0 /* KMPreferenceDisplayController.swift in Sources */,
 				9F0CB48929683DC400007028 /* KMPropertiesPanelPresetColorSubVC.swift in Sources */,
 				BB99ACC4292DE22E0048AFD9 /* KMMergeViewController.swift in Sources */,
@@ -12380,6 +12394,7 @@
 				BB147034299DC0D200784A6A /* OIDTokenResponse.m in Sources */,
 				BBB14A592978E75D00936EDB /* KMRedactMutilPageFlagWindowController.swift in Sources */,
 				9FCFEC8E2AD10A4400EAD2CB /* KMTextFieldSheetController.swift in Sources */,
+				BB2F9AB52AFCC2F800F9DD93 /* KMProfileInfoWindowController.swift in Sources */,
 				BB1BFF942AEA6352003EB179 /* KMImageToPDFMethod.swift in Sources */,
 				899700E128F3A9F2009AF911 /* KMHomeWindowController.swift in Sources */,
 				BB9DCCA12A0A2B0A0024A6F1 /* KMConvertSettingView.swift in Sources */,
@@ -12474,7 +12489,6 @@
 				9FCFEC762AC56ECE00EAD2CB /* CPDFListStampAnnotation.swift in Sources */,
 				BBA388152AEF9A42004FE93F /* NSWindow+KMExtension.swift in Sources */,
 				9FD0D2A92AD4EFB000DA3FF8 /* KMSavePanelAccessoryController.swift in Sources */,
-				BB2F9AA52AFC8D5A00F9DD93 /* KMProfileInfoWindowController.m in Sources */,
 				9F1FE4D129406E4700E952CA /* CTTabController.m in Sources */,
 				9F8539E029470A0700DF644E /* KMTabStripView.swift in Sources */,
 				BBA8B7AC2935DC120097D183 /* KMRemovePasswordResultTipView.swift in Sources */,

+ 0 - 32
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -452,37 +452,5 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "4D93AA09-0E5B-4BA4-8FA1-A4C5CD46424B"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/Preference/Controller/KMGeneralPreferences.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "317"
-            endingLineNumber = "317"
-            landmarkName = "defaultsDidRevert()"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "C2E1DBEB-7852-4C5E-B4FB-F109704A80B7"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/Preference/Window/KMPreferenceController.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "460"
-            endingLineNumber = "460"
-            landmarkName = "_resetCurrentSheetDidEnd(_:_:_:)"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 2 - 2
PDF Office/PDF Master/Class/Common/Category/NSUserDefaultsController+KMExtension.swift

@@ -28,8 +28,8 @@ extension NSUserDefaultsController {
         self.removeObserver(anObserver, forKeyPath: "values.\(key)")
     }
     
-    @objc func revertToInitialValues(forKeys keys: [String]) {
-        for key in keys {
+    @objc func revertToInitialValues(forKeys keys: [String]?) {
+        for key in keys ?? [] {
             (self.values as? NSMutableDictionary)?.setValue(self.initialValues?[key], forKey: key)
         }
     }

+ 59 - 6
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift

@@ -16,6 +16,11 @@ typealias KMHomeContentViewQucikToolsDidSelect = (_ view: KMHomeContentView, _ i
 typealias KMHomeContentViewQucikToolsAddAction = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
 typealias KMHomeContentViewQucikToolsRemoveAction = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void
 
+enum KMHomeQucikToolsShowType {
+    case expand
+    case collapse
+}
+
 class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var qucikToolsLabel: NSTextField!
     @IBOutlet weak var qucikToolsView: KMQucikToolsView!
@@ -23,6 +28,7 @@ class KMHomeContentView: KMBaseXibView {
     @IBOutlet weak var pageLabel: NSTextField!
     @IBOutlet weak var rightButton: NSButton!
     @IBOutlet weak var moreButton: KMButton!
+    @IBOutlet weak var qucikToolsConstraintHeight: NSLayoutConstraint!
     
     
     @IBOutlet weak var recentlyLabel: NSTextField!
@@ -40,6 +46,17 @@ class KMHomeContentView: KMBaseXibView {
     var qucikToolsAddAction: KMHomeContentViewQucikToolsAddAction?
     var qucikToolsRemoveAction: KMHomeContentViewQucikToolsRemoveAction?
     
+    var qucikToolsType: KMHomeQucikToolsShowType = .expand {
+        didSet {
+            self.qucikToolsView.type = qucikToolsType
+            if qucikToolsType == .collapse {
+                self.qucikToolsConstraintHeight.constant = 166
+            } else {
+                self.qucikToolsConstraintHeight.constant = 262
+            }
+        }
+    }
+    
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
 
@@ -131,13 +148,45 @@ extension KMHomeContentView {
         self.qucikToolsView.nextPage()
     }
     
-    @IBAction func moreButtonAction(_ sender: Any) {
-        let homeQuickToolsWindowController: KMHomeQuickToolsWindowController = KMHomeQuickToolsWindowController.sharedHomeQuickTools
-        homeQuickToolsWindowController.window?.center()
-        NSWindow.currentWindow().addChildWindow(homeQuickToolsWindowController.window!, ordered: NSWindow.OrderingMode.above)
+    @IBAction func moreButtonAction(_ sender: NSButton) {
+        let collapse = NSLocalizedString("Collapse All", comment: "")
+        let quickTools = NSLocalizedString("Manage Quick Tools", comment: "")
+        let expand = NSLocalizedString("Expand All", comment: "")
+        
+        var array: [String] = []
+        if qucikToolsType == .expand {
+            array = [collapse, quickTools]
+        } else {
+            array = [expand, quickTools]
+        }
+        
+        let vc: KMHomePopViewController = KMHomePopViewController().initWithPopViewDataArr(array)
+        let createFilePopover: NSPopover = NSPopover.init()
+        createFilePopover.contentViewController = vc
+        createFilePopover.delegate = self
+        createFilePopover.animates = true
+        createFilePopover.behavior = .semitransient
+        createFilePopover.setValue(true, forKey: "shouldHideAnchor")
+        createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: 10, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
+        
+//        vc.customBoxWidthLayoutConstraint.constant = sender.frame.width
+        vc.downCallback = { [unowned self] (downEntered: Bool, count: String) -> Void in
+            if downEntered {
+                createFilePopover.close()
+                if count == collapse {
+                    self.qucikToolsType = .collapse
+                } else if count == expand {
+                    self.qucikToolsType = .expand
+                } else if count == quickTools {
+                    let homeQuickToolsWindowController: KMHomeQuickToolsWindowController = KMHomeQuickToolsWindowController.sharedHomeQuickTools
+                    homeQuickToolsWindowController.window?.center()
+                    NSWindow.currentWindow().addChildWindow(homeQuickToolsWindowController.window!, ordered: NSWindow.OrderingMode.above)
 
-        homeQuickToolsWindowController.dataChange = { [unowned self] controller in
-            self.qucikToolsView.reloadData()
+                    homeQuickToolsWindowController.dataChange = { [unowned self] controller in
+                        self.qucikToolsView.reloadData()
+                    }
+                }
+            }
         }
     }
     
@@ -157,3 +206,7 @@ extension KMHomeContentView {
         callBack(self)
     }
 }
+
+extension KMHomeContentView: NSPopoverDelegate {
+    
+}

+ 1 - 0
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.xib

@@ -14,6 +14,7 @@
                 <outlet property="leftButton" destination="WXY-wn-hPk" id="hp6-fa-w4J"/>
                 <outlet property="moreButton" destination="YVh-aT-yWA" id="M54-rm-tnw"/>
                 <outlet property="pageLabel" destination="AZq-VF-EUc" id="CCP-bH-lFT"/>
+                <outlet property="qucikToolsConstraintHeight" destination="TWz-4G-1dS" id="Xlt-SU-0we"/>
                 <outlet property="qucikToolsLabel" destination="FaJ-2q-2cQ" id="q0S-ez-pED"/>
                 <outlet property="qucikToolsView" destination="ynU-RA-kWD" id="t4n-b1-mpf"/>
                 <outlet property="recentlyLabel" destination="Jq6-Hl-amd" id="cL6-5Q-9jC"/>

+ 16 - 1
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/KMQucikToolsView.swift

@@ -20,6 +20,14 @@ class KMQucikToolsView: KMBaseXibView {
     var pageChange: KMQucikToolsViewPageChange?
     
     var data: [KMQucikToolsModel] = []
+    var type: KMHomeQucikToolsShowType = .expand {
+        didSet {
+            self.collectionView.reloadData()
+//            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
+//                self.collectionView.reloadData()
+//            }
+        }
+    }
     
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
@@ -110,6 +118,7 @@ extension KMQucikToolsView: NSCollectionViewDataSource {
             view.model = self.data[indexPath.item]
         }
         
+        view.type = type
         view.addAction = { [unowned self] view, item in
             self.addAction?(view, item)
         }
@@ -125,7 +134,13 @@ extension KMQucikToolsView: NSCollectionViewDataSource {
 extension KMQucikToolsView: NSCollectionViewDelegateFlowLayout {
     
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {
-        return NSSize(width: 216, height: 96)
+        if type == .collapse {
+            return NSSize(width: 172, height: 48)
+        } else if type == .expand {
+            return NSSize(width: 216, height: 96)
+        } else {
+            return NSSize(width: 216, height: 96)
+        }
     }
     
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, insetForSectionAt section: Int) -> NSEdgeInsets {

+ 23 - 17
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.swift

@@ -25,10 +25,18 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     @IBOutlet weak var tagView: NSView!
     @IBOutlet weak var tagLabel: NSTextField!
     
+    @IBOutlet weak var imageTopConstraint: NSLayoutConstraint!
+    @IBOutlet weak var handerViewTopConstraint: NSLayoutConstraint!
+    
     
     var addAction: KMQucikToolCollectionViewItemAddAction?
     var removeAction: KMQucikToolCollectionViewItemRemoveAction?
     
+    var type: KMHomeQucikToolsShowType = .expand {
+        didSet {
+            self.reloadData()
+        }
+    }
     var model: KMQucikToolsModel? {
         didSet {
             self.reloadData()
@@ -90,11 +98,16 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
                 self.titleLabel.textColor = KMAppearance.Layout.w0Color()
                 self.subTitleLabel.textColor = KMAppearance.Layout.w70Color()
                 self.iconImageView.image = model?.iconImage(true)
+                
+                guard let model = self.model else { return }
+                self.handleView.isHidden = !model.canAdd()
             } else {
                 self.contentBox.fillColor = KMAppearance.Layout.l1Color()
                 self.titleLabel.textColor = KMAppearance.Layout.h0Color()
                 self.subTitleLabel.textColor = KMAppearance.Layout.h1Color()
                 self.iconImageView.image = model?.iconImage(false)
+                
+                self.handleView.isHidden = true
             }
         }
         
@@ -106,6 +119,16 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     func reloadData() {
         guard let model = model else { return }
         
+        if type == .expand {
+            imageTopConstraint.constant = 20
+            handerViewTopConstraint.constant = 44
+            subTitleLabel.isHidden = false
+        } else {
+            imageTopConstraint.constant = 14
+            handerViewTopConstraint.constant = 8
+            subTitleLabel.isHidden = true
+        }
+        
         self.titleLabel.stringValue = model.titleString()
         self.subTitleLabel.stringValue = model.subTitleString()
         self.iconImageView.image = model.iconImage()
@@ -124,20 +147,3 @@ class KMQucikToolCollectionViewItem: NSCollectionViewItem {
     }
     
 }
-
-extension KMQucikToolCollectionViewItem {
-    override func mouseEntered(with event: NSEvent) {
-        self.view.backgroundColor(NSColor.green)
-        
-        
-        guard let model = self.model else { return }
-        self.handleView.isHidden = !model.canAdd()
-    }
-    
-    override func mouseExited(with event: NSEvent) {
-        self.view.backgroundColor(NSColor.red)
-        
-        self.handleView.isHidden = true
-    }
-    
-}

+ 7 - 6
PDF Office/PDF Master/Class/Home/View/HomeContentView/QucikTools/View/KMQucikToolCollectionViewItem.xib

@@ -12,8 +12,10 @@
                 <outlet property="addBox" destination="WpY-hX-Iuh" id="fMG-vu-eRc"/>
                 <outlet property="addButton" destination="Sfr-Rz-iNv" id="t4A-h4-K0f"/>
                 <outlet property="contentBox" destination="Mqk-nf-F6P" id="NYS-b5-WXO"/>
+                <outlet property="handerViewTopConstraint" destination="MMu-GC-USf" id="foB-IM-weq"/>
                 <outlet property="handleView" destination="5hE-EB-Fbu" id="26F-NC-WO7"/>
                 <outlet property="iconImageView" destination="Vlz-sL-oSP" id="B0h-Nl-Kpf"/>
+                <outlet property="imageTopConstraint" destination="pxK-L8-ix9" id="gln-rv-V3f"/>
                 <outlet property="removeBox" destination="4I9-UP-8io" id="MX1-8C-cop"/>
                 <outlet property="removeButton" destination="HWd-oT-cNf" id="ZKr-wg-jc0"/>
                 <outlet property="subTitleLabel" destination="xUh-Dj-kJH" id="Tpg-Qr-ffJ"/>
@@ -47,7 +49,7 @@
                                         <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="KMImageNameHomeBackground" id="5wv-kB-Bkg"/>
                                     </imageView>
                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CuI-0G-xl6">
-                                        <rect key="frame" x="42" y="57" width="42" height="17"/>
+                                        <rect key="frame" x="42" y="58" width="42" height="17"/>
                                         <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="wMS-Vz-yLV">
                                             <font key="font" metaFont="systemBold" size="14"/>
                                             <color key="textColor" name="KMGray6Color"/>
@@ -55,7 +57,7 @@
                                         </textFieldCell>
                                     </textField>
                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xUh-Dj-kJH">
-                                        <rect key="frame" x="42" y="19" width="160" height="34"/>
+                                        <rect key="frame" x="42" y="20" width="160" height="34"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="34" id="gc3-Ff-Nhi"/>
                                         </constraints>
@@ -109,7 +111,6 @@
                                                 </view>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="24" id="ZZ8-sN-RHF"/>
-                                                    <constraint firstAttribute="width" constant="88" id="mSV-Jb-zUY"/>
                                                 </constraints>
                                                 <color key="fillColor" white="1" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                             </box>
@@ -139,7 +140,6 @@
                                                 </view>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="24" id="L9o-vl-BZL"/>
-                                                    <constraint firstAttribute="width" constant="88" id="lQZ-xc-ZE5"/>
                                                 </constraints>
                                                 <color key="fillColor" white="1" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                             </box>
@@ -148,6 +148,7 @@
                                             <constraint firstAttribute="trailing" secondItem="4I9-UP-8io" secondAttribute="trailing" id="H7I-ef-a1Z"/>
                                             <constraint firstItem="WpY-hX-Iuh" firstAttribute="centerY" secondItem="5hE-EB-Fbu" secondAttribute="centerY" id="PCT-YL-AFj"/>
                                             <constraint firstItem="4I9-UP-8io" firstAttribute="leading" secondItem="WpY-hX-Iuh" secondAttribute="trailing" constant="8" id="chG-Dz-V3u"/>
+                                            <constraint firstItem="WpY-hX-Iuh" firstAttribute="width" secondItem="4I9-UP-8io" secondAttribute="width" id="dGf-z5-YOL"/>
                                             <constraint firstItem="4I9-UP-8io" firstAttribute="centerY" secondItem="WpY-hX-Iuh" secondAttribute="centerY" id="hCY-iE-6l4"/>
                                             <constraint firstItem="WpY-hX-Iuh" firstAttribute="leading" secondItem="5hE-EB-Fbu" secondAttribute="leading" id="hH9-RV-mUU"/>
                                         </constraints>
@@ -155,15 +156,15 @@
                                 </subviews>
                                 <constraints>
                                     <constraint firstAttribute="bottom" secondItem="5hE-EB-Fbu" secondAttribute="bottom" constant="8" id="D7T-JK-rEj"/>
+                                    <constraint firstItem="5hE-EB-Fbu" firstAttribute="top" secondItem="B7V-zv-Z6E" secondAttribute="top" constant="44" id="MMu-GC-USf"/>
                                     <constraint firstItem="xUh-Dj-kJH" firstAttribute="leading" secondItem="CuI-0G-xl6" secondAttribute="leading" id="N72-QY-RBz"/>
                                     <constraint firstItem="CuI-0G-xl6" firstAttribute="leading" secondItem="Vlz-sL-oSP" secondAttribute="trailing" constant="8" id="WfY-mk-msC"/>
-                                    <constraint firstItem="CuI-0G-xl6" firstAttribute="top" secondItem="B7V-zv-Z6E" secondAttribute="top" constant="22" id="YjZ-Fj-3Oa"/>
                                     <constraint firstItem="5hE-EB-Fbu" firstAttribute="leading" secondItem="B7V-zv-Z6E" secondAttribute="leading" constant="16" id="Z1n-qt-ohg"/>
                                     <constraint firstItem="xUh-Dj-kJH" firstAttribute="top" secondItem="CuI-0G-xl6" secondAttribute="bottom" constant="4" id="bxk-x0-9pl"/>
                                     <constraint firstAttribute="trailing" secondItem="5hE-EB-Fbu" secondAttribute="trailing" constant="16" id="fM1-OU-rRd"/>
-                                    <constraint firstItem="5hE-EB-Fbu" firstAttribute="top" secondItem="Vlz-sL-oSP" secondAttribute="bottom" constant="4" id="kxS-do-AqU"/>
                                     <constraint firstItem="Vlz-sL-oSP" firstAttribute="top" secondItem="B7V-zv-Z6E" secondAttribute="top" constant="20" id="pxK-L8-ix9"/>
                                     <constraint firstItem="Vlz-sL-oSP" firstAttribute="leading" secondItem="B7V-zv-Z6E" secondAttribute="leading" constant="16" id="s3q-BH-Q5c"/>
+                                    <constraint firstItem="CuI-0G-xl6" firstAttribute="centerY" secondItem="Vlz-sL-oSP" secondAttribute="centerY" id="zD0-2k-XCt"/>
                                     <constraint firstAttribute="trailing" secondItem="xUh-Dj-kJH" secondAttribute="trailing" constant="16" id="zX8-gf-kxj"/>
                                 </constraints>
                             </view>

+ 354 - 0
PDF Office/PDF Master/Class/PDFTools/SelfSign/Tools/KMProfileInfo.swift

@@ -0,0 +1,354 @@
+//
+//  KMProfileInfo.swift
+//  PDF Master
+//
+//  Created by tangchao on 2023/11/9.
+//
+
+import Cocoa
+
+private var _shared: KMProfileInfo?
+
+@objcMembers class KMProfileInfo: NSObject, NSCoding {
+    private static let KMProfileUnarchiveKey = "KMProfileUnarchiveKeyTemp1"
+    
+    private let KMProfileSaveInfoFullNameKey = "KMProfileSaveInfoFullNameKey"
+    private let KMProfileSaveInfoFirstNameKey = "KMProfileSaveInfoFirstNameKey"
+    private let KMProfileSaveInfoMiddleNameKey = "KMProfileSaveInfoMiddleNameKey"
+    private let KMProfileSaveInfoLastNameKey = "KMProfileSaveInfoLastNameKey"
+
+    private let KMProfileSaveInfoStreet1Key = "KMProfileSaveInfoStreet1Key"
+    private let KMProfileSaveInfoStreet2Key = "KMProfileSaveInfoStreet2Key"
+    private let KMProfileSaveInfoCityKey = "KMProfileSaveInfoCityKey"
+    private let KMProfileSaveInfoStateKey = "KMProfileSaveInfoStateKey"
+    private let KMProfileSaveInfoZipKey = "KMProfileSaveInfoZipKey"
+    private let KMProfileSaveInfoCountryKey = "KMProfileSaveInfoCountryKey"
+
+    private let KMProfileSaveInfoEmailKey = "KMProfileSaveInfoEmailKey"
+    private let KMProfileSaveInfoTelKey = "KMProfileSaveInfoTelKey"
+    private let KMProfileSaveInfoBirthDateKey = "KMProfileSaveInfoBirthDateKey"
+    private let KMProfileSaveInfoCustomInfoKey = "KMProfileSaveInfoCustomInfoKey"
+    
+    private var _fullName: String = ""
+    var fullName: String {
+        get {
+            return self._fullName
+        }
+        set {
+            if (self._fullName != newValue) {
+                self._fullName = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _firstName: String = ""
+    var firstName: String {
+        get {
+            return self._firstName
+        }
+        set {
+            if (self._firstName != newValue) {
+                self._firstName = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _middleName: String = ""
+    var middleName: String {
+        get {
+            return self._middleName
+        }
+        set {
+            if (self._middleName != newValue) {
+                self._middleName = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+
+    private var _lastName: String = ""
+    var lastName: String {
+        get {
+            return self._lastName
+        }
+        set {
+            if (self._lastName != newValue) {
+                self._lastName = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _street1: String = ""
+    var street1: String {
+        get {
+            return self._street1
+        }
+        set {
+            if (self._street1 != newValue) {
+                self._street1 = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _street2: String = ""
+    var street2: String {
+        get {
+            return self._street2
+        }
+        set {
+            if (self._street2 != newValue) {
+                self._street2 = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _city: String = ""
+    var city: String {
+        get {
+            return self._city
+        }
+        set {
+            if (self._city != newValue) {
+                self._city = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _state: String = ""
+    var state: String {
+        get {
+            return self._state
+        }
+        set {
+            if (self._state != newValue) {
+                self._state = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _zip: String = ""
+    var zip: String {
+        get {
+            return self._zip
+        }
+        set {
+            if (self._zip != newValue) {
+                self._zip = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _country: String = ""
+    var country: String {
+        get {
+            return self._country
+        }
+        set {
+            if (self._country != newValue) {
+                self._country = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _email: String = ""
+    var email: String {
+        get {
+            return self._email
+        }
+        set {
+            if (self._email != newValue) {
+                self._email = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+
+    private var _tel: String = ""
+    var tel: String {
+        get {
+            return self._tel
+        }
+        set {
+            if (self._tel != newValue) {
+                self._tel = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _birthDate: String = ""
+    var birthDate: String {
+        get {
+            return self._birthDate
+        }
+        set {
+            if (self._birthDate != newValue) {
+                self._birthDate = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    private var _customInfoArray: [Any] = []
+    var customInfoArray: [Any] {
+        get {
+            return self._customInfoArray
+        }
+        set {
+            if NSMutableArray(array: self.customInfoArray).isEqual(newValue) == false {
+                self._customInfoArray = newValue
+                
+                self._saveInfo()
+            }
+        }
+    }
+    
+    @objc (sharedInstance)
+    static func shared() -> KMProfileInfo {
+        if let instanch = _shared {
+            return instanch
+        }
+        
+        let defaults = UserDefaults.standard
+        if let encodedObject = defaults.object(forKey: KMProfileUnarchiveKey) as? Data {
+            NSKeyedUnarchiver.setClass(Self.self, forClassName: "KMProfileInfo")
+            let instance = NSKeyedUnarchiver.unarchiveObject(with: encodedObject)
+            _shared = (instance as! KMProfileInfo)
+        } else {
+            let instance = KMProfileInfo()
+            instance._setBaseInfo()
+            instance._saveInfo()
+            _shared = instance
+        }
+        
+        return _shared!
+    }
+    
+    override init() {
+        super.init()
+    }
+    
+    required init?(coder: NSCoder) {
+        super.init()
+        
+        self._fullName = coder.decodeObject(forKey: KMProfileSaveInfoFullNameKey) as? String ?? ""
+        self._firstName = coder.decodeObject(forKey: KMProfileSaveInfoFirstNameKey) as? String ?? ""
+        self._middleName = coder.decodeObject(forKey: KMProfileSaveInfoMiddleNameKey) as? String ?? ""
+        self._lastName = coder.decodeObject(forKey: KMProfileSaveInfoLastNameKey) as? String ?? ""
+        
+        self._street1 = coder.decodeObject(forKey: KMProfileSaveInfoStreet1Key) as? String ?? ""
+        self._street2 = coder.decodeObject(forKey: KMProfileSaveInfoStreet2Key) as? String ?? ""
+        self._city = coder.decodeObject(forKey: KMProfileSaveInfoCityKey) as? String ?? ""
+        self._state = coder.decodeObject(forKey: KMProfileSaveInfoStateKey) as? String ?? ""
+        self._zip = coder.decodeObject(forKey: KMProfileSaveInfoZipKey) as? String ?? ""
+        self._country = coder.decodeObject(forKey: KMProfileSaveInfoCountryKey) as? String ?? ""
+        
+        self._email = coder.decodeObject(forKey: KMProfileSaveInfoEmailKey) as? String ?? ""
+        
+        self._tel = coder.decodeObject(forKey: KMProfileSaveInfoTelKey) as? String ?? ""
+        
+        self._birthDate = coder.decodeObject(forKey: KMProfileSaveInfoBirthDateKey) as? String ?? ""
+        
+        self._customInfoArray = coder.decodeObject(forKey: KMProfileSaveInfoCustomInfoKey) as? [String] ?? []
+    }
+    
+    func encode(with coder: NSCoder) {
+        coder.encode(self.fullName, forKey: KMProfileSaveInfoFullNameKey)
+        coder.encode(self.firstName, forKey: KMProfileSaveInfoFirstNameKey)
+        coder.encode(self.middleName, forKey: KMProfileSaveInfoMiddleNameKey)
+        coder.encode(self.lastName, forKey: KMProfileSaveInfoLastNameKey)
+        
+        coder.encode(self.street1, forKey: KMProfileSaveInfoStreet1Key)
+        coder.encode(self.street2, forKey: KMProfileSaveInfoStreet2Key)
+        coder.encode(self.city, forKey: KMProfileSaveInfoCityKey)
+        coder.encode(self.state, forKey: KMProfileSaveInfoStateKey)
+        coder.encode(self.zip, forKey: KMProfileSaveInfoZipKey)
+        coder.encode(self.country, forKey: KMProfileSaveInfoCountryKey)
+        
+        coder.encode(self.email, forKey: KMProfileSaveInfoEmailKey)
+        coder.encode(self.tel, forKey: KMProfileSaveInfoTelKey)
+        
+        coder.encode(self.birthDate, forKey: KMProfileSaveInfoBirthDateKey)
+        coder.encode(self.customInfoArray, forKey: KMProfileSaveInfoCustomInfoKey)
+    }
+    
+    func replaceObjectInCustomInfoArray(at index: Int, with object: Any) {
+        self._customInfoArray[index] = object 
+        self._saveInfo()
+    }
+    
+    
+    func insertObject(_ object: Any, inCustomInfoArrayAt index: Int) {
+        self._customInfoArray.insert(object, at: index)
+        self._saveInfo()
+    }
+    
+    func removeObjectFromCustomInfoArray(at index: Int) {
+        self.customInfoArray.remove(at: index)
+        self._saveInfo()
+    }
+    /*
+
+     - (void):(NSUInteger)index {
+
+     }
+
+     #pragma mark - NSCoding
+     
+     - (NSString *)description {
+         return [NSString stringWithFormat:@"fullName:%@,firstName:%@,middleName:%@,lastName:%@,street1:%@,street2:%@,city:%@,zip:%@,country:%@,email:%@,tel:%@,birthdate:%@,customInfo:%@",self.fullName,self.firstName,self.middleName,self.lastName,self.street1,self.street2,self.city,self.zip,self.country,self.email,self.tel,self.birthDate,self.customInfoArray];
+     }
+     */
+}
+
+// MARK: - Private Methods
+
+extension KMProfileInfo {
+    private func _saveInfo() {
+        let encodedObject = NSKeyedArchiver.archivedData(withRootObject: self)
+        let defaults = UserDefaults.standard
+        defaults.set(encodedObject, forKey: KMProfileInfo.KMProfileUnarchiveKey)
+        defaults.synchronize()
+    }
+    
+    private func _setBaseInfo() {
+        self._fullName = ""
+        self._firstName = ""
+        self._middleName = ""
+        self._lastName = ""
+        
+        self._street1 = ""
+        self._street2 = ""
+        self._city = ""
+        self._state = ""
+        self._zip = ""
+        self._country = ""
+        
+        self._email = ""
+        self._tel = ""
+        
+        self._customInfoArray = []
+    }
+}

+ 0 - 21
PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.h

@@ -1,21 +0,0 @@
-//
-//  KMProfileInfoWindowController.h
-//  PDF Reader Pro Edition
-//
-//  Created by 蒋志鹏 on 2019-07-19.
-//
-
-#import <Cocoa/Cocoa.h>
-
-@class SKMainWindowController;
-
-NS_ASSUME_NONNULL_BEGIN
-typedef void(^profileInfoAddtoDocCallBack)(NSString *string);
-
-@interface KMProfileInfoWindowController : NSWindowController
-
-@property (nonatomic, copy) profileInfoAddtoDocCallBack callBack;//回调
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 917
PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.m

@@ -1,917 +0,0 @@
-//
-//  KMProfileInfoWindowController.m
-//  PDF Reader Pro Edition
-//
-//  Created by 蒋志鹏 on 2019-07-19.
-//
-
-#import "KMProfileInfoWindowController.h"
-//#import "NSWindowController_SKExtensions.h"
-//#import "KMProfileCellView.h"
-//#import "NSButton+TitleColor.h"
-#import <PDF_Master-Swift.h>
-
-static NSString *KMProfileUnarchiveKey = @"KMProfileUnarchiveKeyTemp1";
-
-static NSString *KMProfileSaveInfoFullNameKey = @"KMProfileSaveInfoFullNameKey";
-static NSString *KMProfileSaveInfoFirstNameKey = @"KMProfileSaveInfoFirstNameKey";
-static NSString *KMProfileSaveInfoMiddleNameKey = @"KMProfileSaveInfoMiddleNameKey";
-static NSString *KMProfileSaveInfoLastNameKey = @"KMProfileSaveInfoLastNameKey";
-
-static NSString *KMProfileSaveInfoStreet1Key = @"KMProfileSaveInfoStreet1Key";
-static NSString *KMProfileSaveInfoStreet2Key = @"KMProfileSaveInfoStreet2Key";
-static NSString *KMProfileSaveInfoCityKey = @"KMProfileSaveInfoCityKey";
-static NSString *KMProfileSaveInfoStateKey = @"KMProfileSaveInfoStateKey";
-static NSString *KMProfileSaveInfoZipKey = @"KMProfileSaveInfoZipKey";
-static NSString *KMProfileSaveInfoCountryKey = @"KMProfileSaveInfoCountryKey";
-
-static NSString *KMProfileSaveInfoEmailKey = @"KMProfileSaveInfoEmailKey";
-static NSString *KMProfileSaveInfoTelKey = @"KMProfileSaveInfoTelKey";
-static NSString *KMProfileSaveInfoBirthDateKey = @"KMProfileSaveInfoBirthDateKey";
-static NSString *KMProfileSaveInfoCustomInfoKey = @"KMProfileSaveInfoCustomInfoKey";
-
-@interface KMProfileInfo : NSObject <NSCoding>
-
-@property (nonatomic, retain) NSString *fullName;
-@property (nonatomic, retain) NSString *firstName;
-@property (nonatomic, retain) NSString *middleName;
-@property (nonatomic, retain) NSString *lastName;
-
-@property (nonatomic, retain) NSString *street1;
-@property (nonatomic, retain) NSString *street2;
-@property (nonatomic, retain) NSString *city;
-@property (nonatomic, retain) NSString *state;
-@property (nonatomic, retain) NSString *zip;
-@property (nonatomic, retain) NSString *country;
-
-@property (nonatomic, retain) NSString *email;
-@property (nonatomic, retain) NSString *tel;
-
-@property (nonatomic, retain) NSString *birthDate;
-
-@property (nonatomic, retain) NSMutableArray *customInfoArray;
-
-@end
-
-@implementation KMProfileInfo
-
-#pragma mark - Getter & setter
-
-- (void)setFullName:(NSString *)fullName {
-//    if (![fullName isEqualToString:_fullName]) {
-//        [_fullName release];
-//        _fullName = [fullName retain];
-        
-    _fullName = fullName;
-        [self saveInfo];
-//    }
-}
-
-- (void)setFirstName:(NSString *)firstName {
-//    if (![_firstName isEqualToString:firstName]) {
-//        [_firstName release];
-//        _firstName = [firstName retain];
-        
-    _firstName = firstName;
-        [self saveInfo];
-//    }
-}
-
-- (void)setMiddleName:(NSString *)middleName {
-//    if (![_middleName isEqualToString:middleName]) {
-//        [_middleName release];
-//        _middleName = [middleName retain];
-        
-    _middleName = middleName;
-        [self saveInfo];
-//    }
-}
-
-- (void)setLastName:(NSString *)lastName {
-//    if (![_lastName isEqualToString:lastName]) {
-//        [_lastName release];
-//        _lastName = [lastName retain];
-    _lastName = lastName;
-        [self saveInfo];
-//    }
-}
-
-- (void)setStreet1:(NSString *)street1 {
-//    if (![_street1 isEqualToString:street1]) {
-//        [_street1 release];
-//        _street1 = [street1 retain];
-        
-    _street1 = street1;
-        [self saveInfo];
-//    }
-}
-
-- (void)setStreet2:(NSString *)street2 {
-//    if (![_street2 isEqualToString:street2]) {
-//        [_street2 release];
-//        _street2 = [street2 retain];
-        
-    _street2 = street2;
-        [self saveInfo];
-//    }
-}
-
-- (void)setCity:(NSString *)city {
-//    if (![_city isEqualToString:city]) {
-//        [_city release];
-//        _city = [city retain];
-        
-    _city = city;
-        [self saveInfo];
-//    }
-}
-
-- (void)setState:(NSString *)state {
-//    if (![_state isEqualToString:state]) {
-//        [_state release];
-//        _state = [state retain];
-        
-    _state = state;
-        [self saveInfo];
-//    }
-}
-
-- (void)setZip:(NSString *)zip {
-//    if (![_zip isEqualToString:zip]) {
-//        [_zip release];
-//        _zip = [zip retain];
-        
-    _zip = zip;
-        [self saveInfo];
-//    }
-}
-
-- (void)setCountry:(NSString *)country {
-//    if (![_country isEqualToString:country]) {
-//        [_country release];
-//        _country = [country retain];
-        
-    _country = country;
-        [self saveInfo];
-//    }
-}
-
-
-- (void)setEmail:(NSString *)email {
-//    if (![_email isEqualToString:email]) {
-//        [_email release];
-//        _email = [email retain];
-        
-    _email = email;
-        [self saveInfo];
-//    }
-}
-
-- (void)setTel:(NSString *)tel {
-//    if (![_tel isEqualToString:tel]) {
-//        [_tel release];
-//        _tel = [tel retain];
-    _tel = tel;
-        [self saveInfo];
-//    }
-}
-
-- (void)setBirthDate:(NSString *)birthDate {
-//    if (![_birthDate isEqualToString:birthDate]) {
-//        [_birthDate release];
-//        _birthDate = [birthDate retain];
-        
-    _birthDate = birthDate;
-        [self saveInfo];
-//    }
-}
-
-- (void)setCustomInfoArray:(NSMutableArray *)customInfoArray {
-//    if (![customInfoArray isEqual:customInfoArray]) {
-//        [customInfoArray release];
-//        _customInfoArray  = [customInfoArray retain];
-        
-    _customInfoArray = customInfoArray;
-        [self saveInfo];
-//    }
-}
-
-#pragma mark -  Init Methods
-
-+ (instancetype)sharedInstance {
-    static dispatch_once_t onceToken;
-    static KMProfileInfo *manager = nil;
-    dispatch_once(&onceToken, ^{
-        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-        NSData *encodedObject = [defaults objectForKey:KMProfileUnarchiveKey];
-        if (!encodedObject) {
-            manager = [[KMProfileInfo alloc] init];
-            [manager setBaseInfo];
-            [manager saveInfo];
-        } else {
-            manager = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
-        }
-        
-    });
-    return manager;
-}
-
-#pragma mark - Private Methods
-
-- (void)saveInfo {
-    NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:self];
-    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    [defaults setObject:encodedObject forKey:KMProfileUnarchiveKey];
-    [defaults synchronize];
-}
-
-- (void)setBaseInfo {
-    _fullName = @"";
-    _firstName = @"";
-    _middleName = @"";
-    _lastName = @"";
-    
-    _street1 = @"";
-    _street2 = @"";
-    _city = @"";
-    _state = @"";
-    _zip = @"";
-    _country = @"";
-    
-    _email = @"";
-    _tel = @"";
-    
-    _birthDate = @"";
-    _customInfoArray = [NSMutableArray array];
-}
-
-
-- (void)replaceObjectInCustomInfoArrayAtIndex:(NSInteger)index withObject:(id)object {
-    [self.customInfoArray replaceObjectAtIndex:index withObject:object];
-    [self saveInfo];
-}
-
-- (void)removeObjectFromCustomInfoArrayAtIndex:(NSUInteger)index {
-    [self.customInfoArray removeObjectAtIndex:index];
-    [self saveInfo];
-}
-
-- (void)insertObject:(id)object inCustomInfoArrayAtIndex:(NSInteger)index {
-    [self.customInfoArray insertObject:object atIndex:index];
-    [self saveInfo];
-}
-
-#pragma mark - NSCoding
-
-- (void)encodeWithCoder:(NSCoder *)aCoder {
-    [aCoder encodeObject:self.fullName forKey:KMProfileSaveInfoFullNameKey];
-    [aCoder encodeObject:self.firstName forKey:KMProfileSaveInfoFirstNameKey];
-    [aCoder encodeObject:self.middleName forKey:KMProfileSaveInfoMiddleNameKey];
-    [aCoder encodeObject:self.lastName forKey:KMProfileSaveInfoLastNameKey];
-    
-    [aCoder encodeObject:self.street1 forKey:KMProfileSaveInfoStreet1Key];
-    [aCoder encodeObject:self.street2 forKey:KMProfileSaveInfoStreet2Key];
-    [aCoder encodeObject:self.city forKey:KMProfileSaveInfoCityKey];
-    [aCoder encodeObject:self.state forKey:KMProfileSaveInfoStateKey];
-    [aCoder encodeObject:self.zip forKey:KMProfileSaveInfoZipKey];
-    [aCoder encodeObject:self.country forKey:KMProfileSaveInfoCountryKey];
-    
-    [aCoder encodeObject:self.email forKey:KMProfileSaveInfoEmailKey];
-    [aCoder encodeObject:self.tel forKey:KMProfileSaveInfoTelKey];
-    
-    [aCoder encodeObject:self.birthDate forKey:KMProfileSaveInfoBirthDateKey];
-    [aCoder encodeObject:self.customInfoArray forKey:KMProfileSaveInfoCustomInfoKey];
-}
-
-- (instancetype)initWithCoder:(NSCoder *)aDecoder {
-    if (self = [super init]) {
-        _fullName = [aDecoder decodeObjectForKey:KMProfileSaveInfoFullNameKey] ?:@"";
-        _firstName = [aDecoder decodeObjectForKey:KMProfileSaveInfoFirstNameKey] ?:@"";
-        _middleName = [aDecoder decodeObjectForKey:KMProfileSaveInfoMiddleNameKey] ?:@"";
-        _lastName = [aDecoder decodeObjectForKey:KMProfileSaveInfoLastNameKey] ?:@"";
-        
-        _street1 = [aDecoder decodeObjectForKey:KMProfileSaveInfoStreet1Key] ?:@"";
-        _street2 = [aDecoder decodeObjectForKey:KMProfileSaveInfoStreet2Key] ?:@"";
-        _city = [aDecoder decodeObjectForKey:KMProfileSaveInfoCityKey] ?:@"";
-        _state = [aDecoder decodeObjectForKey:KMProfileSaveInfoStateKey] ?:@"";
-        _zip = [aDecoder decodeObjectForKey:KMProfileSaveInfoZipKey] ?:@"";
-        _country = [aDecoder decodeObjectForKey:KMProfileSaveInfoCountryKey] ?:@"";
-        
-        _email = [aDecoder decodeObjectForKey:KMProfileSaveInfoEmailKey] ?:@"";
-        
-        _tel = [aDecoder decodeObjectForKey:KMProfileSaveInfoTelKey] ?:@"";
-        
-        _birthDate = [aDecoder decodeObjectForKey:KMProfileSaveInfoBirthDateKey] ?:@"";
-        _customInfoArray = [aDecoder decodeObjectForKey:KMProfileSaveInfoCustomInfoKey]?: [NSMutableArray array];
-    }
-    return self;
-}
-
-- (NSString *)description {
-    return [NSString stringWithFormat:@"fullName:%@,firstName:%@,middleName:%@,lastName:%@,street1:%@,street2:%@,city:%@,zip:%@,country:%@,email:%@,tel:%@,birthdate:%@,customInfo:%@",self.fullName,self.firstName,self.middleName,self.lastName,self.street1,self.street2,self.city,self.zip,self.country,self.email,self.tel,self.birthDate,self.customInfoArray];
-}
-
-
-@end
-
-static NSString  *TitleCellIdentifier = @"TitleCell";
-static NSString  *NormalCellIdentifier = @"Normal";
-
-@interface KMProfileInfoWindowController () <NSTableViewDelegate, NSTableViewDataSource, NSTextFieldDelegate>
-
-@property (assign) IBOutlet NSTextField *titleLabel;
-@property (assign) IBOutlet NSTableView *tableView;
-@property (nonatomic, retain) NSMutableArray *tableContents;
-@property (assign) IBOutlet NSButton *backButton;
-@property (assign) IBOutlet NSButton *addButton;
-@property (assign) IBOutlet NSButton *addNewInfoButton;
-@property (assign) IBOutlet NSButton *removeNewInfoButton;
-
-@end
-
-@implementation KMProfileInfoWindowController
-
-- (void)dealloc {
-    
-//    [_tableContents release];
-    [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
-    
-//    [super dealloc];
-}
-
-#pragma mark - Life Cycle
-- (void)windowDidLoad {
-    [super windowDidLoad];
-    
-    [self configuViews];
-    [self fetchDisplayKeys];
-    [self.tableView reloadData];
-    [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
-}
-
-#pragma mark - Private Methods
-
-- (void)configuViews {
-    
-    self.titleLabel.stringValue = NSLocalizedString(@"My Profile", nil);
-
-    //Button Part
-    self.backButton.title = NSLocalizedString(@"Cancel", nil);
-    self.addButton.title = NSLocalizedString(@"Add to Doc", nil);
-    self.addButton.enabled = NO;
-    self.removeNewInfoButton.enabled = NO;
-    //NSMenu Part
-    NSMenuItem *editItem = [self.tableView.menu itemAtIndex:0];
-    NSMenuItem *addItem = [self.tableView.menu itemAtIndex:1];
-    NSMenuItem *deleteItem = [self.tableView.menu itemAtIndex:2];
-    
-    editItem.title = NSLocalizedString(@"Edit", nil);
-    addItem.title = NSLocalizedString(@"Add to Doc", nil);
-    deleteItem.title = NSLocalizedString(@"Delete", nil);
-}
-
-- (void)fetchDisplayKeys {
-    _tableContents = [NSMutableArray array];
-    [_tableContents addObject:NSLocalizedString(@"Name", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Full Name", nil)];
-    [_tableContents addObject:NSLocalizedString(@"First Name", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Middle Name", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Last Name", nil)];
-    
-    [_tableContents addObject:NSLocalizedString(@"Address", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Street 1", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Street 2", nil)];
-    [_tableContents addObject:NSLocalizedString(@"City", nil)];
-    [_tableContents addObject:NSLocalizedString(@"State ", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Zip", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Country", nil)];
-    
-    [_tableContents addObject:NSLocalizedString(@"Contact Information", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Email", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Tel", nil)];
-    
-    [_tableContents addObject:NSLocalizedString(@"Dates", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Date", nil)];
-    [_tableContents addObject:NSLocalizedString(@"Birth Date", nil)];
-    if ([KMProfileInfo sharedInstance].customInfoArray.count > 0) {
-        [_tableContents addObject:NSLocalizedString(@"Custom", nil)];
-        for (NSUInteger i = 0 ; i < [KMProfileInfo sharedInstance].customInfoArray.count; i ++) {
-            NSDictionary *dict = [[KMProfileInfo sharedInstance].customInfoArray objectAtIndex:i];
-            [_tableContents addObject:dict.allKeys.firstObject];
-        }
-    }
-}
-
-- (void)configuTextField:(KMProfileCellView *)cellView {
-    NSTextField * textField = cellView.detailtextField;
-    NSInteger tag = textField.tag;
-    NSString *placeHoldString = @"";
-    NSString *nameString = @"";
-
-    if (tag == 1) {
-        placeHoldString = NSLocalizedString(@"Add Full Name", nil);
-        nameString = [KMProfileInfo sharedInstance].fullName;
-    } else if (tag == 2) {
-        placeHoldString = NSLocalizedString(@"Add First Name", nil);
-        nameString = [KMProfileInfo sharedInstance].firstName;
-    } else if (tag == 3) {
-        placeHoldString = NSLocalizedString(@"Add Middle Name", nil);
-        nameString = [KMProfileInfo sharedInstance].middleName;
-    } else if (tag == 4) {
-        placeHoldString = NSLocalizedString(@"Add Last Name", nil);
-        nameString = [KMProfileInfo sharedInstance].lastName;
-    } else if (tag == 6) {
-        placeHoldString = NSLocalizedString(@"Add Street 1", nil);
-        nameString = [KMProfileInfo sharedInstance].street1;
-    } else if (tag == 7) {
-        placeHoldString = NSLocalizedString(@"Add Street 2", nil);
-        nameString = [KMProfileInfo sharedInstance].street2;
-    } else if (tag == 8) {
-
-        placeHoldString = NSLocalizedString(@"Add City", nil);
-        nameString = [KMProfileInfo sharedInstance].city;
-    } else if (tag == 9) {
-        placeHoldString = NSLocalizedString(@"Add State", nil);
-        nameString = [KMProfileInfo sharedInstance].state;
-    } else if (tag == 10) {
-        placeHoldString = NSLocalizedString(@"Add Zip", nil);
-        nameString = [KMProfileInfo sharedInstance].zip;
-    } else if (tag == 11) {
-        placeHoldString = NSLocalizedString(@"Add Country", nil);
-        nameString = [KMProfileInfo sharedInstance].country;
-    } else if (tag == 13) {
-        placeHoldString = NSLocalizedString(@"Add Email", nil);
-        nameString = [KMProfileInfo sharedInstance].email;
-    } else if (tag == 14) {
-        placeHoldString = NSLocalizedString(@"Add Tel", nil);
-        nameString = [KMProfileInfo sharedInstance].tel;
-    } else if (tag == 16) {
-        placeHoldString = NSLocalizedString(@"Add Date", nil);
-        NSDate *date = [NSDate date];
-        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
-        [formatter setDateFormat:@"YYYY/MM/dd"];
-        nameString = [formatter stringFromDate:date];
-    } else if (tag == 17) {
-        placeHoldString = NSLocalizedString(@"Add Birth Date", nil);
-        nameString = [KMProfileInfo sharedInstance].birthDate;
-    }
-    textField.stringValue = nameString;
-    if (nameString.length > 0) {
-        textField.hidden = NO;
-        cellView.addButton.hidden = YES;
-    } else {
-        cellView.addButton.title = placeHoldString;
-        textField.placeholderString = placeHoldString;
-        textField.hidden = YES;
-        cellView.addButton.tag = tag;
-        cellView.addButton.target = self;
-        [cellView.addButton setAction:@selector(addFileName_Add:)];
-        [cellView.addButton setTitleColor:[NSColor systemBlueColor]];
-        cellView.addButton.hidden = NO;
-
-    }
-}
-
-#pragma mark - NSTableViewDelegate / NSTableViewDataSources
-
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
-    return self.tableContents.count;
-}
-
-- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
-    NSString *addingString = [self.tableContents objectAtIndex:row];
-    NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
-    if (([addingString isEqualToString:NSLocalizedString(@"Name", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Address", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Contact Information", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Dates", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Custom", nil)])
-        && row <= customIndex) {
-        return 24.0;
-    } else {
-        return 36.0;
-    }
-}
-
-- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
-    NSString *addingString = [self.tableContents objectAtIndex:row];
-    NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
-    NSTableCellView *tableCellView = nil;
-    if (([addingString isEqualToString:NSLocalizedString(@"Name", nil)] ||
-        [addingString isEqualToString:NSLocalizedString(@"Address", nil)] ||
-        [addingString isEqualToString:NSLocalizedString(@"Contact Information", nil)] ||
-        [addingString isEqualToString:NSLocalizedString(@"Dates", nil)] ||
-        [addingString isEqualToString:NSLocalizedString(@"Custom", nil)])
-        && row <= customIndex) {
-        tableCellView = [tableView makeViewWithIdentifier:TitleCellIdentifier owner:tableColumn];
-        KMProfileTitleCellView *cellView = (KMProfileTitleCellView *)tableCellView;
-        cellView.textField.stringValue = addingString;
-        cellView.textField.editable = NO;
-        cellView.wantsLayer = YES;
-        if ([KMAppearance isSupportNewColor]) {
-            if ([KMAppearance isDarkMode]) {
-                cellView.layer.backgroundColor = [NSColor colorWithRed:73/255.0 green:75/255.0 blue:77/255.0 alpha:1.0].CGColor;
-            } else {
-                cellView.layer.backgroundColor = [NSColor colorWithRed:219/255.0 green:219/255.0 blue:219/255.0 alpha:1.0].CGColor;
-            }
-        } else {
-            cellView.layer.backgroundColor = [NSColor colorWithRed:235.0/255.0 green:235.0/255.0 blue:235.0/255.0 alpha:1.0].CGColor;
-        }
-        
-    } else {
-        tableCellView = [tableView makeViewWithIdentifier:NormalCellIdentifier owner:tableColumn];
-        KMProfileCellView *cellView = (KMProfileCellView *)tableCellView;
-        cellView.textField.stringValue = addingString;
-        if([cellView isKindOfClass:[KMProfileCellView class]]){
-            cellView.detailtextField.hidden = NO;
-        }
-        cellView.textField.textColor = [KMAppearance KMColor_Layout_H0];
-        if (customIndex > row) {
-            cellView.detailtextField.tag = row;
-            [self configuTextField:cellView];
-            cellView.textField.editable = NO;
-            cellView.textField.selectable = NO;
-            if ([addingString isEqualToString:NSLocalizedString(@"Date", nil)]) {
-                cellView.detailtextField.editable = NO;
-                cellView.detailtextField.selectable = NO;
-            }
-
-            cellView.detailtextField.delegate = self;
-        } else {
-            NSInteger index = row - customIndex - 1;
-            NSDictionary *dict = [[KMProfileInfo sharedInstance].customInfoArray objectAtIndex:index];
-            cellView.addButton.hidden = YES;
-            cellView.detailtextField.stringValue = dict.allValues.firstObject;
-            cellView.detailtextField.placeholderString = NSLocalizedString(@"Type Value Here", nil);
-            cellView.textField.placeholderString = NSLocalizedString(@"Type Label Here", nil);
-            cellView.textField.editable = YES;
-            cellView.textField.selectable = YES;
-            cellView.detailtextField.editable = YES;
-            cellView.detailtextField.selectable = YES;
-            cellView.textField.delegate = self;
-            cellView.detailtextField.delegate = self;
-
-        }
-    }
-    return tableCellView;
-}
-
-- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row {
-    NSString *addingString = [self.tableContents objectAtIndex:row];
-    NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
-    if (([addingString isEqualToString:NSLocalizedString(@"Name", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Address", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Contact Information", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Dates", nil)] ||
-         [addingString isEqualToString:NSLocalizedString(@"Custom", nil)])
-        && row <= customIndex) {
-        return NO;
-    }
-    return YES;
-}
-
-
-
-#pragma mark - NSTextFieldDelegate
-
-- (void)controlTextDidChange:(NSNotification *)obj {
-    
-    NSInteger currentRow = self.tableView.selectedRow;
-    if (currentRow == -1) {
-        return;
-    }
-    NSTextField *textField = (NSTextField *)obj.object;
-    KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:currentRow makeIfNecessary:NO];
-    if (currentRow == 1) {
-        [KMProfileInfo sharedInstance].fullName = textField.stringValue;
-    } else if (currentRow == 2) {
-        [KMProfileInfo sharedInstance].firstName = textField.stringValue;
-    } else if (currentRow == 3) {
-        [KMProfileInfo sharedInstance].middleName = textField.stringValue;
-    } else if (currentRow == 4) {
-        [KMProfileInfo sharedInstance].lastName = textField.stringValue;
-    } else if (currentRow == 6) {
-        [KMProfileInfo sharedInstance].street1 = textField.stringValue;
-    } else if (currentRow == 7) {
-        [KMProfileInfo sharedInstance].street2 = textField.stringValue;
-    } else if (currentRow == 8) {
-        [KMProfileInfo sharedInstance].city = textField.stringValue;
-    } else if (currentRow == 9) {
-        [KMProfileInfo sharedInstance].state = textField.stringValue;
-    } else if (currentRow == 10) {
-        [KMProfileInfo sharedInstance].zip = textField.stringValue;
-    } else if (currentRow == 11) {
-        [KMProfileInfo sharedInstance].country = textField.stringValue;
-    } else if (currentRow == 13) {
-        [KMProfileInfo sharedInstance].email = textField.stringValue;
-    } else if (currentRow == 14) {
-        [KMProfileInfo sharedInstance].tel = textField.stringValue;
-    } else if (currentRow == 16) {
-//        [KMProfileInfo sharedInstance].date = textField.stringValue;
-    } else if (currentRow == 17) {
-        [KMProfileInfo sharedInstance].birthDate = textField.stringValue;
-    } else if (currentRow >= 19 ) {
-        NSInteger customIndex = currentRow - 19;
-        if (cellView) {
-            NSDictionary *dict = [[KMProfileInfo sharedInstance].customInfoArray objectAtIndex:customIndex];
-            NSString *originalKey = dict.allKeys.firstObject;
-            NSString *originalValue = dict.allValues.firstObject;
-            if ([textField isEqual:cellView.textField]) {
-                NSDictionary *newDict = @{textField.stringValue : originalValue};
-                [[KMProfileInfo sharedInstance] replaceObjectInCustomInfoArrayAtIndex:customIndex withObject:newDict];
-            } else if ([textField isEqual:cellView.detailtextField]){
-                NSDictionary *newDict = @{originalKey:textField.stringValue};
-                [[KMProfileInfo sharedInstance] replaceObjectInCustomInfoArrayAtIndex:customIndex withObject:newDict];
-            }
-        }
-    }
-    
-    if (cellView.detailtextField.stringValue.length > 0 ) {
-        self.addButton.enabled = YES;
-    } else {
-        self.addButton.enabled = NO;
-    }
-}
-
-- (void)controlTextDidBeginEditing:(NSNotification *)obj {
-    NSTextField *textField = obj.object;
-    BOOL isDarkMode = NO;
-    if (@available(macOS 10.14, *)) {
-        if ([[NSApplication sharedApplication].effectiveAppearance isEqual: [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]) {
-            isDarkMode =YES;
-        }
-    }
-
-    textField.textColor = [NSColor labelColor];
-}
-
-- (void)controlTextDidEndEditing:(NSNotification *)obj;
-{
-    NSTextField *textField = obj.object;
-    NSInteger tag = textField.tag;
-    KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:textField.tag makeIfNecessary:NO];
-
-    if ([cellView isKindOfClass:[KMProfileCellView class]] && tag > 0) {
-        NSString *placeHoldString = @"";
-
-        if (tag == 1) {
-            placeHoldString = NSLocalizedString(@"Add Full Name", nil);
-        } else if (tag == 2) {
-            placeHoldString = NSLocalizedString(@"Add First Name", nil);
-        } else if (tag == 3) {
-            placeHoldString = NSLocalizedString(@"Add Middle Name", nil);
-        } else if (tag == 4) {
-            placeHoldString = NSLocalizedString(@"Add Last Name", nil);
-        } else if (tag == 6) {
-            placeHoldString = NSLocalizedString(@"Add Street 1", nil);
-        } else if (tag == 7) {
-            placeHoldString = NSLocalizedString(@"Add Street 2", nil);
-        } else if (tag == 8) {
-            placeHoldString = NSLocalizedString(@"Add City", nil);
-        } else if (tag == 9) {
-            placeHoldString = NSLocalizedString(@"Add State", nil);
-        } else if (tag == 10) {
-            placeHoldString = NSLocalizedString(@"Add Zip", nil);
-        } else if (tag == 11) {
-            placeHoldString = NSLocalizedString(@"Add Country", nil);
-        } else if (tag == 13) {
-            placeHoldString = NSLocalizedString(@"Add Email", nil);
-        } else if (tag == 14) {
-            placeHoldString = NSLocalizedString(@"Add Tel", nil);
-        } else if (tag == 16) {
-            placeHoldString = NSLocalizedString(@"Add Date", nil);
-        } else if (tag == 17) {
-            placeHoldString = NSLocalizedString(@"Add Birth Date", nil);
-        }
-
-        if (textField.stringValue.length > 0) {
-            textField.textColor = [NSColor secondaryLabelColor];
-            textField.hidden = NO;
-            cellView.addButton.hidden = YES;
-        } else {
-//            textField.hidden = YES; //自定义新增,输入Label后,value为空时推出编辑,就无法填写了
-            textField.placeholderString = @"";
-            cellView.addButton.hidden = NO;
-            cellView.addButton.tag = tag;
-            cellView.addButton.target = self;
-            [cellView.addButton setAction:@selector(addFileName_Add:)];
-            cellView.addButton.title = placeHoldString;
-            [cellView.addButton setTitleColor:[NSColor systemBlueColor]];
-        }
-    }
-    
-}
-
-- (void)tableViewSelectionDidChange:(NSNotification *)notification {
-    if (self.tableView.selectedRow == NSNotFound || self.tableView.selectedRow == -1) {
-        return;
-    }
-    KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.selectedRow makeIfNecessary:NO];
-    self.addButton.enabled = cellView.detailtextField.stringValue.length > 0;
-
-    for (NSInteger i = 0; i < self.tableView.numberOfRows; i++) {
-        NSTableCellView *cellView =  [self.tableView viewAtColumn:0 row:i makeIfNecessary:NO];
-        if ([cellView isKindOfClass:[KMProfileCellView class]]) {
-            KMProfileCellView *cellView1 = (KMProfileCellView *)cellView;
-            if (i == self.tableView.selectedRow) {
-                cellView1.detailtextField.textColor = [NSColor whiteColor];
-                [cellView1.addButton setTitleColor:[NSColor whiteColor]];
-            } else {
-                cellView1.detailtextField.textColor = [NSColor secondaryLabelColor];
-                [cellView1.addButton setTitleColor:[NSColor systemBlueColor]];
-            }
-        }
-    }
-    NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
-    if (self.tableView.selectedRow > customIndex) {
-        self.removeNewInfoButton.enabled = YES;
-    } else {
-        self.removeNewInfoButton.enabled = NO;
-    }
-}
-
-#pragma  mark - Button Action
-
-- (IBAction)buttonClicked_back:(id)sender {
-//    [self dismissSheet:sender];
-}
-
-- (IBAction)buttonClicked_add:(id)sender {
-    NSInteger selectRow =self.tableView.selectedRow;
-    if (selectRow >= 0) {
-        if (self.callBack) {
-            KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.selectedRow makeIfNecessary:NO];
-            self.callBack(cellView.detailtextField.stringValue);
-//            [self dismissSheet:sender];
-        }
-    }
-}
-
-- (IBAction)buttonClicked_addNewInfo:(id)sender {
-    NSDictionary *dict = @{@"":@""};
-    [[KMProfileInfo sharedInstance] insertObject:dict inCustomInfoArrayAtIndex:[KMProfileInfo sharedInstance].customInfoArray.count];
-    [self fetchDisplayKeys];
-    [self.tableView reloadData];
-    if (self.tableView.numberOfRows > 1) {
-        [self.tableView scrollRowToVisible:self.tableView.numberOfRows - 1];
-        NSIndexSet *set = [NSIndexSet indexSetWithIndex:self.tableView.numberOfRows - 1];
-        [self.tableView selectRowIndexes:set byExtendingSelection:NO];
-        KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.selectedRow makeIfNecessary:NO];
-        cellView.addButton.hidden = YES;
-        [cellView.textField becomeFirstResponder];
-    };
-}
-
-- (IBAction)buttonClicked_RemoveNewInfo:(id)sender
-{
-    NSInteger  editIndex = self.tableView.selectedRow;
-    NSUInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
-    if (editIndex - customIndex - 1 < [KMProfileInfo sharedInstance].customInfoArray.count) {
-        [[KMProfileInfo sharedInstance] removeObjectFromCustomInfoArrayAtIndex:editIndex - customIndex - 1];
-        [self fetchDisplayKeys];
-        [self.tableView reloadData];
-        self.removeNewInfoButton.enabled = NO;
-    }
-}
-
-- (IBAction)addFileName_Add:(NSButton *)sender
-{
-    [self.window makeFirstResponder:nil];
-    NSInteger tag = sender.tag;
-    KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:tag makeIfNecessary:NO];
-    if ([cellView isKindOfClass:[KMProfileCellView class]]) {
-        cellView.addButton.hidden = YES;
-        cellView.detailtextField.hidden = NO;
-        [cellView.detailtextField becomeFirstResponder];
-    }
-}
-
-#pragma mark - NSMenu Action
-
-- (IBAction)menuItemClicked_Edit:(id)sender {
-    KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.clickedRow makeIfNecessary:NO];
-    NSIndexSet *set = [NSIndexSet indexSetWithIndex:self.tableView.clickedRow];
-    [self.tableView selectRowIndexes:set byExtendingSelection:NO];
-    if (cellView.textField.editable) {
-        if (cellView.textField.stringValue.length == 0) {
-            [cellView.textField becomeFirstResponder];
-        }else {
-            [cellView.detailtextField becomeFirstResponder];
-        }
-    } else {
-        [cellView.detailtextField becomeFirstResponder];
-    }
-}
-
-- (IBAction)menuItemClicked_Add:(id)sender {
-     KMProfileCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.clickedRow makeIfNecessary:NO];
-    if (self.callBack) {
-        self.callBack(cellView.detailtextField.stringValue);
-//        [self dismissSheet:sender];
-    }
-}
-
-- (IBAction)menuItemClicked_Delete:(id)sender {
-    NSInteger  editIndex = self.tableView.clickedRow;
-    NSInteger customIndex = [self.tableContents indexOfObject:NSLocalizedString(@"Custom", nil)];
-    if (editIndex < customIndex ) {
-        switch (editIndex) {
-            case 1:
-                [KMProfileInfo sharedInstance].fullName = @"";
-                break;
-            case 2:
-                [KMProfileInfo sharedInstance].firstName = @"";
-                break;
-            case 3:
-                [KMProfileInfo sharedInstance].middleName = @"";
-                break;
-            case 4:
-                [KMProfileInfo sharedInstance].lastName = @"";
-                break;
-                
-            case 6:
-                [KMProfileInfo sharedInstance].street1 = @"";
-                break;
-            case 7:
-                [KMProfileInfo sharedInstance].street2 = @"";
-                break;
-            case 8:
-                [KMProfileInfo sharedInstance].city = @"";
-                break;
-            case 9:
-                [KMProfileInfo sharedInstance].state = @"";
-                break;
-            case 10:
-                [KMProfileInfo sharedInstance].zip = @"";
-                break;
-            case 11:
-                [KMProfileInfo sharedInstance].country = @"";
-                break;
-            case 13:
-                [KMProfileInfo sharedInstance].email = @"";
-                break;
-            case 14:
-                [KMProfileInfo sharedInstance].tel = @"";
-                break;
-            case 16:
-//                [KMProfileInfo sharedInstance].date = @"";
-                break;
-            case 17:
-                [KMProfileInfo sharedInstance].birthDate = @"";
-                break;
-            default:
-                break;
-        }
-    } else {
-        [[KMProfileInfo sharedInstance] removeObjectFromCustomInfoArrayAtIndex:editIndex - customIndex - 1];
-    }
-    
-    [self fetchDisplayKeys];
-    [self.tableView reloadData];
-}
-
-- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
-    
-    NSTableCellView *cellView = [self.tableView viewAtColumn:0 row:self.tableView.clickedRow makeIfNecessary:NO];
-    if (menuItem.action == @selector(menuItemClicked_Edit:)) {
-        if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
-            return NO;
-        } else {
-            KMProfileCellView *cellView1 = (KMProfileCellView *)cellView;
-            if ([cellView1.textField.stringValue isEqualToString:NSLocalizedString(@"Date", nil)]) {
-                return NO;
-            }
-            return YES;
-        }
-    } else if (menuItem.action == @selector(menuItemClicked_Add:)) {
-        if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
-            return NO;
-        } else {
-            KMProfileCellView *cell = (KMProfileCellView *)cellView;
-            return cell.detailtextField.stringValue.length > 0;
-        }
-    } else if (menuItem.action == @selector(menuItemClicked_Delete:)) {
-        if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
-            return NO;
-        } else {
-            KMProfileCellView *cellView1 = (KMProfileCellView *)cellView;
-            if ([cellView1.textField.stringValue isEqualToString:NSLocalizedString(@"Date", nil)]) {
-                return NO;
-            }
-            return YES;
-        }
-    }
-    return NO;
-}
-
-- (void)themeChanged:(NSNotification *)notification {
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [self updateViewColor];
-    });
-}
-
-- (void)updateViewColor {
-    [self.tableView reloadData];
-}
-
-@end

+ 606 - 0
PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift

@@ -0,0 +1,606 @@
+//
+//  KMProfileInfoWindowController.swift
+//  PDF Master
+//
+//  Created by tangchao on 2023/11/9.
+//
+
+import Cocoa
+
+class KMProfileInfoWindowController: NSWindowController {
+    var callBack: ((String) -> Void)?
+    
+    @IBOutlet var titleLabel: NSTextField!
+    @IBOutlet var tableView: NSTableView!
+    
+    @IBOutlet var backButton: NSButton!
+    @IBOutlet var addButton: NSButton!
+    @IBOutlet var addNewInfoButton: NSButton!
+    @IBOutlet var removeNewInfoButton: NSButton!
+    
+    var tableContents: [String] = []
+    
+    private let TitleCellIdentifier = "TitleCell"
+    private let NormalCellIdentifier = "Normal"
+
+    deinit {
+        KMPrint("KMProfileInfoWindowController deinit.")
+        DistributedNotificationCenter.default().removeObserver(self)
+    }
+    
+    override func windowDidLoad() {
+        super.windowDidLoad()
+        
+        self._configuViews()
+        self._fetchDisplayKeys()
+        self.tableView.reloadData()
+        DistributedNotificationCenter.default().addObserver(self, selector: #selector(_themeChanged), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
+    }
+    
+    @IBAction func addFileName_Add(_ sender: NSButton) {
+        self.window?.makeFirstResponder(nil)
+        let tag = sender.tag
+        let cellView = self.tableView.view(atColumn: 0, row: tag, makeIfNecessary: false) as? KMProfileCellView
+        if let data = cellView?.isKind(of: KMProfileCellView.self), data {
+            cellView?.addButton.isHidden = true
+            cellView?.detailtextField.isHidden = false
+            cellView?.detailtextField.becomeFirstResponder()
+        }
+    }
+    
+    @IBAction func buttonClicked_back(_ sender: AnyObject?) {
+        guard let block = self.callBack else {
+            return
+        }
+        block("")
+    }
+    
+    @IBAction func buttonClicked_add(_ sender: AnyObject?) {
+        let selectRow = self.tableView.selectedRow
+        if (selectRow >= 0) {
+            if (self.callBack != nil) {
+                let cellView = self.tableView.view(atColumn: 0, row: selectRow, makeIfNecessary: false) as? KMProfileCellView
+                self.callBack!(cellView?.detailtextField.stringValue ?? "")
+            }
+        }
+    }
+
+    @IBAction func buttonClicked_addNewInfo(_ sender: AnyObject?) {
+        let dict: [String : String] = ["" : ""]
+        KMProfileInfo.shared().insertObject(dict, inCustomInfoArrayAt: KMProfileInfo.shared().customInfoArray.count)
+        
+        self._fetchDisplayKeys()
+        self.tableView.reloadData()
+        if (self.tableView.numberOfRows > 1) {
+            self.tableView.scrollRowToVisible(self.tableView.numberOfRows - 1)
+            let set = NSIndexSet(index: self.tableView.numberOfRows - 1)
+            self.tableView.selectRowIndexes(set as IndexSet, byExtendingSelection: false)
+            let cellView = self.tableView.view(atColumn: 0, row: self.tableView.selectedRow, makeIfNecessary: false) as? KMProfileCellView
+            cellView?.addButton.isHidden = true
+            cellView?.textField?.becomeFirstResponder()
+        }
+    }
+    
+    @IBAction func buttonClicked_RemoveNewInfo(_ sender: AnyObject?) {
+        let editIndex = self.tableView.selectedRow
+        let customIndex = self.tableContents.index(of: KMLocalizedString("Custom", nil)) ?? NSNotFound
+        if (editIndex - customIndex - 1 < KMProfileInfo.shared().customInfoArray.count) {
+            KMProfileInfo.shared().removeObjectFromCustomInfoArray(at: editIndex - customIndex - 1)
+            self._fetchDisplayKeys()
+            self.tableView.reloadData()
+            self.removeNewInfoButton.isEnabled = false
+        }
+    }
+    
+    // MARK: - NSMenu Action
+    
+    @IBAction func menuItemClicked_Edit(_ sender: AnyObject?) {
+        let cellView = self.tableView.view(atColumn: 0, row: self.tableView.clickedRow, makeIfNecessary: false) as? KMProfileCellView
+        let set = IndexSet(integer: self.tableView.clickedRow)
+        self.tableView.selectRowIndexes(set, byExtendingSelection: false)
+        if let data = cellView?.textField?.isEditable, data {
+            if let data = cellView?.textField?.stringValue.isEmpty, data {
+                cellView?.textField?.becomeFirstResponder()
+            }else {
+                cellView?.detailtextField.becomeFirstResponder()
+            }
+        } else {
+            cellView?.detailtextField.becomeFirstResponder()
+        }
+    }
+    
+    @IBAction func menuItemClicked_Add(_ sender: AnyObject?) {
+        let cellView = self.tableView.view(atColumn: 0, row: self.tableView.clickedRow, makeIfNecessary: false) as? KMProfileCellView
+       if (self.callBack != nil) {
+           self.callBack!(cellView?.detailtextField.stringValue ?? "")
+       }
+    }
+    
+    @IBAction func menuItemClicked_Delete(_ sender: AnyObject?) {
+        let editIndex = self.tableView.clickedRow
+        let customIndex = self.tableContents.index(of: KMLocalizedString("Custom", nil)) ?? NSNotFound
+        if (editIndex < customIndex) {
+            switch (editIndex) {
+                case 1:
+                    KMProfileInfo.shared().fullName = ""
+                    break;
+                case 2:
+                    KMProfileInfo.shared().firstName = ""
+                    break;
+                case 3:
+                    KMProfileInfo.shared().middleName = ""
+                    break;
+                case 4:
+                    KMProfileInfo.shared().lastName = ""
+                    break;
+                case 6:
+                    KMProfileInfo.shared().street1 = ""
+                    break;
+                case 7:
+                    KMProfileInfo.shared().street2 = ""
+                    break;
+                case 8:
+                    KMProfileInfo.shared().city = ""
+                    break;
+                case 9:
+                KMProfileInfo.shared().state = ""
+                    break;
+                case 10:
+                KMProfileInfo.shared().zip = ""
+                    break;
+                case 11:
+                KMProfileInfo.shared().country = ""
+                    break;
+                case 13:
+                KMProfileInfo.shared().email = ""
+                    break;
+                case 14:
+                KMProfileInfo.shared().tel = ""
+                    break;
+                case 16:
+    //                [KMProfileInfo.shared().date = @"";
+                    break;
+                case 17:
+                KMProfileInfo.shared().birthDate = ""
+                    break;
+                default:
+                    break;
+            }
+        } else {
+            KMProfileInfo.shared().removeObjectFromCustomInfoArray(at: editIndex - customIndex - 1)
+        }
+        self._fetchDisplayKeys()
+        self.tableView.reloadData()
+    }
+}
+
+// MARK: - Private Methods
+
+extension KMProfileInfoWindowController {
+    private func _configuViews() {
+        self.titleLabel.stringValue = KMLocalizedString("My Profile", nil)
+
+        //Button Part
+        self.backButton.title = KMLocalizedString("Cancel", nil)
+        self.addButton.title = KMLocalizedString("Add to Doc", nil)
+        self.addButton.isEnabled = false
+        self.removeNewInfoButton.isEnabled = false
+        //NSMenu Part
+        
+        let editItem = self.tableView.menu?.item(at: 0)
+        let addItem = self.tableView.menu?.item(at: 1)
+        let deleteItem = self.tableView.menu?.item(at: 2)
+        
+        editItem?.title = KMLocalizedString("Edit", nil)
+        addItem?.title = KMLocalizedString("Add to Doc", nil)
+        deleteItem?.title = KMLocalizedString("Delete", nil)
+    }
+    
+    private func _fetchDisplayKeys() {
+        self.tableContents = []
+        self.tableContents.append(KMLocalizedString("Name", nil))
+        self.tableContents.append(KMLocalizedString("Full Name", nil))
+        self.tableContents.append(KMLocalizedString("First Name", nil))
+        self.tableContents.append(KMLocalizedString("Middle Name", nil))
+        self.tableContents.append(KMLocalizedString("Last Name", nil))
+        
+        self.tableContents.append(KMLocalizedString("Address", nil))
+        self.tableContents.append(KMLocalizedString("Street 1", nil))
+        self.tableContents.append(KMLocalizedString("Street 2", nil))
+        self.tableContents.append(KMLocalizedString("City", nil))
+        self.tableContents.append(KMLocalizedString("State", nil))
+        self.tableContents.append(KMLocalizedString("Zip", nil))
+        self.tableContents.append(KMLocalizedString("Country", nil))
+        
+        self.tableContents.append(KMLocalizedString("Contact Information", nil))
+        self.tableContents.append(KMLocalizedString("Email", nil))
+        self.tableContents.append(KMLocalizedString("Tel", nil))
+        
+        self.tableContents.append(KMLocalizedString("Dates", nil))
+        self.tableContents.append(KMLocalizedString("Date", nil))
+        self.tableContents.append(KMLocalizedString("Birth Date", nil))
+        
+        if (KMProfileInfo.shared().customInfoArray.count > 0) {
+            self.tableContents.append(KMLocalizedString("Custom", nil))
+            for i in 0 ..< KMProfileInfo.shared().customInfoArray.count {
+                if let dict: [String : Any] = KMProfileInfo.shared().customInfoArray[i] as? [String : Any], dict.isEmpty == false {
+                    self.tableContents.append(dict.keys.first!)
+                }
+            }
+        }
+    }
+    
+    @objc private func _themeChanged(_ notification: NSNotification) {
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
+            self._updateViewColor()
+        }
+    }
+    
+    private func _updateViewColor() {
+        self.tableView.reloadData()
+    }
+    
+    private func _configuTextField(_ cellView: KMProfileCellView?) {
+        let textField = cellView?.detailtextField
+        let tag = textField?.tag ?? 0
+        var placeHoldString: String = ""
+        var nameString: String = ""
+
+        if (tag == 1) {
+            placeHoldString = KMLocalizedString("Add Full Name", nil)
+            nameString = KMProfileInfo.shared().fullName
+        } else if (tag == 2) {
+            placeHoldString = KMLocalizedString("Add First Name", nil)
+            nameString = KMProfileInfo.shared().firstName
+        } else if (tag == 3) {
+            placeHoldString = KMLocalizedString("Add Middle Name", nil)
+            nameString = KMProfileInfo.shared().middleName
+        } else if (tag == 4) {
+            placeHoldString = KMLocalizedString("Add Last Name", nil)
+            nameString = KMProfileInfo.shared().lastName
+        } else if (tag == 6) {
+            placeHoldString = KMLocalizedString("Add Street 1", nil)
+            nameString = KMProfileInfo.shared().street1
+        } else if (tag == 7) {
+            placeHoldString = KMLocalizedString("Add Street 2", nil)
+            nameString = KMProfileInfo.shared().street2
+        } else if (tag == 8) {
+
+            placeHoldString = KMLocalizedString("Add City", nil)
+            nameString = KMProfileInfo.shared().city
+        } else if (tag == 9) {
+            placeHoldString = KMLocalizedString("Add State", nil)
+            nameString = KMProfileInfo.shared().state
+        } else if (tag == 10) {
+            placeHoldString = KMLocalizedString("Add Zip", nil)
+            nameString = KMProfileInfo.shared().zip
+        } else if (tag == 11) {
+            placeHoldString = KMLocalizedString("Add Country", nil)
+            nameString = KMProfileInfo.shared().country
+        } else if (tag == 13) {
+            placeHoldString = KMLocalizedString("Add Email", nil)
+            nameString = KMProfileInfo.shared().email
+        } else if (tag == 14) {
+            placeHoldString = KMLocalizedString("Add Tel", nil)
+            nameString = KMProfileInfo.shared().tel
+        } else if (tag == 16) {
+            placeHoldString = KMLocalizedString("Add Date", nil)
+            let date = Date()
+            let formatter = DateFormatter()
+            formatter.dateFormat = "YYYY/MM/dd"
+            nameString = formatter.string(from: date)
+        } else if (tag == 17) {
+            placeHoldString = KMLocalizedString("Add Birth Date", nil)
+            nameString = KMProfileInfo.shared().birthDate
+        }
+        textField?.stringValue = nameString
+        if (nameString.isEmpty == false) {
+            textField?.isHidden = false
+            cellView?.addButton.isHidden = true
+        } else {
+            cellView?.addButton.title = placeHoldString
+            textField?.placeholderString = placeHoldString
+            textField?.isHidden = true
+            cellView?.addButton.tag = tag
+            cellView?.addButton.target = self
+            cellView?.addButton.action = #selector(addFileName_Add)
+            cellView?.addButton.setTitleColor(NSColor.systemBlue)
+            cellView?.addButton.isHidden = false
+
+        }
+    }
+
+}
+
+extension KMProfileInfoWindowController: NSTableViewDelegate, NSTableViewDataSource {
+    func numberOfRows(in tableView: NSTableView) -> Int {
+        self.tableContents.count
+    }
+    
+    func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
+        let addingString = self.tableContents[row]
+        let customIndex = self.tableContents.index(of: KMLocalizedString("Custom", nil)) ?? NSNotFound
+        if (addingString == KMLocalizedString("Name", nil) || addingString == KMLocalizedString("Address", nil) || addingString == KMLocalizedString("Contact Information", nil) || addingString == KMLocalizedString("Dates", nil) || addingString == KMLocalizedString("Custom", nil)) && row <= customIndex {
+            return 24.0
+        }
+        return 36.0
+    }
+    
+    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
+        let addingString = self.tableContents[row]
+        let customIndex = self.tableContents.index(of: KMLocalizedString("Custom", nil)) ?? NSNotFound
+        var tableCellView: NSTableCellView?
+        if (addingString == KMLocalizedString("Name", nil) || addingString == KMLocalizedString("Address", nil) || addingString == KMLocalizedString("Contact Information", nil) || addingString == KMLocalizedString("Dates", nil) || addingString == KMLocalizedString("Custom", nil)) && row <= customIndex {
+            tableCellView = (tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: TitleCellIdentifier), owner: tableColumn) as! NSTableCellView)
+            let cellView = tableCellView as! KMProfileTitleCellView
+            cellView.textField?.stringValue = addingString
+            cellView.textField?.isEditable = false
+            cellView.wantsLayer = true
+            if (KMAppearance.isSupportNewColor()) {
+                if (KMAppearance.isDarkMode()) {
+                    cellView.layer?.backgroundColor = NSColor(red: 73/255.0, green: 75/255.0, blue: 77/255.0, alpha: 1).cgColor
+                } else {
+                    cellView.layer?.backgroundColor = NSColor(red: 219/255.0, green: 219/255.0, blue: 219/255.0, alpha: 1).cgColor
+                }
+            } else {
+                cellView.layer?.backgroundColor = NSColor(red: 235.0/255.0, green: 235.0/255.0, blue: 235.0/255.0, alpha: 1).cgColor
+            }
+            
+        } else {
+            tableCellView = (tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: NormalCellIdentifier), owner: tableColumn) as! NSTableCellView)
+            let cellView = tableCellView as? KMProfileCellView
+            cellView?.textField?.stringValue = addingString
+            if let data = cellView?.isKind(of: KMProfileCellView.self), data {
+                cellView?.detailtextField.isHidden = false
+            }
+            cellView?.textField?.textColor = KMAppearance.Layout.h0Color()
+            if (customIndex > row) {
+                cellView?.detailtextField.tag = row
+//                [self configuTextField:cellView];
+                self._configuTextField(cellView)
+                cellView?.textField?.isEditable = false
+                cellView?.textField?.isSelectable = false
+                if addingString == KMLocalizedString("Date", nil) {
+                    cellView?.detailtextField.isEditable = false
+                    cellView?.detailtextField.isSelectable = false
+                }
+
+                cellView?.detailtextField.delegate = self
+            } else {
+                let index = row - customIndex - 1
+                let dict = KMProfileInfo.shared().customInfoArray[index] as? [String : Any]
+                cellView?.addButton.isHidden = true
+                cellView?.detailtextField.stringValue = dict?.values.first as? String ?? ""
+                cellView?.detailtextField.placeholderString = KMLocalizedString("Type Value Here", nil)
+                cellView?.textField?.placeholderString = KMLocalizedString("Type Label Here", nil)
+                cellView?.textField?.isEditable = true
+                cellView?.textField?.isSelectable = true
+                cellView?.detailtextField.isEditable = true
+                cellView?.detailtextField.isSelectable = true
+                cellView?.textField?.delegate = self
+                cellView?.detailtextField.delegate = self
+
+            }
+        }
+        return tableCellView;
+    }
+    
+    func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
+        let addingString = self.tableContents[row]
+        let customIndex = self.tableContents.index(of: KMLocalizedString("Custom", nil)) ?? NSNotFound
+        if (addingString == KMLocalizedString("Name", nil) || addingString == KMLocalizedString("Address", nil) || addingString == KMLocalizedString("Contact Information", nil) || addingString == KMLocalizedString("Dates", nil) || addingString == KMLocalizedString("Custom", nil)) && row <= customIndex {
+            return false
+        }
+        return true
+    }
+    
+    func tableViewSelectionDidChange(_ notification: Notification) {
+        if (self.tableView.selectedRow == NSNotFound || self.tableView.selectedRow == -1) {
+            return;
+        }
+        let cellView = self.tableView.view(atColumn: 0, row: self.tableView.selectedRow, makeIfNecessary: false) as? KMProfileCellView
+        self.addButton.isEnabled = cellView?.detailtextField.stringValue.isEmpty == false
+
+        for i in 0 ..< self.tableView.numberOfRows {
+            let cellView = self.tableView.view(atColumn: 0, row: i, makeIfNecessary: false) as? NSTableCellView
+            if let data = cellView?.isKind(of: KMProfileCellView.self), data {
+                let cellView1 = cellView as! KMProfileCellView
+                if (i == self.tableView.selectedRow) {
+                    cellView1.detailtextField.textColor = .white
+                    cellView1.addButton.setTitleColor(NSColor.white)
+                } else {
+                    cellView1.detailtextField.textColor = NSColor.secondaryLabelColor
+                    cellView1.addButton.setTitleColor(NSColor.systemBlue)
+                }
+            }
+        }
+        let customIndex = self.tableContents.index(of: KMLocalizedString("Custom", nil)) ?? NSNotFound
+        if (self.tableView.selectedRow > customIndex) {
+            self.removeNewInfoButton.isEnabled = true
+        } else {
+            self.removeNewInfoButton.isEnabled = false
+        }
+    }
+}
+
+extension KMProfileInfoWindowController: NSTextFieldDelegate {
+    func controlTextDidChange(_ obj: Notification) {
+        let currentRow = self.tableView.selectedRow
+        if (currentRow == -1) {
+            return
+        }
+        guard let textField = obj.object as? NSTextField else {
+            return
+        }
+        let cellView = self.tableView.view(atColumn: 0, row: currentRow, makeIfNecessary: false) as? KMProfileCellView
+        if (currentRow == 1) {
+            KMProfileInfo.shared().fullName = textField.stringValue;
+        } else if (currentRow == 2) {
+            KMProfileInfo.shared().firstName = textField.stringValue;
+        } else if (currentRow == 3) {
+            KMProfileInfo.shared().middleName = textField.stringValue;
+        } else if (currentRow == 4) {
+            KMProfileInfo.shared().lastName = textField.stringValue;
+        } else if (currentRow == 6) {
+            KMProfileInfo.shared().street1 = textField.stringValue;
+        } else if (currentRow == 7) {
+            KMProfileInfo.shared().street2 = textField.stringValue;
+        } else if (currentRow == 8) {
+            KMProfileInfo.shared().city = textField.stringValue;
+        } else if (currentRow == 9) {
+            KMProfileInfo.shared().state = textField.stringValue;
+        } else if (currentRow == 10) {
+            KMProfileInfo.shared().zip = textField.stringValue;
+        } else if (currentRow == 11) {
+            KMProfileInfo.shared().country = textField.stringValue;
+        } else if (currentRow == 13) {
+            KMProfileInfo.shared().email = textField.stringValue;
+        } else if (currentRow == 14) {
+            KMProfileInfo.shared().tel = textField.stringValue;
+        } else if (currentRow == 16) {
+    //        [KMProfileInfo.shared().date = textField.stringValue;
+        } else if (currentRow == 17) {
+            KMProfileInfo.shared().birthDate = textField.stringValue;
+        } else if (currentRow >= 19 ) {
+            let customIndex = currentRow - 19
+            if (cellView != nil) {
+                let dict = KMProfileInfo.shared().customInfoArray[customIndex] as? [String : Any]
+                let originalKey = dict?.keys.first!
+                let originalValue = dict?.values.first as! String
+                if textField.isEqual(cellView?.textField) {
+                    let newDict = [textField.stringValue : originalValue]
+                    KMProfileInfo.shared().replaceObjectInCustomInfoArray(at: customIndex, with: newDict)
+                } else if textField.isEqual(cellView?.detailtextField) {
+                    let newDict = [originalKey : textField.stringValue]
+                    KMProfileInfo.shared().replaceObjectInCustomInfoArray(at: customIndex, with: newDict)
+                }
+            }
+        }
+        
+        if cellView?.detailtextField.stringValue.isEmpty == false  {
+            self.addButton.isEnabled = true
+        } else {
+            self.addButton.isEnabled = false
+        }
+    }
+    
+    func controlTextDidBeginEditing(_ obj: Notification) {
+         let textField = obj.object as? NSTextField
+//        BOOL isDarkMode = NO;
+//        if (@available(macOS 10.14, *)) {
+//            if ([[NSApplication sharedApplication].effectiveAppearance isEqual: [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]) {
+//                isDarkMode =YES;
+//            }
+//        }
+
+        textField?.textColor = NSColor.labelColor
+    }
+    
+    func controlTextDidEndEditing(_ obj: Notification) {
+        let textField = obj.object as? NSTextField
+        let tag = textField?.tag ?? 0
+        let cellView = self.tableView.view(atColumn: 0, row: tag, makeIfNecessary: false) as? KMProfileCellView
+
+        if let data = cellView?.isKind(of: KMProfileCellView.self), data, tag > 0 {
+            var placeHoldString = ""
+
+            if (tag == 1) {
+                placeHoldString = KMLocalizedString("Add Full Name", nil)
+            } else if (tag == 2) {
+                placeHoldString = KMLocalizedString("Add First Name", nil)
+            } else if (tag == 3) {
+                placeHoldString = KMLocalizedString("Add Middle Name", nil)
+            } else if (tag == 4) {
+                placeHoldString = KMLocalizedString("Add Last Name", nil)
+            } else if (tag == 6) {
+                placeHoldString = KMLocalizedString("Add Street 1", nil)
+            } else if (tag == 7) {
+                placeHoldString = KMLocalizedString("Add Street 2", nil)
+            } else if (tag == 8) {
+                placeHoldString = KMLocalizedString("Add City", nil)
+            } else if (tag == 9) {
+                placeHoldString = KMLocalizedString("Add State", nil)
+            } else if (tag == 10) {
+                placeHoldString = KMLocalizedString("Add Zip", nil)
+            } else if (tag == 11) {
+                placeHoldString = KMLocalizedString("Add Country", nil)
+            } else if (tag == 13) {
+                placeHoldString = KMLocalizedString("Add Email", nil)
+            } else if (tag == 14) {
+                placeHoldString = KMLocalizedString("Add Tel", nil)
+            } else if (tag == 16) {
+                placeHoldString = KMLocalizedString("Add Date", nil)
+            } else if (tag == 17) {
+                placeHoldString = KMLocalizedString("Add Birth Date", nil)
+            }
+
+            if (textField?.stringValue.isEmpty == false) {
+                textField?.textColor = NSColor.secondaryLabelColor
+                textField?.isHidden = false
+                cellView?.addButton.isHidden = true
+            } else {
+    //            textField.hidden = YES; //自定义新增,输入Label后,value为空时推出编辑,就无法填写了
+                textField?.placeholderString = ""
+                cellView?.addButton.isHidden = false
+                cellView?.addButton.tag = tag
+                cellView?.addButton.target = self
+                cellView?.addButton.action = #selector(addFileName_Add)
+                cellView?.addButton.title = placeHoldString
+                cellView?.addButton.setTitleColor(NSColor.systemBlue)
+            }
+        }
+    }
+}
+
+extension KMProfileInfoWindowController: NSMenuItemValidation {
+    func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
+         let cellView = self.tableView.view(atColumn: 0, row: self.tableView.clickedRow, makeIfNecessary: false) as? NSTableCellView
+        if (menuItem.action == #selector(menuItemClicked_Edit)) {
+            if let data = cellView?.isKind(of: KMProfileTitleCellView.self), data {
+                return false
+            } else {
+                let cellView1 = cellView as? KMProfileCellView
+                if (cellView1?.textField?.stringValue == KMLocalizedString("Date", nil)) {
+                    return false
+                }
+                return true
+            }
+        } else if (menuItem.action == #selector(menuItemClicked_Add)) {
+//            if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
+//                return NO;
+//            } else {
+//                KMProfileCellView *cell = (KMProfileCellView *)cellView;
+//                return cell.detailtextField.stringValue.length > 0;
+//            }
+            if let data = cellView?.isKind(of: KMProfileTitleCellView.self), data {
+                return false
+            } else {
+                let cellView1 = cellView as? KMProfileCellView
+                if let data = cellView1?.detailtextField?.stringValue.isEmpty, data {
+                    return false
+                }
+                return true
+            }
+        } else if (menuItem.action == #selector(menuItemClicked_Delete)) {
+//            if ([cellView isKindOfClass:[KMProfileTitleCellView class]]) {
+//                return NO;
+//            } else {
+//                KMProfileCellView *cellView1 = (KMProfileCellView *)cellView;
+//                if ([cellView1.textField.stringValue isEqualToString:NSLocalizedString(@"Date", nil)]) {
+//                    return NO;
+//                }
+//                return YES;
+//            }
+            if let data = cellView?.isKind(of: KMProfileTitleCellView.self), data {
+                return false
+            } else {
+                let cellView1 = cellView as? KMProfileCellView
+                if (cellView1?.textField?.stringValue == KMLocalizedString("Date", nil)) {
+                    return false
+                }
+                return true
+            }
+        }
+        return false
+    }
+}

+ 5 - 5
PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.xib

@@ -128,7 +128,7 @@ DQ
                         </constraints>
                     </customView>
                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HcI-gL-dgj">
-                        <rect key="frame" x="38" y="400" width="37" height="18"/>
+                        <rect key="frame" x="38" y="398" width="37" height="18"/>
                         <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="YeK-uM-b3g">
                             <font key="font" size="13" name="PingFangSC-Regular"/>
                             <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -136,13 +136,13 @@ DQ
                         </textFieldCell>
                     </textField>
                     <scrollView autohidesScrollers="YES" horizontalLineScroll="17" horizontalPageScroll="10" verticalLineScroll="17" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="P2P-jH-JNm">
-                        <rect key="frame" x="40" y="74" width="584" height="325"/>
+                        <rect key="frame" x="40" y="74" width="584" height="323"/>
                         <clipView key="contentView" id="Txz-Kp-TvA">
-                            <rect key="frame" x="1" y="1" width="582" height="323"/>
+                            <rect key="frame" x="1" y="1" width="582" height="321"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
                                 <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="ldR-2V-TXt">
-                                    <rect key="frame" x="0.0" y="0.0" width="582" height="323"/>
+                                    <rect key="frame" x="0.0" y="0.0" width="582" height="321"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
@@ -204,7 +204,7 @@ DQ
                                                         <outlet property="textField" destination="jaJ-ef-ZVq" id="GzH-wx-MQQ"/>
                                                     </connections>
                                                 </tableCellView>
-                                                <tableCellView identifier="TitleCell" id="FUh-ze-Iiz" customClass="KMProfileTitleCellView">
+                                                <tableCellView identifier="TitleCell" id="FUh-ze-Iiz" customClass="KMProfileTitleCellView" customModule="PDF_Master" customModuleProvider="target">
                                                     <rect key="frame" x="0.0" y="17" width="518" height="17"/>
                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                     <subviews>

+ 6 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -3044,6 +3044,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 } else if toolbarItem.itemIdentifier == KMToolbarToolProfileIdentifier {
                     Swift.debugPrint("KMToolbarToolProfileIdentifier ...")
                     let windowC = KMProfileInfoWindowController(windowNibName: "KMProfileInfoWindowController")
+                    windowC.callBack = { [weak self] string in
+//                        if (string.length > 0) {
+//                            [blockSelf.pdfView addTextFieldWithSubType:KMSelfSignAnnotationFreeTextSubType_Profile string:string];
+//                        }
+                        self?.km_endSheet()
+                    }
                     self.km_beginSheet(windowC: windowC)
                 } else if toolbarItem.itemIdentifier == KMToolbarViewSettingIdentifier {
                     Swift.debugPrint("KMToolbarViewSettingIdentifier ...")

+ 3 - 1
PDF Office/PDF Master/Class/Preference/Controller/KMDisplayPreferences.swift

@@ -131,5 +131,7 @@ import Cocoa
 }
 
 extension KMDisplayPreferences: KMPreferencePane {
-    
+    func defaultsDidRevert() {
+        
+    }
 }

+ 7 - 12
PDF Office/PDF Master/Class/Preference/Controller/KMGeneralPreferences.swift

@@ -14,9 +14,10 @@ class KMGeneralPreferences: NSViewController {
      #define AUTOMATICALLYCHECKSFORUPDATES_KEY @"automaticallyChecksForUpdates"
      #define UPDATECHECKINTERVAL_KEY @"updateCheckInterval"
 
-     #define SUScheduledCheckIntervalKey @"SUScheduledCheckInterval"
+     
      */
     private let UPDATEINTERVAL_KEY = "updateInterval"
+    private let SUScheduledCheckIntervalKey = "SUScheduledCheckInterval"
     
     @IBOutlet var updateIntervalPopUpButton: NSPopUpButton!
     
@@ -255,16 +256,6 @@ class KMGeneralPreferences: NSViewController {
              [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
      }
 
-     #pragma mark Hooks
-
-     - (void)defaultsDidRevert {
-         NSTimeInterval interval = [[[NSBundle mainBundle] objectForInfoDictionaryKey:SUScheduledCheckIntervalKey] doubleValue];
-     #if VERSION_DMG
-         [[SUUpdater sharedUpdater] setUpdateCheckInterval:interval];
-         [[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:interval > 0.0];
-     #endif
-     }
-
      @end
 
      */
@@ -313,6 +304,10 @@ extension KMGeneralPreferences {
 
 extension KMGeneralPreferences: KMPreferencePane {
     func defaultsDidRevert() {
-        
+        let interval = Bundle.main.object(forInfoDictionaryKey: SUScheduledCheckIntervalKey)
+    #if VERSION_DMG
+//        [[SUUpdater sharedUpdater] setUpdateCheckInterval:interval];
+//        [[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:interval > 0.0];
+    #endif
     }
 }

+ 3 - 1
PDF Office/PDF Master/Class/Preference/Controller/KMNotesPreferences.swift

@@ -136,5 +136,7 @@ class KMNotesPreferences: NSViewController {
 }
 
 extension KMNotesPreferences: KMPreferencePane {
-    
+    func defaultsDidRevert() {
+        
+    }
 }

+ 37 - 62
PDF Office/PDF Master/Class/Preference/Window/KMPreferenceController.swift

@@ -29,6 +29,9 @@ class KMPreferenceController: NSWindowController {
     var history: [NSViewController]?
     var historyIndex: Int = 0
     var currentPane: KMPreferencePane?
+    
+    private let INITIALUSERDEFAULTS_KEY = "InitialUserDefaults"
+    private let RESETTABLEKEYS_KEY = "ResettableKeys"
     /*
      @class SKIBArray;
      @protocol ;
@@ -151,14 +154,6 @@ class KMPreferenceController: NSWindowController {
     
     
     /*
-
-     #define INITIALUSERDEFAULTS_KEY @"InitialUserDefaults"
-     #define RESETTABLEKEYS_KEY @"ResettableKeys"
-
-     //@synthesize resetButtons;
-
-
-
      - (void)selectPaneWithIdentifier:(NSString *)itemIdentifier {
          [self selectPane:[self preferencePaneForItemIdentifier:itemIdentifier]];
      }
@@ -167,36 +162,6 @@ class KMPreferenceController: NSWindowController {
 
      #pragma mark Actions
 
-
-
-     - (void)resetAllSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
-         if (returnCode == NSAlertFirstButtonReturn) {
-             [[NSUserDefaultsController sharedUserDefaultsController] revertToInitialValues:nil];
-             for (NSViewController<SKPreferencePane> *pane in preferencePanes) {
-                 if ([pane respondsToSelector:@selector(defaultsDidRevert)])
-                     [pane defaultsDidRevert];
-             }
-             
-             //重置OCR后,记录切换值
-             [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"KMStatusPlanPopUpBtnKey"];
-             [[NSUserDefaults standardUserDefaults] synchronize];
-         }
-     }
-
-     - (IBAction)resetAll:(id)sender {
-         NSAlert *alert = [[NSAlert alloc] init];
-         [alert setMessageText:NSLocalizedString(@"Reset all preferences to their original values?", @"Message in alert dialog when pressing Reset All button")];
-         [alert setInformativeText:NSLocalizedString(@"Choosing Reset will restore all settings to the state they were in when PDF Reader Pro Edition was first installed.", @"Informative text in alert dialog when pressing Reset All button")];
-         [alert addButtonWithTitle:NSLocalizedString(@"Reset", @"Button title")];
-         [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Button title")];
-         [alert beginSheetModalForWindow:[self window]
-                           modalDelegate:self
-                          didEndSelector:@selector(resetAllSheetDidEnd:returnCode:contextInfo:)
-                             contextInfo:NULL];
-     }
-
-
-
      - (IBAction)doGoToNextPage:(id)sender {
          NSUInteger itemIndex = [preferencePanes indexOfObject:currentPane];
          if (itemIndex != NSNotFound && ++itemIndex < [preferencePanes count])
@@ -319,18 +284,6 @@ class KMPreferenceController: NSWindowController {
             return
         }
         
-//        NSString *label = [currentPane title];
-//        NSAlert *alert = [[NSAlert alloc] init];
-//        [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"Reset %@ preferences to their original values?", @"Message in alert dialog when pressing Reset All button"), label]];
-//        [alert setInformativeText:[NSString stringWithFormat:, label]];
-//        [alert addButtonWithTitle:NSLocalizedString(@"Reset", @"Button title")];
-//        [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Button title")];
-//        [alert beginSheetModalForWindow:[self window]
-//                          modalDelegate:self
-////                         didEndSelector:@selector(resetCurrentSheetDidEnd:returnCode:contextInfo:)
-//                            contextInfo:NULL];
-        
-        
         let label = (self.currentPane as? NSViewController)?.title ?? ""
         let alert = NSAlert()
         alert.messageText = String(format: KMLocalizedString("Reset %@ preferences to their original values?", "Message in alert dialog when pressing Reset All button"), label)
@@ -339,7 +292,26 @@ class KMPreferenceController: NSWindowController {
         alert.addButton(withTitle: KMLocalizedString("Cancel", "Button title"))
         alert.beginSheetModal(for: self.window!, modalDelegate: self, didEnd: #selector(_resetCurrentSheetDidEnd), contextInfo: nil)
     }
-
+    
+    @IBAction func resetAll(_ sender: AnyObject?) {
+        let alert = NSAlert()
+        alert.messageText = KMLocalizedString("Reset all preferences to their original values?", "Message in alert dialog when pressing Reset All button")
+        alert.informativeText = KMLocalizedString("Choosing Reset will restore all settings to the state they were in when PDF Reader Pro Edition was first installed.", "Informative text in alert dialog when pressing Reset All button")
+        alert.addButton(withTitle: KMLocalizedString("Reset", "Button title"))
+        alert.addButton(withTitle: KMLocalizedString("Cancel", "Button title"))
+        
+        let response = alert.runModal()
+        if (response == .alertFirstButtonReturn) {
+            NSUserDefaultsController.shared.revertToInitialValues(forKeys: nil)
+            for pane in self.preferencePanes! {
+                pane.defaultsDidRevert?()
+            }
+            
+            //重置OCR后,记录切换值
+//            [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"KMStatusPlanPopUpBtnKey"];
+//            [[NSUserDefaults standardUserDefaults] synchronize];
+        }
+    }
 }
 
 // MARK: - Private Methods
@@ -446,17 +418,20 @@ extension KMPreferenceController {
     }
     
     @objc private func _resetCurrentSheetDidEnd(_ alert: NSAlert, _ returnCode: Int, _ contextInfo: Any) {
-//        if (returnCode == NSAlertFirstButtonReturn) {
-//            NSURL *initialUserDefaultsURL = [[NSBundle mainBundle] URLForResource:INITIALUSERDEFAULTS_KEY withExtension:@"plist"];
-//            NSArray *resettableKeys = [[[NSDictionary dictionaryWithContentsOfURL:initialUserDefaultsURL] objectForKey:RESETTABLEKEYS_KEY] objectForKey:[currentPane nibName]];
-//            [[NSUserDefaultsController sharedUserDefaultsController] revertToInitialValuesForKeys:resettableKeys];
-//            if ([currentPane respondsToSelector:@selector(defaultsDidRevert)])
-//                [currentPane defaultsDidRevert];
-//            if ([[currentPane title] isEqualToString:@"OCR"]) { //重置OCR后,记录切换值
-//                [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"KMStatusPlanPopUpBtnKey"];
-//                [[NSUserDefaults standardUserDefaults] synchronize];
-//            }
-//        }
+        if (returnCode == NSApplication.ModalResponse.alertFirstButtonReturn.rawValue) {
+            let initialUserDefaultsURL = Bundle.main.url(forResource: INITIALUSERDEFAULTS_KEY, withExtension: "plist")
+            if let _currentPane = self.currentPane as? NSViewController {
+                let resettableKeys = (NSDictionary(contentsOf: initialUserDefaultsURL!)?.object(forKey: RESETTABLEKEYS_KEY) as? NSDictionary)?.object(forKey: _currentPane.nibName!)
+                if let data = resettableKeys as? [String] {
+                    NSUserDefaultsController.shared.revertToInitialValues(forKeys: data)
+                }
+                self.currentPane?.defaultsDidRevert?()
+//                if ([[currentPane title] isEqualToString:@"OCR"]) { //重置OCR后,记录切换值
+//                    [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"KMStatusPlanPopUpBtnKey"];
+//                    [[NSUserDefaults standardUserDefaults] synchronize];
+//                }
+            }
+        }
     }
 }
 

+ 0 - 2
PDF Office/PDF Master/PDF_Master-Bridging-Header.h

@@ -57,5 +57,3 @@
 #import "KMConvertURLToPDF.h"
 
 #import "NSImage_SKExtensions.h"
-
-#import "KMProfileInfoWindowController.h"