Pārlūkot izejas kodu

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

niehaoyu 3 mēneši atpakaļ
vecāks
revīzija
ca02b1b491

+ 4 - 12
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailView/KMNThumbnailBaseViewController.swift

@@ -165,19 +165,11 @@ class KMNThumbnailBaseViewController: KMNBaseViewController,NSCollectionViewDele
                 indexpaths.insert(indexpath)
             }
             
-            collectionView.selectionIndexPaths = indexpaths
-            
-            if(indexpaths.count > 0) {
-                let firstIndexPath = indexpaths.first
-                
-                let itemFrame = collectionView.frameForItem(at: firstIndexPath!.item)
-                let itemFrameInCollectionView = collectionView.convert(itemFrame, to: self.view)
-                
-                if collectionView.bounds.contains(itemFrameInCollectionView) {
-                } else {
-                    collectionView.scrollToItems(at: indexpaths, scrollPosition: .bottom)
-                }
+            if indexpaths.count > 0 {
+                self.collectionView.scrollToItems(at: indexpaths, scrollPosition: .centeredVertically)
             }
+            
+            self.collectionView.selectionIndexPaths = indexpaths
         }
     }
     

+ 4 - 16
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -716,7 +716,7 @@ struct KMNMWCFlags {
             botaViewController?.leftsideType = .search
         } else if pdfSideBarType == .thumbnail {
             botaViewController?.leftsideType = pdfSideBarType
-            KMPrint(" thumbnail")
+            botaViewController?.currentPageDidChangedAction(listView: listView)
         } else if pdfSideBarType == .outline {
             botaViewController?.outlineViewC.handdler.pdfView = listView
             botaViewController?.leftsideType = pdfSideBarType
@@ -1327,19 +1327,11 @@ struct KMNMWCFlags {
     }
     
     func closeAnnotationPopWindow() {
-        let popWindow = KMNPopOperationWindowController.shared
-        if popWindow.window?.isVisible == true {
-            listView.window?.removeChildWindow(popWindow.window ?? NSWindow())
-            popWindow.window?.close()
-        }
+        KMNPopOperationWindowController.shared.closeWindow(listView: listView)
     }
     
     func closePopContentEditWindow() {
-        let popWindow = KMNPopContentEditWindowController.shared
-        if popWindow.window?.isVisible == true {
-            listView.window?.removeChildWindow(popWindow.window ?? NSWindow())
-            popWindow.window?.close()
-        }
+        KMNPopContentEditWindowController.shared.closeWindow(listView: listView)
     }
     
     func reloadPopUIActiveAnnotations(activeAnnotations:[CPDFAnnotation]) {
@@ -2890,11 +2882,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         
         sideBarController?.reloadPageTurnerData()
         
-        var indexpaths: Set<IndexPath> = []
-        indexpaths.insert(IndexPath(item: listView.currentPageIndex, section: 0))
-        
-        botaViewController?.thumnailViewController?.selectionIndexPaths =  indexpaths
-        botaViewController?.currentPageDidChangedAction(document: pdfView.document)
+        botaViewController?.currentPageDidChangedAction(listView: listView)
         
         //分屏视图
         reloadPDFPageNumberToolbar()

+ 10 - 6
PDF Office/PDF Master/KMClass/Left/KMNLeftSideViewController.swift

@@ -100,6 +100,7 @@ class KMNLeftSideViewController: KMNBaseViewController {
                 headerBoxHeightConst.constant = 40
                 headerBox.contentView = thumbnailHeaderViewController.view
                 bottomBox.contentView = thumnailViewController?.view
+                self.view.layoutSubtreeIfNeeded()
             case .bookmark:
                 headerBoxHeightConst.constant = 0
 
@@ -137,9 +138,7 @@ class KMNLeftSideViewController: KMNBaseViewController {
     
     override func viewDidLoad() {
         super.viewDidLoad()
-        
-        updateUIThemeColor()
-        
+                
         initThumnailView()
     }
     
@@ -171,12 +170,17 @@ class KMNLeftSideViewController: KMNBaseViewController {
         }
     }
     
-    public func currentPageDidChangedAction(document: CPDFDocument?) {
-        guard let theDocument = document, theDocument.isEqual(to: currentDocument) else {
+    public func currentPageDidChangedAction(listView: CPDFListView?) {
+        guard let theDocument = listView?.document, theDocument.isEqual(to: currentDocument) else {
             return
         }
         if leftsideType == .bookmark {
-            bookmarkViewC.currentPageDidChangedAction(document: document)
+            bookmarkViewC.currentPageDidChangedAction(document: currentDocument)
+        } else if leftsideType == .thumbnail {
+            var indexpaths: Set<IndexPath> = []
+            indexpaths.insert(IndexPath(item: listView?.currentPageIndex ?? 0, section: 0))
+            
+            thumnailViewController?.selectionIndexPaths =  indexpaths
         }
     }
 }

+ 17 - 2
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopContentEditWindowController.swift

@@ -531,8 +531,8 @@ class KMNPopContentEditWindowController: KMNBaseWindowController {
     
     weak var listView: CPDFListView?
     
-    var fontPopover:NSPopover?
-    var ObjectPopover:NSPopover?
+    private var fontPopover:NSPopover?
+    private var ObjectPopover:NSPopover?
 
     override func windowDidLoad() {
         super.windowDidLoad()
@@ -679,6 +679,21 @@ class KMNPopContentEditWindowController: KMNBaseWindowController {
         }
     }
     
+    public func closeWindow(listView:CPDFListView?) {
+        if self.window?.isVisible == true {
+            listView?.window?.removeChildWindow(self.window ?? NSWindow())
+            self.window?.close()
+        }
+        
+        if ObjectPopover?.isShown == true {
+            ObjectPopover?.close()
+        }
+        
+        if fontPopover?.isShown == true {
+            fontPopover?.close()
+        }
+    }
+    
     //MARK: - private
     private func congfigFontPopUI() {
         fontNameSelect.properties = ComponentSelectProperties(size: .s,

+ 8 - 8
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopContentEditWindowController.xib

@@ -71,20 +71,19 @@
                                     </constraints>
                                 </box>
                                 <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="Asu-CO-giT">
-                                    <rect key="frame" x="475" y="4" width="37" height="32"/>
+                                    <rect key="frame" x="475" y="3" width="37" height="34"/>
                                     <view key="contentView" id="IEM-hp-v4T">
-                                        <rect key="frame" x="0.0" y="0.0" width="37" height="32"/>
+                                        <rect key="frame" x="0.0" y="0.0" width="37" height="34"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="2aI-ns-oxB" customClass="ComponentCSelectorItem" customModule="KMComponentLibrary">
-                                                <rect key="frame" x="5" y="0.0" width="32" height="32"/>
+                                                <rect key="frame" x="5" y="0.0" width="32" height="34"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="32" id="Ige-a8-PP9"/>
-                                                    <constraint firstAttribute="height" constant="32" id="my5-qW-0aM"/>
                                                 </constraints>
                                             </customView>
                                             <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="Rsf-Ge-bao">
-                                                <rect key="frame" x="0.0" y="8" width="1" height="16"/>
+                                                <rect key="frame" x="0.0" y="9" width="1" height="16"/>
                                                 <view key="contentView" id="MHM-uo-o2D">
                                                     <rect key="frame" x="0.0" y="0.0" width="1" height="16"/>
                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -99,7 +98,8 @@
                                         <constraints>
                                             <constraint firstAttribute="trailing" secondItem="2aI-ns-oxB" secondAttribute="trailing" id="5Lk-LY-Fq8"/>
                                             <constraint firstItem="2aI-ns-oxB" firstAttribute="leading" secondItem="Rsf-Ge-bao" secondAttribute="trailing" constant="4" id="Fpu-CI-Y6v"/>
-                                            <constraint firstItem="2aI-ns-oxB" firstAttribute="centerY" secondItem="IEM-hp-v4T" secondAttribute="centerY" id="HPk-O6-shV"/>
+                                            <constraint firstAttribute="bottom" secondItem="2aI-ns-oxB" secondAttribute="bottom" id="YBG-JT-o51"/>
+                                            <constraint firstItem="2aI-ns-oxB" firstAttribute="top" secondItem="IEM-hp-v4T" secondAttribute="top" id="a9M-Wb-Ogd"/>
                                             <constraint firstItem="Rsf-Ge-bao" firstAttribute="centerY" secondItem="IEM-hp-v4T" secondAttribute="centerY" id="sA4-Ga-cV6"/>
                                             <constraint firstItem="Rsf-Ge-bao" firstAttribute="leading" secondItem="IEM-hp-v4T" secondAttribute="leading" id="ufx-CP-u5S"/>
                                         </constraints>
@@ -107,12 +107,12 @@
                                 </box>
                             </subviews>
                             <constraints>
-                                <constraint firstAttribute="bottom" secondItem="Asu-CO-giT" secondAttribute="bottom" constant="4" id="Igm-Ly-mmW"/>
+                                <constraint firstAttribute="bottom" secondItem="Asu-CO-giT" secondAttribute="bottom" constant="3" id="Igm-Ly-mmW"/>
                                 <constraint firstAttribute="bottom" secondItem="gcY-AN-rME" secondAttribute="bottom" constant="3" id="Na4-OV-xu6"/>
                                 <constraint firstItem="gcY-AN-rME" firstAttribute="top" secondItem="vS3-lN-nYx" secondAttribute="top" constant="3" id="Nd7-Ec-1HX"/>
                                 <constraint firstItem="gcY-AN-rME" firstAttribute="leading" secondItem="vS3-lN-nYx" secondAttribute="leading" constant="8" id="O0m-w4-wnm"/>
                                 <constraint firstAttribute="trailing" secondItem="gcY-AN-rME" secondAttribute="trailing" constant="60" id="Xpm-rN-REZ"/>
-                                <constraint firstItem="Asu-CO-giT" firstAttribute="top" secondItem="vS3-lN-nYx" secondAttribute="top" constant="4" id="d4f-fG-xp1"/>
+                                <constraint firstItem="Asu-CO-giT" firstAttribute="top" secondItem="vS3-lN-nYx" secondAttribute="top" constant="3" id="d4f-fG-xp1"/>
                                 <constraint firstAttribute="trailing" secondItem="Asu-CO-giT" secondAttribute="trailing" constant="8" id="dwx-Ba-0Hq"/>
                             </constraints>
                         </view>

+ 57 - 27
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopOperationWindowController.swift

@@ -593,8 +593,8 @@ class KMNPopOperationWindowController: KMNBaseWindowController {
     @IBOutlet var urlInput: ComponentInput!
     @IBOutlet weak var backUrlWidthConstraint: NSLayoutConstraint!
     
-    var fontPopover:NSPopover?
-    var ObjectPopover:NSPopover?
+    private var fontPopover:NSPopover?
+    private var ObjectPopover:NSPopover?
     
     weak var listView:CPDFListView? {
         didSet {
@@ -794,6 +794,21 @@ class KMNPopOperationWindowController: KMNBaseWindowController {
         }
     }
     
+    public func closeWindow(listView:CPDFListView?) {
+        if self.window?.isVisible == true {
+            listView?.window?.removeChildWindow(self.window ?? NSWindow())
+            self.window?.close()
+        }
+        
+        if ObjectPopover?.isShown == true {
+            ObjectPopover?.close()
+        }
+        
+        if fontPopover?.isShown == true {
+            fontPopover?.close()
+        }
+    }
+    
     //MARK: - private
     private func congfigGeneraPopUI() {
         var colors = KMAnnotationPropertiesColorManager.manager.markHighlightColors
@@ -1054,41 +1069,31 @@ class KMNPopOperationWindowController: KMNBaseWindowController {
     
     @objc func linkGoButtonClicked(_ sender: NSView) {
         if linkType == .url {
-            let webString = urlInput.properties.text
-            linkAnnotation.setDestination(nil)
-
-            let linkUrlPath = KMNTools.judgeWebURL(webString)
-            linkAnnotation.setURL(linkUrlPath)
-            updatePDFViewCallback?()
-
-            if let data = URL(string: linkUrlPath) {
+            guard let webString = linkAnnotation.url() else { return  }
+            if let data = URL(string: webString) {
                 NSWorkspace.shared.open(data)
             }
         } else if linkType == .email {
-            let emailString = urlInput.properties.text
-
-            if !KMNTools.isValidateEmail(emailString) {
+            guard let emailString = linkAnnotation.url() else {
                 let alert = NSAlert()
                 alert.alertStyle = .critical
                 alert.messageText = NSLocalizedString("Invalid Email. Please try again.", comment: "")
                 alert.runModal()
                 return
             }
-            linkAnnotation.setDestination(nil)
-
-            let linkUrlPath = KMNTools.judgeEmailURL(emailString)
-            linkAnnotation.setURL(linkUrlPath)
-            updatePDFViewCallback?()
-
-            NSWorkspace.shared.open(URL(string: linkUrlPath)!)
+            if KMNTools.isValidateEmail(emailString) {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("Invalid Email. Please try again.", comment: "")
+                alert.runModal()
+            } else {
+                NSWorkspace.shared.open(URL(string: emailString)!)
+            }
         } else if linkType == .page {
-            linkAnnotation.setURL(nil)
-
-            let destination = CPDFDestination(document: listView?.document ?? CPDFDocument(), pageIndex: Int(paginationView.properties.currentIndex - 1))
-            linkAnnotation.setDestination(destination)
-            updatePDFViewCallback?()
-
-            listView?.go(to: destination)
+            if let destination = linkAnnotation.destination() {
+                listView?.go(to: destination)
+                closeWindow(listView: listView)
+            }
         }
     }
     
@@ -1166,6 +1171,24 @@ extension KMNPopOperationWindowController: ComponentInputDelegate {
         } else if (inputView == gropNameInput) {
            
         } else if (inputView == urlInput) {
+            if linkType == .email {
+                let emailString = urlInput.properties.text
+                if KMNTools.isValidateEmail(emailString) {
+                    linkAnnotation.setDestination(nil)
+                    
+                    let linkUrlPath = KMNTools.judgeEmailURL(emailString)
+                    linkAnnotation.setURL(linkUrlPath)
+                    updatePDFViewCallback?()
+                    
+                }
+            } else if linkType == .url {
+                let webString = urlInput.properties.text
+                linkAnnotation.setDestination(nil)
+
+                let linkUrlPath = KMNTools.judgeWebURL(webString)
+                linkAnnotation.setURL(linkUrlPath)
+                updatePDFViewCallback?()
+            }
            
         }
     }
@@ -1212,8 +1235,15 @@ extension KMNPopOperationWindowController: ComponentPaginationDelegate {
     public func componentPaginationDidValueChanged(pagination: ComponentPagination) {
         let pageIndex = pagination.properties.currentIndex
         if let page = listView?.document.page(at: UInt(pageIndex)) {
+            
+            linkAnnotation.setURL(nil)
+
+            let destination = CPDFDestination(document: listView?.document ?? CPDFDocument(), pageIndex: Int(paginationView.properties.currentIndex - 1))
+            linkAnnotation.setDestination(destination)
+            
             refreshPageThum()
             reloadPageUrlData()
+            updatePDFViewCallback?()
         }
     }
 }

+ 12 - 12
PDF Office/PDF Master/KMClass/PDFListView/WindowController/KMNPopOperationWindowController.xib

@@ -62,9 +62,9 @@
             <windowStyleMask key="styleMask" fullSizeContentView="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="511" height="42"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/>
-            <view key="contentView" misplaced="YES" id="se5-gp-TjO">
-                <rect key="frame" x="0.0" y="0.0" width="511" height="42"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
+            <view key="contentView" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="503" height="42"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <box boxType="custom" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="iV9-GQ-NJE">
@@ -84,21 +84,20 @@
                                         <constraint firstAttribute="width" constant="452" id="PmJ-AM-Kgc"/>
                                     </constraints>
                                 </box>
-                                <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="34L-Tp-WUP">
-                                    <rect key="frame" x="456" y="4" width="37" height="32"/>
+                                <box boxType="custom" borderType="none" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="34L-Tp-WUP">
+                                    <rect key="frame" x="456" y="3" width="37" height="34"/>
                                     <view key="contentView" id="PYw-kY-DK4">
-                                        <rect key="frame" x="0.0" y="0.0" width="37" height="32"/>
+                                        <rect key="frame" x="0.0" y="0.0" width="37" height="34"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="pfZ-VY-VTh" customClass="ComponentCSelector" customModule="KMComponentLibrary">
-                                                <rect key="frame" x="5" y="-1" width="32" height="34"/>
+                                                <rect key="frame" x="5" y="0.0" width="32" height="34"/>
                                                 <constraints>
-                                                    <constraint firstAttribute="height" constant="34" id="C0F-fj-xCh"/>
                                                     <constraint firstAttribute="width" constant="32" id="NAx-PC-y22"/>
                                                 </constraints>
                                             </customView>
                                             <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="9xa-JY-EhU">
-                                                <rect key="frame" x="0.0" y="8" width="1" height="16"/>
+                                                <rect key="frame" x="0.0" y="9" width="1" height="16"/>
                                                 <view key="contentView" id="QmK-oA-Zno">
                                                     <rect key="frame" x="0.0" y="0.0" width="1" height="16"/>
                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -115,7 +114,8 @@
                                             <constraint firstItem="9xa-JY-EhU" firstAttribute="leading" secondItem="PYw-kY-DK4" secondAttribute="leading" id="AMb-Wj-EcT"/>
                                             <constraint firstItem="9xa-JY-EhU" firstAttribute="centerY" secondItem="PYw-kY-DK4" secondAttribute="centerY" id="Dyx-bM-HEA"/>
                                             <constraint firstAttribute="trailing" secondItem="pfZ-VY-VTh" secondAttribute="trailing" id="S3H-Jd-e8p"/>
-                                            <constraint firstItem="pfZ-VY-VTh" firstAttribute="centerY" secondItem="PYw-kY-DK4" secondAttribute="centerY" id="ivG-at-4Z6"/>
+                                            <constraint firstAttribute="bottom" secondItem="pfZ-VY-VTh" secondAttribute="bottom" id="cwN-Ux-8ga"/>
+                                            <constraint firstItem="pfZ-VY-VTh" firstAttribute="top" secondItem="PYw-kY-DK4" secondAttribute="top" id="zjn-AY-B5B"/>
                                         </constraints>
                                     </view>
                                 </box>
@@ -125,8 +125,8 @@
                                 <constraint firstItem="hK7-nm-yiB" firstAttribute="top" secondItem="9j5-uh-fjw" secondAttribute="top" constant="3" id="Okw-o9-mpa"/>
                                 <constraint firstAttribute="trailing" secondItem="hK7-nm-yiB" secondAttribute="trailing" constant="41" id="TYz-c7-EYo"/>
                                 <constraint firstItem="hK7-nm-yiB" firstAttribute="leading" secondItem="9j5-uh-fjw" secondAttribute="leading" constant="8" id="aAB-Id-B5f"/>
-                                <constraint firstItem="34L-Tp-WUP" firstAttribute="top" secondItem="9j5-uh-fjw" secondAttribute="top" constant="4" id="cwk-Hx-a5r"/>
-                                <constraint firstAttribute="bottom" secondItem="34L-Tp-WUP" secondAttribute="bottom" constant="4" id="feA-Nd-fVt"/>
+                                <constraint firstItem="34L-Tp-WUP" firstAttribute="top" secondItem="9j5-uh-fjw" secondAttribute="top" constant="3" id="cwk-Hx-a5r"/>
+                                <constraint firstAttribute="bottom" secondItem="34L-Tp-WUP" secondAttribute="bottom" constant="3" id="feA-Nd-fVt"/>
                                 <constraint firstAttribute="trailing" secondItem="34L-Tp-WUP" secondAttribute="trailing" constant="8" id="sUj-xQ-GOL"/>
                             </constraints>
                         </view>