Ver código fonte

【2025】【Markup】高亮注释属性面板自测优化

niehaoyu 3 meses atrás
pai
commit
263a274f94

+ 7 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Controller/Color/ComponentCColorGroup.swift

@@ -96,17 +96,24 @@ public class ComponentCColorGroup: ComponentBaseXibView {
     
     public func refreshUI() {
         if let subviews = colorContendBox.contentView?.subviews {
+            var isPressed: Bool = false
             for view in subviews {
                 if view is ComponentCColorItem {
                     let itemView = view as! ComponentCColorItem
                     if itemView.properties?.color?.colorToHexString() == currentColor?.colorToHexString() {
                         itemView.properties?.state = .pressed
+                        isPressed = true
                     } else {
                         itemView.properties?.state = .normal
                     }
                     itemView.refreshUI()
                 }
             }
+            if isPressed == false, let color = currentColor {
+                customColorItem.properties?.color = currentColor
+                customColorItem.properties?.state = .pressed
+                customColorItem.refreshUI()
+            }
         }
         
         if customColorItem.properties?.color?.colorToHexString() != currentColor?.colorToHexString() {

+ 1 - 7
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Dropdown/ComponentDropdown.swift

@@ -260,13 +260,7 @@ public class ComponentDropdown: ComponentBaseXibView {
     
     public override func mouseDown(with event: NSEvent) {
         super.mouseDown(with: event)
-        
-//        if properties.isDisabled == false {
-//            properties.state = .pressed
-//        }
-//        
-//        refreshUI()
-        
+       
     }
     
     public override func mouseUp(with event: NSEvent) {

+ 1 - 6
PDF Office/PDF Master/AppDelegate.swift

@@ -405,12 +405,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
             NSApp.appearance = NSAppearance(named: .darkAqua)
         } else {
             NSApp.appearance = NSAppearance(named: .aqua)
-        }
-//        if let data = NSApp.appearance?.name, data == .darkAqua {
-//            NSApp.appearance = .init(named: .aqua)
-//        } else {
-//            NSApp.appearance = .init(named: .darkAqua)
-//        }
+        } 
         NotificationCenter.default.post(name: Notification.Name(rawValue: "kEffectiveAppearance"), object: nil)
     }
     

+ 21 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+AnnotationsCompare.swift

@@ -52,6 +52,27 @@ extension CPDFListView {
         return false
     }
     
+    //MARK: -判断Markup注释是否存在不同类型
+    class func isMarkupAnnotationsContainMultiType(_ annotations: [CPDFMarkupAnnotation]) -> Bool {
+        if annotations.count < 2 {
+            return false
+        }
+        
+        guard let firstAnnotation = annotations.first else {
+            return false
+        }
+        let markupType = firstAnnotation.markupType()
+        
+        for annotation in annotations {
+            if firstAnnotation != annotation {
+                if markupType != annotation.markupType() {
+                    return true
+                }
+            }
+        }
+        return false
+    }
+    
     //MARK: -比较注释中是否存在不同属性的参数
     static func isAnnotationsContainMultiType(_ annotations: [CPDFAnnotation], withType type: CPDFAnnotationCompareType) -> Bool {
         if annotations.count < 2 {

+ 14 - 4
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/KMRightSideController.swift

@@ -24,6 +24,7 @@ class KMRightSideController: NSViewController {
     @IBOutlet var headerRightButton: ComponentButton!
     
     @IBOutlet var infoContendView: NSView!
+    @IBOutlet var infoContendTopConst: NSLayoutConstraint!
     
     @IBOutlet var emptyView: ComponentEmpty!
     
@@ -397,12 +398,22 @@ class KMRightSideController: NSViewController {
         
         updateTitleLabel()
         
+    }
+    
+    //MARK: - reloadData
+    func reloadContendTopConst() {
+        infoContendTopConst.constant = 40
+        headerBGView.isHidden = false
         
-        
+        if contentViewController is KMHighlightController {
+             if CPDFListView.isMarkupAnnotationsContainMultiType((contentViewController as! KMHighlightController).getValidAnnotations()) {
+                infoContendTopConst.constant = 0
+                 headerBGView.isHidden = true
+            }
+        }
         
     }
     
-    //MARK: - reloadData
     func reloadData() {
         let toolMode = viewManager?.toolMode ?? .None
         
@@ -485,8 +496,7 @@ class KMRightSideController: NSViewController {
             
         }
         
-        
-        
+        reloadContendTopConst()
     }
     
     public func reloadDataWithPDFView(pdfView: CPDFListView) {

+ 2 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/KMRightSideController.xib

@@ -13,6 +13,7 @@
                 <outlet property="emptyView" destination="caV-0D-KSQ" id="y5j-1P-GHx"/>
                 <outlet property="headerBGView" destination="TcN-JR-Ldb" id="0Ok-kE-c9g"/>
                 <outlet property="headerRightButton" destination="Rab-FM-SLM" id="y9O-Jc-gdm"/>
+                <outlet property="infoContendTopConst" destination="9KZ-nk-eKv" id="V69-0z-j5S"/>
                 <outlet property="infoContendView" destination="5et-6F-yVg" id="ibb-Ic-3DS"/>
                 <outlet property="titleLabel" destination="Rtf-SN-4Bo" id="ddV-ja-Zc8"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
@@ -83,8 +84,8 @@
                     <constraints>
                         <constraint firstItem="TcN-JR-Ldb" firstAttribute="top" secondItem="Sx1-Eg-QqT" secondAttribute="top" id="132-Pn-4jc"/>
                         <constraint firstItem="caV-0D-KSQ" firstAttribute="centerX" secondItem="Sx1-Eg-QqT" secondAttribute="centerX" id="90h-pt-GqT"/>
+                        <constraint firstItem="5et-6F-yVg" firstAttribute="top" secondItem="Sx1-Eg-QqT" secondAttribute="top" constant="40" id="9KZ-nk-eKv"/>
                         <constraint firstAttribute="trailing" secondItem="TcN-JR-Ldb" secondAttribute="trailing" id="G1x-eP-gh9"/>
-                        <constraint firstItem="5et-6F-yVg" firstAttribute="top" secondItem="TcN-JR-Ldb" secondAttribute="bottom" id="IVU-aY-91O"/>
                         <constraint firstItem="dWX-cw-Vye" firstAttribute="leading" secondItem="Sx1-Eg-QqT" secondAttribute="leading" id="SW9-wy-hTa"/>
                         <constraint firstAttribute="bottom" secondItem="5et-6F-yVg" secondAttribute="bottom" id="Ymu-ti-PuI"/>
                         <constraint firstItem="5et-6F-yVg" firstAttribute="leading" secondItem="Sx1-Eg-QqT" secondAttribute="leading" id="aSN-4h-8FS"/>

+ 18 - 6
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Highlight/KMHighlightController.swift

@@ -16,6 +16,12 @@ class KMHighlightController: NSViewController {
     @IBOutlet var colorSlider: ComponentSlider!
     @IBOutlet var colorOpacitySelect: ComponentSelect!
     
+    private var colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: NSColor.clear)
+    private var colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: NSColor.clear)
+    private var colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: NSColor.clear)
+    private var colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: NSColor.clear)
+    private var colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: NSColor.clear)
+    
     private var annotations: [CPDFMarkupAnnotation] = []
     
     var pdfView: CPDFListView?
@@ -35,6 +41,10 @@ class KMHighlightController: NSViewController {
         setupProperty()
     }
     
+    func getValidAnnotations() -> [CPDFMarkupAnnotation] {
+        return annotations
+    }
+    
     func setupProperty() {
         
         colorLabel.stringValue = KMLocalizedString("Font")
@@ -99,11 +109,13 @@ class KMHighlightController: NSViewController {
                     colors = manager.markOtherColors
                 }
             }
-            let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[0])
-            let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[1])
-            let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[2])
-            let colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[3])
-            let colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: colors[4])
+            if colors.count > 4 {
+                colorAProperty.color = colors[0]
+                colorBProperty.color = colors[1]
+                colorCProperty.color = colors[2]
+                colorDProperty.color = colors[3]
+                colorEProperty.color = colors[4]
+            }
             colorGroup.setUpWithColorPropertys([colorAProperty, colorBProperty, colorCProperty, colorDProperty], customItemProperty: colorEProperty)
         }
         
@@ -148,7 +160,7 @@ class KMHighlightController: NSViewController {
         } else {
             let multiColor: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .color)
             if multiColor == true {
-                colorGroup.currentColor = NSColor.clear
+                colorGroup.currentColor = nil
             } else {
                 colorGroup.currentColor = firstAnnotation?.color
             }

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

@@ -488,11 +488,32 @@ class KMPDFToolbarController: NSViewController {
         secondToolBar.reloadRightview()
     }
     
+    //MARK: - 取消二级工具栏按钮选中状态
+    func cancelSelectedSecondToolbarItems(_ toolMode: KMPDFToolsMode) {
+        guard let _manager = self.toolbarManager, let viewManager = self.viewManager else {
+            return
+        }
+        
+        let propertys = _manager.getSubToolbarItems(toolMode)
+        for property in propertys {
+            if property is ComponentButtonProperty {
+                (property as! ComponentButtonProperty).state = .normal
+            } else if property is ComponentDropdownToolProperty {
+                (property as! ComponentDropdownToolProperty).state = .normal
+            } else if property is ComponentSelectProperties {
+                (property as! ComponentSelectProperties).state = .normal
+            }
+        }
+    }
+    
+    //MARK: - Action点击
     func clickWithIdentify(_ identify: String) {
         guard let _ = self.toolbarManager, let viewManager = self.viewManager else {
             return
         }
+        
         if identify == KMPDFToolbar_PageEdit_Identifier {
+            //MARK: -页面编辑
             pageButton.properties.state = viewManager.isPageEditMode ? .pressed : .normal
             pageButton.reloadData()
             
@@ -587,12 +608,14 @@ class KMPDFToolbarController: NSViewController {
             return
         }
         if sender.properties == toolbarManager.viewProperty {
+            //MARK: -View
             viewManager.showDisplayView = !viewManager.showDisplayView
             
             sender.properties.state = viewManager.showDisplayView ? .pressed : .normal
             sender.reloadData()
             
         } else if sender.properties == toolbarManager.pageProperty {
+            //MARK: -页面编辑
             viewManager.isPageEditMode = !viewManager.isPageEditMode
             
             sender.properties.state = viewManager.isPageEditMode ? .pressed : .normal
@@ -600,6 +623,7 @@ class KMPDFToolbarController: NSViewController {
             
             viewManager.toolMode = .None
         } else if sender.properties == toolbarManager.rightViewProperty {
+            //MARK: -属性栏
             viewManager.showRightSide = !viewManager.showRightSide
             
         }
@@ -898,7 +922,7 @@ extension KMPDFToolbarController: ComponentSelectZoomDelegate {
     
 }
 
-//MARK: - ComponentTabsDelegate
+//MARK: - ComponentTabsDelegate:一级工具栏
 extension KMPDFToolbarController: ComponentTabsDelegate {
     func componentTabsDidSelected(_ view: ComponentTabs, _ property: ComponentTabsProperty) {
         guard let toolbarManager = self.toolbarManager, let _manager = self.viewManager else {
@@ -916,6 +940,9 @@ extension KMPDFToolbarController: ComponentTabsDelegate {
         if property == toolbarManager.markupMode_Property {
             if _manager.toolMode == .Markup {
                 _manager.toolMode = .None
+                
+                cancelSelectedSecondToolbarItems(.Markup)
+                
                 property.state = .normal
                 view.refreshItems()
             } else {
@@ -925,6 +952,9 @@ extension KMPDFToolbarController: ComponentTabsDelegate {
         } else if property == toolbarManager.editMode_Property {
             if _manager.toolMode == .Edit {
                 _manager.toolMode = .None
+                
+                cancelSelectedSecondToolbarItems(.Edit)
+                
                 property.state = .normal
                 view.refreshItems()
             } else {
@@ -934,6 +964,9 @@ extension KMPDFToolbarController: ComponentTabsDelegate {
         } else if property == toolbarManager.formMode_Property {
             if _manager.toolMode == .Form {
                 _manager.toolMode = .None
+                
+                cancelSelectedSecondToolbarItems(.Form)
+                
                 property.state = .normal
                 view.refreshItems()
             } else {
@@ -943,6 +976,9 @@ extension KMPDFToolbarController: ComponentTabsDelegate {
         } else if property == toolbarManager.fillMode_Property {
             if _manager.toolMode == .Fill {
                 _manager.toolMode = .None
+                
+                cancelSelectedSecondToolbarItems(.Fill)
+                
                 property.state = .normal
                 view.refreshItems()
             } else {
@@ -952,6 +988,9 @@ extension KMPDFToolbarController: ComponentTabsDelegate {
         } else if property == toolbarManager.convertMode_Property {
             if _manager.toolMode == .Convert {
                 _manager.toolMode = .None
+                
+                cancelSelectedSecondToolbarItems(.Convert)
+                
                 property.state = .normal
                 view.refreshItems()
             } else {
@@ -961,6 +1000,9 @@ extension KMPDFToolbarController: ComponentTabsDelegate {
         } else if property == toolbarManager.protectMode_Property {
             if _manager.toolMode == .Protect {
                 _manager.toolMode = .None
+                
+                cancelSelectedSecondToolbarItems(.Protect)
+                
                 property.state = .normal
                 view.refreshItems()
             } else {
@@ -971,6 +1013,8 @@ extension KMPDFToolbarController: ComponentTabsDelegate {
             if _manager.toolMode == .Tools {
                 _manager.toolMode = .None
                 
+                cancelSelectedSecondToolbarItems(.Tools)
+                
                 property.state = .normal
                 view.refreshItems()
             } else {

+ 17 - 114
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -2310,6 +2310,21 @@
                   endingLineNumber = "301"
                   offsetFromSymbolStart = "9132">
                </Location>
+               <Location
+                  uuid = "8E901A1F-2E46-45A2-8AAA-ABB5D9E11491 - da5f8849423c2d45"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMMainViewController.changeAnnotationModeAction(item: PDF_Reader_Pro.KMToolbarClickButton) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "301"
+                  endingLineNumber = "301"
+                  offsetFromSymbolStart = "9152">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -4326,22 +4341,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "8C25BC59-319D-4D56-98EE-5735ED8A786D"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "KMComponentLibrary/KMComponentLibrary/View/Dropdown/ComponentDropdown.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "262"
-            endingLineNumber = "262"
-            landmarkName = "mouseDown(with:)"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -4518,54 +4517,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "9B544E8F-D072-4625-B7FD-412A6A5C4364"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/KMClass/Tools/Base/KMNBaseWindowController.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "69"
-            endingLineNumber = "69"
-            landmarkName = "mouseDown(with:)"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "9B544E8F-D072-4625-B7FD-412A6A5C4364 - bf913be03917b8ce"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMNBaseWindowController.showWindow(Swift.Optional&lt;Any&gt;) -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/KMClass/Tools/Base/KMNBaseWindowController.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "69"
-                  endingLineNumber = "69"
-                  offsetFromSymbolStart = "68">
-               </Location>
-               <Location
-                  uuid = "9B544E8F-D072-4625-B7FD-412A6A5C4364 - 6b695b282b75c710"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMNBaseWindowController.mouseDown(with: __C.NSEvent) -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/KMClass/Tools/Base/KMNBaseWindowController.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "69"
-                  endingLineNumber = "69"
-                  offsetFromSymbolStart = "236">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -4661,22 +4612,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "AEB6400E-FEA1-4091-9717-9FA7D932ED96"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "492"
-            endingLineNumber = "492"
-            landmarkName = "clickWithIdentify(_:)"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -4687,42 +4622,10 @@
             filePath = "PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1080"
-            endingLineNumber = "1080"
+            startingLineNumber = "1124"
+            endingLineNumber = "1124"
             landmarkName = "componentGroupDidSelect(group:menuItemProperty:)"
             landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "343E7BFB-E0E6-4622-82D3-22CE9BA091CD - 1f09890bef133f6c"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMPDFToolbarController.componentGroupDidSelect(group: Swift.Optional&lt;KMComponentLibrary.ComponentGroup&gt;, menuItemProperty: Swift.Optional&lt;KMComponentLibrary.ComponentMenuitemProperty&gt;) -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "1080"
-                  endingLineNumber = "1080"
-                  offsetFromSymbolStart = "3080">
-               </Location>
-               <Location
-                  uuid = "343E7BFB-E0E6-4622-82D3-22CE9BA091CD - 1f09890bef133f6c"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMPDFToolbarController.componentGroupDidSelect(group: Swift.Optional&lt;KMComponentLibrary.ComponentGroup&gt;, menuItemProperty: Swift.Optional&lt;KMComponentLibrary.ComponentMenuitemProperty&gt;) -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "1080"
-                  endingLineNumber = "1080"
-                  offsetFromSymbolStart = "3040">
-               </Location>
-            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy