Ver Fonte

【2025】【综合】分屏视图支持拖动文件

niehaoyu há 5 dias atrás
pai
commit
9dc57d1410

+ 28 - 4
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/KMHomeDragView.swift

@@ -21,10 +21,21 @@ class KMHomeDragView: NSView {
 
     open weak var delegate: KMHomeDragViewDelegate?
 
+    var onlySupportPDF = false
     var isDraggingEntered = false
     
     // MARK: Init
     
+    convenience init() {
+        self.init(frame: .zero)
+         
+        initializeUI()
+        
+        dragView.isHidden = true
+        
+        self.registerForDraggedTypes([NSPasteboard.PasteboardType.fileURL])
+    }
+    
     override func awakeFromNib() {
         super.awakeFromNib()
         
@@ -93,11 +104,24 @@ class KMHomeDragView: NSView {
                 break
             }
             let type = path!.pathExtension.lowercased()
-            if (KMTools.isPDFType(type) || KMTools.isImageType(type) || KMTools.isOfficeType(type)) {} else {
-                canAdd = false
-                self.delegate?.homeDragView?(self, notSupport: true)
-                break
+            if self.onlySupportPDF == true {
+                if KMTools.isPDFType(type) {
+                    
+                } else {
+                    canAdd = false
+                    self.delegate?.homeDragView?(self, notSupport: true)
+                    break
+                }
+            } else {
+                if (KMTools.isPDFType(type) || KMTools.isImageType(type) || KMTools.isOfficeType(type)) {
+                    
+                } else {
+                    canAdd = false
+                    self.delegate?.homeDragView?(self, notSupport: true)
+                    break
+                }
             }
+            
         }
         
         if (canAdd) {

+ 27 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/KMNDisplayViewController/KMSplitPDFViewController/KMSplitPDFViewController.swift

@@ -26,6 +26,8 @@ class KMSplitPDFViewController: KMNBaseViewController {
      
     @IBOutlet var splitToolbar: KMPageNumberPromptView!
     
+    @IBOutlet var dragView: KMHomeDragView!
+    
     var pdfView: CPDFListView?
     var viewManager: KMPDFViewManager?
     
@@ -47,6 +49,9 @@ class KMSplitPDFViewController: KMNBaseViewController {
         
         splitToolbar.delegate = self
         
+        dragView.onlySupportPDF = true
+        dragView.delegate = self
+        
         setupProperty()
         
         reloadData()
@@ -93,6 +98,7 @@ class KMSplitPDFViewController: KMNBaseViewController {
     func reloadData() {
         if let fileURL = viewManager?.splitPDFFileURL {
             emptyView.isHidden = true
+            dragView.isHidden = true
             pdfView?.isHidden = false
             
             let document = CPDFDocument(url: fileURL)
@@ -106,6 +112,8 @@ class KMSplitPDFViewController: KMNBaseViewController {
              
         } else {
             emptyView.isHidden = false
+            dragView.isHidden = false
+            
             pdfView?.isHidden = true
          }
         
@@ -230,3 +238,22 @@ extension KMSplitPDFViewController: KMPageNumberPromptViewDelegate {
         delegate?.splitPDFViewControllerDidUpdatePDFScale?(self)
     }
 }
+
+extension KMSplitPDFViewController: KMHomeDragViewDelegate {
+    func homeDragView(_ viewController: KMHomeDragView, filePath: URL) {
+        self.viewManager?.splitPDFFileURL = filePath
+        
+        let document = CPDFDocument(url: filePath)
+        let isLocked = document?.isLocked ?? false
+        if isLocked {
+            
+        }
+        self.reloadData()
+        
+        self.delegate?.splitPDFViewControllerDidUpdateFilePath?(self)
+    }
+    
+    func homeDragView(_ viewController: KMHomeDragView, notSupport: Bool) {
+         
+    }
+}

+ 38 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/KMNDisplayViewController/KMSplitPDFViewController/KMSplitPDFViewController.xib

@@ -9,6 +9,7 @@
         <customObject id="-2" userLabel="File's Owner" customClass="KMSplitPDFViewController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="contendView" destination="h9a-I9-jjo" id="BRC-SH-k8f"/>
+                <outlet property="dragView" destination="cmG-In-sJm" id="aIe-Ke-snl"/>
                 <outlet property="emptyView" destination="a7b-yc-tgX" id="uD0-vi-qen"/>
                 <outlet property="splitToolbar" destination="qRc-yH-vXE" id="WLN-0D-Ghd"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
@@ -30,6 +31,39 @@
                                 <constraint firstAttribute="width" constant="300" id="hMx-Oj-Sl1"/>
                             </constraints>
                         </customView>
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="cmG-In-sJm" customClass="KMHomeDragView" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
+                            <subviews>
+                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="O3x-A5-qae">
+                                    <rect key="frame" x="208" y="116" width="65" height="40"/>
+                                    <subviews>
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="frK-cQ-Pjd">
+                                            <rect key="frame" x="14" y="12" width="37" height="16"/>
+                                            <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="sUh-Kf-UTg">
+                                                <font key="font" metaFont="system"/>
+                                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                            </textFieldCell>
+                                        </textField>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstAttribute="trailing" secondItem="frK-cQ-Pjd" secondAttribute="trailing" constant="16" id="4aC-6n-wjS"/>
+                                        <constraint firstAttribute="height" constant="40" id="hff-dg-bZq"/>
+                                        <constraint firstItem="frK-cQ-Pjd" firstAttribute="leading" secondItem="O3x-A5-qae" secondAttribute="leading" constant="16" id="pHj-dU-czi"/>
+                                        <constraint firstItem="frK-cQ-Pjd" firstAttribute="centerY" secondItem="O3x-A5-qae" secondAttribute="centerY" id="zT5-jd-epm"/>
+                                    </constraints>
+                                </customView>
+                            </subviews>
+                            <constraints>
+                                <constraint firstItem="O3x-A5-qae" firstAttribute="centerY" secondItem="cmG-In-sJm" secondAttribute="centerY" id="VLd-Fh-7nO"/>
+                                <constraint firstItem="O3x-A5-qae" firstAttribute="centerX" secondItem="cmG-In-sJm" secondAttribute="centerX" id="tus-hO-p0p"/>
+                            </constraints>
+                            <connections>
+                                <outlet property="dragLabel" destination="frK-cQ-Pjd" id="C6N-Lw-YGa"/>
+                                <outlet property="dragView" destination="O3x-A5-qae" id="18O-Jh-yOz"/>
+                                <outlet property="dragViewHeight" destination="hff-dg-bZq" id="ahJ-1s-MLa"/>
+                            </connections>
+                        </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="qRc-yH-vXE" customClass="KMPageNumberPromptView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                             <rect key="frame" x="96" y="20" width="288" height="40"/>
                             <constraints>
@@ -39,9 +73,13 @@
                         </customView>
                     </subviews>
                     <constraints>
+                        <constraint firstItem="cmG-In-sJm" firstAttribute="top" secondItem="h9a-I9-jjo" secondAttribute="top" id="4a3-BU-Ega"/>
+                        <constraint firstAttribute="bottom" secondItem="cmG-In-sJm" secondAttribute="bottom" id="Dek-bP-EZm"/>
                         <constraint firstItem="a7b-yc-tgX" firstAttribute="centerY" secondItem="h9a-I9-jjo" secondAttribute="centerY" id="IcB-NO-E4H"/>
                         <constraint firstAttribute="bottom" secondItem="qRc-yH-vXE" secondAttribute="bottom" constant="20" id="Ryd-Py-Sux"/>
+                        <constraint firstAttribute="trailing" secondItem="cmG-In-sJm" secondAttribute="trailing" id="aSN-m6-Ruu"/>
                         <constraint firstItem="a7b-yc-tgX" firstAttribute="centerX" secondItem="h9a-I9-jjo" secondAttribute="centerX" id="aTc-ah-Z9O"/>
+                        <constraint firstItem="cmG-In-sJm" firstAttribute="leading" secondItem="h9a-I9-jjo" secondAttribute="leading" id="ihT-zD-ezF"/>
                         <constraint firstItem="qRc-yH-vXE" firstAttribute="centerX" secondItem="h9a-I9-jjo" secondAttribute="centerX" id="mdj-Kr-F7C"/>
                     </constraints>
                 </customView>

+ 2 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFSecToolbarController.swift

@@ -136,6 +136,8 @@ class KMPDFSecToolbarController: KMNBaseViewController {
                     button.toolTip = KMLocalizedString("Add Image", comment: "")
                 } else if buttonProperty.identifier == KMPDFToolbar_edit_link_Identifier {
                     button.toolTip = KMLocalizedString("Select an area or text on a page for a link to be inserted.", comment: "")
+                } else if buttonProperty.identifier == KMPDFToolbar_edit_crop_Identifier {
+                    button.toolTip = KMLocalizedString("Crop page", comment: "")
                 }
                 
                 else if buttonProperty.identifier == KMPDFToolbar_form_text_Identifier {