Browse Source

【2025】【综合】Form设置优化

niehaoyu 1 month ago
parent
commit
1fd1af59bd

+ 1 - 0
PDF Office/PDF Master/AppDelegate+MenuAction.swift

@@ -851,6 +851,7 @@ extension AppDelegate {
             CPDFKitConfig.sharedInstance().setEnableFormFieldHighlight(!enabled)
             
             mainVC.listView.setNeedsDisplayForVisiblePages()
+            mainVC.alertTipViewController.reloadFormAlertUI()
         }
     }
     

+ 23 - 9
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -272,9 +272,6 @@ struct KMNMWCFlags {
         
         setupUI()
         
-        NotificationCenter.default.addObserver(self, selector: #selector(pdfViewScrollViewDidScroll), name: NSScrollView.didLiveScrollNotification, object: listView.documentView())
-        NotificationCenter.default.addObserver(self, selector: #selector(pageCountChangedNotification), name: NSNotification.Name.CPDFDocumentPageCountChanged, object: listView.document)
-         
     }
     
     override func viewDidAppear() {
@@ -434,8 +431,19 @@ struct KMNMWCFlags {
     
     private func addNotificationCenter() {
         NotificationCenter.default.addObserver(self, selector: #selector(annotationsAttributeHasChange), name: NSNotification.Name.CPDFListViewAnnotationsAttributeHasChange, object:nil)
+         NotificationCenter.default.addObserver(self, selector: #selector(signatureStateChangeNoti), name: NSNotification.Name(rawValue: "CSignatureTrustCerDidChangeNotification"), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(pdfViewScrollViewDidScroll), name: NSScrollView.didLiveScrollNotification, object: listView.documentView())
+        NotificationCenter.default.addObserver(self, selector: #selector(pageCountChangedNotification), name: NSNotification.Name.CPDFDocumentPageCountChanged, object: listView.document)
+        NotificationCenter.default.addObserver(self, selector: #selector(documentDidUnlockNotification), name: Notification.Name("CPDFDocumentDidUnlockNotification"), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(applicationWillTerminateNotification), name: NSApplication.willTerminateNotification, object: nil)
         
-        NotificationCenter.default.addObserver(self, selector: #selector(signatureStateChangeNoti), name: NSNotification.Name(rawValue: "CSignatureTrustCerDidChangeNotification"), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(pdfViewHighlightFormFiledUpdateNoti), name: kPDFViewHighlightFormFiledUpdateNotiName, object: nil)
+ 
+
+    }
+    
+    internal func removeNotifications() {
+        NotificationCenter.default.removeObserver(self)
         
     }
     
@@ -462,7 +470,9 @@ struct KMNMWCFlags {
         } else if SettingsManager.sharedInstance.leftPanelType == .hideLeftSide {
             viewManager.pdfSideBarType = .none
         } else if SettingsManager.sharedInstance.leftPanelType == .prioritizeOutline {
-            
+            if let rootOutline = self.listView.document.outlineRoot(), rootOutline.numberOfChildren > 0 {
+                viewManager.pdfSideBarType = .outline
+            }
         }
         if viewManager.pdfSideBarType == .none {
             toggleCloseLeftSide()
@@ -3123,6 +3133,7 @@ struct KMNMWCFlags {
         CPDFKitConfig.sharedInstance().setEnableFormFieldHighlight(!enabled)
         
         listView.setNeedsDisplayForVisiblePages()
+        self.alertTipViewController.reloadFormAlertUI()
     }
     
     //MARK: - 高亮Link
@@ -4045,6 +4056,7 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
                 CPDFAnnotation.updateHighlightFormFiled(listView, highlightFormFiled: !value)
                 
                 self.toolbarManager.refreshDefaultConfigItem()
+                self.alertTipViewController.reloadFormAlertUI()
                 
             } else if itemIdentifier == KMPDFToolbar_form_ShowName_Identifier {
                 listView.showFormFieldName = !listView.showFormFieldName
@@ -4937,6 +4949,7 @@ extension KMMainViewController: KMBatesControllerDelegate {
 //MARK: - CPDFViewDelegate PDFView代理
 
 extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
+    
     func pdfViewDocumentDidLoaded(_ pdfView: CPDFView!) {
         sideBarController?.reloadPageTurnerData()
         
@@ -7010,10 +7023,6 @@ extension KMMainViewController : CDistanceSettingWindowControllerDelegate {
 //MARK: - extension
 extension KMMainViewController {
     
-    internal func removeNotifications() {
-        NotificationCenter.default.removeObserver(self)
-        
-    }
     
     func removeAllAnnotations() {
         let alert = NSAlert()
@@ -7870,4 +7879,9 @@ extension KMMainViewController {
         self.saveDocument()
     }
     
+    internal func pdfViewHighlightFormFiledUpdateNoti(_ sender: Notification) {
+        self.alertTipViewController.reloadFormAlertUI()
+        
+    }
+    
 }

+ 2 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>

+ 9 - 0
PDF Office/PDF Master/KMClass/PDFListView/ViewController/KMNAlertTipViewController.swift

@@ -121,6 +121,15 @@ class KMNAlertTipViewController: KMNBaseViewController {
                    formComponentAlert.autoresizingMask = .width
                    self.view.addSubview(formComponentAlert)
                }
+               
+               let highlightFormFiled = CPDFKitConfig.sharedInstance().enableFormFieldHighlight()
+               var detailButtonString = ""
+               if highlightFormFiled {
+                   detailButtonString = KMLocalizedString("Disable Highlight Effect")
+               } else {
+                   detailButtonString = KMLocalizedString("Highlight Form Fields")
+               }
+               formComponentAlert.properties.detailButtonString = detailButtonString
                formComponentAlert.reloadData()
            } else {
                if formComponentAlert.superview != nil {