Ver código fonte

【2025】【综合】
1、组件库优化
2、密文逻辑调整

niehaoyu 1 mês atrás
pai
commit
61975d1ead

+ 8 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary.xcodeproj/project.pbxproj

@@ -9,6 +9,8 @@
 /* Begin PBXBuildFile section */
 		BB1554722CEAE80300938A06 /* ComponentCPositionItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1554712CEAE80300938A06 /* ComponentCPositionItem.swift */; };
 		BB1554742CEAE80D00938A06 /* ComponentCPositionItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB1554732CEAE80D00938A06 /* ComponentCPositionItem.xib */; };
+		BB40413D2D363EFF00186F52 /* ComponentGroupWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB40413B2D363EFF00186F52 /* ComponentGroupWindowController.swift */; };
+		BB40413E2D363EFF00186F52 /* ComponentGroupWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB40413C2D363EFF00186F52 /* ComponentGroupWindowController.xib */; };
 		BB5A9B922CB64CE800F64C1F /* KMComponentLibrary.docc in Sources */ = {isa = PBXBuildFile; fileRef = BB5A9B912CB64CE800F64C1F /* KMComponentLibrary.docc */; };
 		BB5A9B932CB64CE800F64C1F /* KMComponentLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = BB5A9B902CB64CE800F64C1F /* KMComponentLibrary.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		BB5A9C752CB64D4800F64C1F /* app-variables.json in Resources */ = {isa = PBXBuildFile; fileRef = BB5A9B992CB64D4700F64C1F /* app-variables.json */; };
@@ -192,6 +194,8 @@
 /* Begin PBXFileReference section */
 		BB1554712CEAE80300938A06 /* ComponentCPositionItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentCPositionItem.swift; sourceTree = "<group>"; };
 		BB1554732CEAE80D00938A06 /* ComponentCPositionItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ComponentCPositionItem.xib; sourceTree = "<group>"; };
+		BB40413B2D363EFF00186F52 /* ComponentGroupWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentGroupWindowController.swift; sourceTree = "<group>"; };
+		BB40413C2D363EFF00186F52 /* ComponentGroupWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ComponentGroupWindowController.xib; sourceTree = "<group>"; };
 		BB5A9B8D2CB64CE800F64C1F /* KMComponentLibrary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = KMComponentLibrary.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		BB5A9B902CB64CE800F64C1F /* KMComponentLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMComponentLibrary.h; sourceTree = "<group>"; };
 		BB5A9B912CB64CE800F64C1F /* KMComponentLibrary.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = KMComponentLibrary.docc; sourceTree = "<group>"; };
@@ -945,6 +949,8 @@
 				BB5A9C5B2CB64D4800F64C1F /* ComponentGroupItem.swift */,
 				BB5A9C5A2CB64D4800F64C1F /* ComponentGroupItem.xib */,
 				BBE788462CBCFCD2008086E2 /* ComponentBaseView.swift */,
+				BB40413B2D363EFF00186F52 /* ComponentGroupWindowController.swift */,
+				BB40413C2D363EFF00186F52 /* ComponentGroupWindowController.xib */,
 			);
 			path = GroupItem;
 			sourceTree = "<group>";
@@ -1114,6 +1120,7 @@
 				BB5A9CFA2CB64D4800F64C1F /* ComponentDivider.xib in Resources */,
 				BB5A9C9B2CB64D4800F64C1F /* ComponentCardHeader.xib in Resources */,
 				BB5A9CD52CB64D4800F64C1F /* ComponentSliderPoint.xib in Resources */,
+				BB40413E2D363EFF00186F52 /* ComponentGroupWindowController.xib in Resources */,
 				BB5A9CE02CB64D4800F64C1F /* ComponentStepper.xib in Resources */,
 				BB5A9C752CB64D4800F64C1F /* app-variables.json in Resources */,
 				BB5A9CAA2CB64D4800F64C1F /* ComponentProgressPopup.xib in Resources */,
@@ -1239,6 +1246,7 @@
 				BB5A9CB02CB64D4800F64C1F /* ComponentPasswordView.swift in Sources */,
 				BB5A9CD12CB64D4800F64C1F /* ComponentNavbarItemProperty.swift in Sources */,
 				BB5A9D1B2CB64D4800F64C1F /* ComponentLibrary.swift in Sources */,
+				BB40413D2D363EFF00186F52 /* ComponentGroupWindowController.swift in Sources */,
 				BB5A9C962CB64D4800F64C1F /* ComponentCardFile.swift in Sources */,
 				BB5A9C7E2CB64D4800F64C1F /* ComponentSideBarItemProperty.swift in Sources */,
 				BB5A9CA92CB64D4800F64C1F /* ComponentProgressPopup.swift in Sources */,

+ 3 - 1
PDF Office/KMComponentLibrary/KMComponentLibrary/ComponentManager.swift

@@ -14,7 +14,9 @@ class ComponentManager: NSObject {
     private var toolTipWorkItem: DispatchWorkItem?
 
     var isTooltipMode: Bool = false
-    
+
+    let groupWindowController = ComponentGroupWindowController.init(windowNibName: "ComponentGroupWindowController")
+
     override init() {
         super.init()
          

+ 21 - 10
PDF Office/KMComponentLibrary/KMComponentLibrary/View/GroupItem/ComponentGroup.swift

@@ -157,22 +157,30 @@ public class ComponentGroup: NSView, NibLoadable {
     
     public func showWithPoint(_ point: CGPoint, relativeTo positioningView: NSView?) {
         
-        let screenRect = NSScreen.main!.frame
-        let contentWindow: NSWindow = NSWindow(contentRect: screenRect,
-                                               styleMask: [.borderless],
-                                               backing: .buffered, defer: false)
+        var screenRect = NSScreen.main!.frame
+ 
+        if let keyWindow = NSApplication.shared.keyWindow, let screen = keyWindow.screen {
+            screenRect = screen.frame
+        }
+        
+        let windowVC = ComponentManager.manager.groupWindowController
+        windowVC.window?.setFrame(screenRect, display: true)
+        
+        let contentWindow = windowVC.window
         if let window = positioningView?.window {
-            contentWindow.level = window.level + 1
+            windowVC.window?.level = window.level + 1
         }
-        contentWindow.backgroundColor = NSColor.clear
-        contentWindow.makeKeyAndOrderFront(nil)
+        windowVC.window?.backgroundColor = NSColor.clear
+        windowVC.window?.makeKeyAndOrderFront(nil)
         
         if let subView = positioningView {
             var rect = frame
-            rect.origin.x = point.x
-            rect.origin.y = point.y
+            rect.origin.x = point.x - screenRect.origin.x
+            rect.origin.y = point.y - screenRect.origin.y
             rect.origin.x += subView.window?.frame.origin.x ?? 0
             rect.origin.y += subView.window?.frame.origin.y ?? 0
+            
+            rect.origin.y += 24
              
             var viewWidth: CGFloat = CGRectGetWidth(self.frame)
             for item in menuItemArr {
@@ -190,7 +198,9 @@ public class ComponentGroup: NSView, NibLoadable {
             }
             frame = rect
             
-            contentWindow.contentView?.addSubview(self)
+            if let window = windowVC.window {
+                window.contentView?.addSubview(self)
+            }
             
             clearMonitor()
             
@@ -207,6 +217,7 @@ public class ComponentGroup: NSView, NibLoadable {
         if let tempWindow = self.window {
             tempWindow.orderOut(nil)
         }
+        ComponentManager.manager.groupWindowController.close()
         
         removeFromSuperview()
         

+ 18 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/GroupItem/ComponentGroupWindowController.swift

@@ -0,0 +1,18 @@
+//
+//  ComponentGroupWindowController.swift
+//  KMComponentLibrary
+//
+//  Created by Niehaoyu on 2025/1/14.
+//
+
+import Cocoa
+
+class ComponentGroupWindowController: NSWindowController {
+
+    override func windowDidLoad() {
+        super.windowDidLoad()
+
+        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+    }
+    
+}

+ 31 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/GroupItem/ComponentGroupWindowController.xib

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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="22505"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="ComponentGroupWindowController" customModule="KMComponentLibrary" customModuleProvider="target">
+            <connections>
+                <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
+            </connections>
+        </customObject>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" titlebarAppearsTransparent="YES" titleVisibility="hidden" id="F0z-JX-Cv5">
+            <windowStyleMask key="styleMask" titled="YES" fullSizeContentView="YES"/>
+            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+            <rect key="contentRect" x="196" y="240" width="480" height="270"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
+            <view key="contentView" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
+                <autoresizingMask key="autoresizingMask"/>
+            </view>
+            <connections>
+                <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
+            </connections>
+            <point key="canvasLocation" x="188" y="182"/>
+        </window>
+    </objects>
+</document>

+ 29 - 11
PDF Office/KMComponentLibrary/KMComponentLibrary/View/ToolTips/ComponentToolTip.swift

@@ -244,24 +244,42 @@ public class ComponentToolTip: ComponentBaseXibView {
     }
     
     public func showWithPoint(_ point: CGPoint, inView view: NSView?) {
-        let screenRect = NSScreen.main!.frame
-        let contentWindow: NSWindow = NSWindow(contentRect: screenRect,
-                                               styleMask: [.borderless],
-                                               backing: .buffered, defer: false)
-        contentWindow.level = .statusBar
-        contentWindow.backgroundColor = NSColor.clear
-        contentWindow.makeKeyAndOrderFront(nil)
+//        let screenRect = NSScreen.main!.frame
+//        let contentWindow: NSWindow = NSWindow(contentRect: screenRect,
+//                                               styleMask: [.borderless],
+//                                               backing: .buffered, defer: false)
+//        contentWindow.level = .statusBar
+//        contentWindow.backgroundColor = NSColor.clear
+//        contentWindow.makeKeyAndOrderFront(nil)
+        
+        var screenRect = NSScreen.main!.frame
+        
+ 
+        if let keyWindow = NSApplication.shared.keyWindow, let screen = keyWindow.screen {
+            screenRect = screen.frame
+        }
+        
+        let windowVC = ComponentManager.manager.groupWindowController
+        windowVC.window?.setFrame(screenRect, display: true)
+        
+        let contentWindow = windowVC.window
+        windowVC.window?.level = .statusBar
+        windowVC.window?.backgroundColor = NSColor.clear
+        windowVC.window?.makeKeyAndOrderFront(nil)
         
         if let subView = view {
             var rect = frame
-            rect.origin.x = point.x
-            rect.origin.y = point.y
+            rect.origin.x = point.x - screenRect.origin.x
+            rect.origin.y = point.y - screenRect.origin.y
             rect.origin.x += subView.window?.frame.origin.x ?? 0
             rect.origin.y += subView.window?.frame.origin.y ?? 0
             
-            frame = rect
+            rect.origin.y += 20
             
-            contentWindow.contentView?.addSubview(self)
+            frame = rect
+            if let window = contentWindow {
+                window.contentView?.addSubview(self)
+            }
          }
     }
     

+ 19 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -527,6 +527,8 @@ struct KMNMWCFlags {
         listView.pdfListViewDelegate = self
         listView.document = self.document
         listView.pageBreakMargins = NSEdgeInsetsMake(10, 0, 10, 10)
+        listView.hideNotes = false
+        
         reloadPDFSplitInfo()
         
         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.15) {
@@ -727,9 +729,20 @@ struct KMNMWCFlags {
     
     func showOrHideNotes() {
         self.listView.hideNotes = !self.listView.hideNotes
-        if self.listView.hideNotes {
-            listView.annotationType = .unkown
+    
+        let items = [toolbarManager.highlightProperty, toolbarManager.UnderlineProperty,
+                     toolbarManager.wavelineProperty, toolbarManager.strikethroughProperty,
+                     toolbarManager.textProperty, toolbarManager.noteProperty,
+                     toolbarManager.penProperty, toolbarManager.eraserProperty, 
+                     toolbarManager.rectangleProperty, toolbarManager.circleProperty,
+                     toolbarManager.arrowProperty, toolbarManager.lineProperty,
+                     toolbarManager.measureProperty, toolbarManager.stampProperty,
+                     toolbarManager.signProperty]
+        for item in items {
+            item.isDisabled = listView.hideNotes
         }
+        pdfToolbarController?.reloadSecondToolbar(forceRefresh: true)
+        
     }
     
     //MARK: - SplitView
@@ -3972,12 +3985,16 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
             //MARK: -Protect
             if itemIdentifier == KMPDFToolbar_protect_redact_Identifier {
                 
+                toolbarViewModeChanged()
             } else if itemIdentifier == KMPDFToolbar_protect_redact_Property_Identifier {
                 self.showRedactProperty(readactAnnotation: nil)
                 
+                toolbarViewModeChanged()
             } else if itemIdentifier == KMPDFToolbar_protect_redact_Apply_Identifier {
+                toolbarViewModeChanged()
                 
             } else if itemIdentifier == KMPDFToolbar_protect_redact_Exit_Identifier {
+                toolbarViewModeChanged()
                 
             } else if itemIdentifier == KMPDFToolbar_protect_security_Identifier {
                 self.showSecureWindow()

+ 1 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Fill_Tick/FillTickController.swift

@@ -68,7 +68,7 @@ class FillTickController: NSViewController {
     
     func setupProperty() {
         
-        colorLabel.stringValue = KMLocalizedString("Font")
+        colorLabel.stringValue = KMLocalizedString("Color")
         colorLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
         colorLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
         

+ 5 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift

@@ -462,7 +462,7 @@ class KMPDFToolbarController: NSViewController {
         
     }
     
-    func reloadSecondToolbar() {
+    func reloadSecondToolbar(forceRefresh refresh: Bool = false) {
         guard let _manager = self.toolbarManager, let viewManager = self.viewManager else {
             return
         }
@@ -476,6 +476,10 @@ class KMPDFToolbarController: NSViewController {
                     secondToolBar.reloadMainPropertys(propertys)
                 } else {
                     //同一种类型
+                    if refresh {
+                        //特殊情况下同一级点击刷新所有item
+                        secondToolBar.reloadMainPropertys(propertys)
+                    }
                 }
             } else {
                 secondToolBar.reloadMainPropertys(propertys)