Sfoglia il codice sorgente

偏好设置-通用设置补充交互

tangchao 1 anno fa
parent
commit
b843b107ad

BIN
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 0
PDF Office/PDF Office/AppDelegate.swift

@@ -58,6 +58,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
         DBClientsManager.setup(withAppKeyDesktop: "jxjlqfm1cfp2mjj")
         
         reopenDocument(forPaths: [])
+        
+        KMPreferenceManager.shared.author = NSFullUserName()
     }
     
     func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

+ 3 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift

@@ -89,6 +89,9 @@ extension KMMainViewController {
             self.listView.layoutDocumentView()
         }
         self.updatePageIndicatoreType()
+        if (info.keys.contains(KMGeneralAuthorNameKey)) { // 作者名称
+            CPDFKitConfig.sharedInstance().setAnnotationAuthor((info[KMGeneralAuthorNameKey] as! String))
+        }
     }
     
     func updatePageIndicatoreType () {

+ 4 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -80,6 +80,10 @@ import Cocoa
     var openSecondaryPdfView: KMSecondaryViewController?
     var secondaryPdfContentView: NSView?
     var lastSplitPDFHeight: Float?
+    
+    deinit {
+        NotificationCenter.default.removeObserver(self)
+    }
 
     override func awakeFromNib() {
         super.awakeFromNib()

+ 15 - 3
PDF Office/PDF Office/Class/Preference/Tools/KMPreferenceManager.swift

@@ -192,7 +192,12 @@ class KMPreferenceManager: NSObject {
             
         }
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-            NotificationCenter.default.post(name: NSNotification.Name(rawValue: KMPreferenceDidChangeNotificationName), object: [group])
+            let info: [String : Any]? = UserDefaults.standard.value(forKey: KMPreferenceInfoKey) as? [String : Any]
+            var groupInfo: [KMPreferenceKey : Any]?
+            if (info != nil) {
+                groupInfo = info![group.rawValue] as? [KMPreferenceKey : Any]
+            }
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: KMPreferenceDidChangeNotificationName), object: [group], userInfo: groupInfo != nil ? groupInfo : [:])
         }
     }
     
@@ -202,7 +207,14 @@ class KMPreferenceManager: NSObject {
         UserDefaults.standard.synchronize()
         
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-            NotificationCenter.default.post(name: NSNotification.Name(rawValue: KMPreferenceDidChangeNotificationName), object: [KMPreferenceGroup.general, KMPreferenceGroup.display, KMPreferenceGroup.markup, KMPreferenceGroup.infomation, KMPreferenceGroup.other])
+            var groppInfos: [KMPreferenceKey : Any] = [:]
+            for groupInfo in info.values {
+                for (key, value) in groupInfo {
+                    groppInfos.updateValue(value, forKey: key)
+                }
+            }
+            
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: KMPreferenceDidChangeNotificationName), object: [KMPreferenceGroup.general, KMPreferenceGroup.display, KMPreferenceGroup.markup, KMPreferenceGroup.infomation, KMPreferenceGroup.other], userInfo: groppInfos)
         }
     }
     
@@ -283,7 +295,7 @@ class KMPreferenceManager: NSObject {
                                                                          KMOpenImageFileTypeKey : 0,
                                                                        KMSetDefaultPDFReaderKey : true,
                                                                           KMSavePasswordTypeKey : 2,
-                                                                         KMGeneralAuthorNameKey : "Kdanmobile"],
+                                                                         KMGeneralAuthorNameKey : NSFullUserName()],
                 KMPreferenceGroup.display.rawValue : [KMViewPageDisplayTypeKey : 1,
                                                         KMViewZoomScaleTypeKey : 0,
                                                       KMLeftSideDisplayTypeKey : 0,