Explorar o código

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

tangchao hai 1 ano
pai
achega
2b3f14b10a

+ 16 - 20
PDF Office/PDF Master/Class/GuideInfo/Controllers/FunctionGuide/KMConvertGuideView.xib

@@ -9,7 +9,7 @@
         <customObject id="-2" userLabel="File's Owner"/>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <customView id="c22-O7-iKe" customClass="KMConvertGuideView" customModule="PDF_Master" customModuleProvider="target">
+        <customView id="c22-O7-iKe" customClass="KMConvertGuideView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="678" height="650"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
@@ -60,11 +60,7 @@
                                     <rect key="frame" x="20" y="150" width="360" height="20"/>
                                     <subviews>
                                         <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="B2O-Zo-9Ns">
-                                            <rect key="frame" x="0.0" y="0.0" width="20" height="20"/>
-                                            <constraints>
-                                                <constraint firstAttribute="width" constant="20" id="3kd-MF-8m0"/>
-                                                <constraint firstAttribute="height" constant="20" id="V0n-iN-Wof"/>
-                                            </constraints>
+                                            <rect key="frame" x="0.0" y="2" width="20" height="20"/>
                                             <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="guide_Convert_tip" id="BPX-oj-IFr"/>
                                         </imageView>
                                         <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vLK-MJ-ETm">
@@ -80,9 +76,9 @@
                                         </textField>
                                     </subviews>
                                     <constraints>
+                                        <constraint firstItem="vLK-MJ-ETm" firstAttribute="top" secondItem="B2O-Zo-9Ns" secondAttribute="top" constant="2" id="AUd-zJ-4yF"/>
                                         <constraint firstItem="vLK-MJ-ETm" firstAttribute="top" secondItem="RH5-2l-6Fc" secondAttribute="top" id="IBW-6K-fav"/>
                                         <constraint firstItem="B2O-Zo-9Ns" firstAttribute="leading" secondItem="RH5-2l-6Fc" secondAttribute="leading" id="LsV-ed-7ah"/>
-                                        <constraint firstItem="B2O-Zo-9Ns" firstAttribute="top" secondItem="RH5-2l-6Fc" secondAttribute="top" id="Pm1-eG-AVF"/>
                                         <constraint firstAttribute="bottom" secondItem="vLK-MJ-ETm" secondAttribute="bottom" constant="2" id="YqU-gk-rAB"/>
                                         <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="20" id="YyJ-P4-xYI"/>
                                         <constraint firstItem="vLK-MJ-ETm" firstAttribute="leading" secondItem="B2O-Zo-9Ns" secondAttribute="trailing" constant="4" id="snN-ot-aNw"/>
@@ -93,7 +89,7 @@
                                     <rect key="frame" x="20" y="124" width="360" height="18"/>
                                     <subviews>
                                         <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ncd-2J-81m">
-                                            <rect key="frame" x="0.0" y="-2" width="20" height="20"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="20" height="20"/>
                                             <constraints>
                                                 <constraint firstAttribute="width" constant="20" id="8Pf-Ga-wih"/>
                                                 <constraint firstAttribute="height" constant="20" id="Q2g-pU-Wy5"/>
@@ -118,14 +114,14 @@
                                         <constraint firstItem="Y4d-zT-oBL" firstAttribute="leading" secondItem="Ncd-2J-81m" secondAttribute="trailing" constant="4" id="RuJ-2h-PDx"/>
                                         <constraint firstAttribute="width" constant="360" id="Xxu-Fu-Pvw"/>
                                         <constraint firstItem="Ncd-2J-81m" firstAttribute="leading" secondItem="4s7-tz-fFz" secondAttribute="leading" id="c3L-PS-6i7"/>
-                                        <constraint firstItem="Ncd-2J-81m" firstAttribute="top" secondItem="4s7-tz-fFz" secondAttribute="top" id="wsb-bm-vaE"/>
+                                        <constraint firstItem="Ncd-2J-81m" firstAttribute="top" secondItem="4s7-tz-fFz" secondAttribute="top" constant="-2" id="wsb-bm-vaE"/>
                                     </constraints>
                                 </customView>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="puY-2Y-BOa">
                                     <rect key="frame" x="20" y="98" width="360" height="18"/>
                                     <subviews>
                                         <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ifv-GO-04q">
-                                            <rect key="frame" x="0.0" y="-2" width="20" height="20"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="20" height="20"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="20" id="RtF-lq-crQ"/>
                                                 <constraint firstAttribute="width" constant="20" id="tlL-CR-QtY"/>
@@ -149,7 +145,7 @@
                                         <constraint firstAttribute="width" constant="360" id="MwK-dq-kyo"/>
                                         <constraint firstItem="rYf-RP-Ojg" firstAttribute="top" secondItem="puY-2Y-BOa" secondAttribute="top" id="QKs-uL-Tu5"/>
                                         <constraint firstItem="ifv-GO-04q" firstAttribute="leading" secondItem="puY-2Y-BOa" secondAttribute="leading" id="Thi-Bk-gzO"/>
-                                        <constraint firstItem="ifv-GO-04q" firstAttribute="top" secondItem="puY-2Y-BOa" secondAttribute="top" id="XaM-q0-oeT"/>
+                                        <constraint firstItem="ifv-GO-04q" firstAttribute="top" secondItem="puY-2Y-BOa" secondAttribute="top" constant="-2" id="XaM-q0-oeT"/>
                                         <constraint firstItem="rYf-RP-Ojg" firstAttribute="leading" secondItem="ifv-GO-04q" secondAttribute="trailing" constant="4" id="fqF-do-njB"/>
                                     </constraints>
                                 </customView>
@@ -157,7 +153,7 @@
                                     <rect key="frame" x="20" y="72" width="360" height="18"/>
                                     <subviews>
                                         <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1I3-Mh-7n8">
-                                            <rect key="frame" x="0.0" y="-2" width="20" height="20"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="20" height="20"/>
                                             <constraints>
                                                 <constraint firstAttribute="width" constant="20" id="T2x-5S-z3f"/>
                                                 <constraint firstAttribute="height" constant="20" id="X83-qQ-yFz"/>
@@ -177,7 +173,7 @@
                                         </textField>
                                     </subviews>
                                     <constraints>
-                                        <constraint firstItem="1I3-Mh-7n8" firstAttribute="top" secondItem="MSg-b9-aBi" secondAttribute="top" id="70h-s6-nkC"/>
+                                        <constraint firstItem="1I3-Mh-7n8" firstAttribute="top" secondItem="MSg-b9-aBi" secondAttribute="top" constant="-2" id="70h-s6-nkC"/>
                                         <constraint firstItem="cd9-us-gA4" firstAttribute="leading" secondItem="1I3-Mh-7n8" secondAttribute="trailing" constant="4" id="AYV-pd-HAi"/>
                                         <constraint firstAttribute="width" constant="360" id="CrN-uE-2Z6"/>
                                         <constraint firstItem="1I3-Mh-7n8" firstAttribute="leading" secondItem="MSg-b9-aBi" secondAttribute="leading" id="D4j-yB-sii"/>
@@ -192,14 +188,14 @@
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FKZ-6g-6uN">
-                                                <rect key="frame" x="10" y="9" width="45" height="16"/>
+                                                <rect key="frame" x="10" y="7" width="45" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Close" id="9ro-jO-CZy">
                                                     <font key="font" metaFont="systemBold"/>
                                                     <color key="textColor" red="0.99999600649999998" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="P5F-Uj-vJH" customClass="KMButton" customModule="PDF_Master" customModuleProvider="target">
+                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="P5F-Uj-vJH" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                 <rect key="frame" x="0.0" y="0.0" width="65" height="30"/>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="7Up-eg-vZi">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -212,7 +208,7 @@
                                         </subviews>
                                         <constraints>
                                             <constraint firstItem="P5F-Uj-vJH" firstAttribute="leading" secondItem="2H3-w4-Cbp" secondAttribute="leading" id="3iw-1c-ahe"/>
-                                            <constraint firstItem="FKZ-6g-6uN" firstAttribute="centerY" secondItem="2H3-w4-Cbp" secondAttribute="centerY" constant="-2" id="6bL-EO-IRB"/>
+                                            <constraint firstItem="FKZ-6g-6uN" firstAttribute="centerY" secondItem="2H3-w4-Cbp" secondAttribute="centerY" id="6bL-EO-IRB"/>
                                             <constraint firstAttribute="trailing" secondItem="P5F-Uj-vJH" secondAttribute="trailing" id="MzO-7u-87D"/>
                                             <constraint firstItem="P5F-Uj-vJH" firstAttribute="top" secondItem="2H3-w4-Cbp" secondAttribute="top" id="kfG-Gq-khs"/>
                                             <constraint firstAttribute="trailing" secondItem="FKZ-6g-6uN" secondAttribute="trailing" constant="12" id="nr6-Rs-FDl"/>
@@ -224,21 +220,21 @@
                                         <constraint firstAttribute="height" constant="32" id="ysN-nq-4L9"/>
                                     </constraints>
                                 </box>
-                                <box boxType="custom" borderType="line" cornerRadius="5" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="PWh-gy-TmU" customClass="KMBox" customModule="PDF_Master" customModuleProvider="target">
+                                <box boxType="custom" borderType="line" cornerRadius="5" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="PWh-gy-TmU" customClass="KMBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                     <rect key="frame" x="235" y="20" width="145" height="32"/>
                                     <view key="contentView" id="Lcj-9H-r8H">
                                         <rect key="frame" x="1" y="1" width="143" height="30"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7B0-Ss-Sdb">
-                                                <rect key="frame" x="10" y="9" width="123" height="16"/>
+                                                <rect key="frame" x="10" y="7" width="123" height="16"/>
                                                 <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Convert All Pages" id="0Vq-qk-vP7">
                                                     <font key="font" metaFont="systemBold"/>
                                                     <color key="textColor" red="0.99999600649999998" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                     <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                 </textFieldCell>
                                             </textField>
-                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mua-0m-k0A" customClass="KMButton" customModule="PDF_Master" customModuleProvider="target">
+                                            <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mua-0m-k0A" customClass="KMButton" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                 <rect key="frame" x="0.0" y="0.0" width="143" height="30"/>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="ZMk-wp-fkl">
                                                     <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -253,7 +249,7 @@
                                             <constraint firstItem="mua-0m-k0A" firstAttribute="top" secondItem="Lcj-9H-r8H" secondAttribute="top" id="8ku-Vn-WVb"/>
                                             <constraint firstItem="7B0-Ss-Sdb" firstAttribute="leading" secondItem="Lcj-9H-r8H" secondAttribute="leading" constant="12" id="9nT-Qh-PBH"/>
                                             <constraint firstAttribute="bottom" secondItem="mua-0m-k0A" secondAttribute="bottom" id="HeN-jN-3b8"/>
-                                            <constraint firstItem="7B0-Ss-Sdb" firstAttribute="centerY" secondItem="Lcj-9H-r8H" secondAttribute="centerY" constant="-2" id="QvR-5i-zNC"/>
+                                            <constraint firstItem="7B0-Ss-Sdb" firstAttribute="centerY" secondItem="Lcj-9H-r8H" secondAttribute="centerY" id="QvR-5i-zNC"/>
                                             <constraint firstAttribute="trailing" secondItem="mua-0m-k0A" secondAttribute="trailing" id="ThN-V5-s9T"/>
                                             <constraint firstItem="mua-0m-k0A" firstAttribute="leading" secondItem="Lcj-9H-r8H" secondAttribute="leading" id="Woo-F3-06s"/>
                                             <constraint firstAttribute="trailing" secondItem="7B0-Ss-Sdb" secondAttribute="trailing" constant="12" id="n0d-EE-B9o"/>

+ 2 - 2
PDF Office/PDF Master/Class/GuideInfo/KMFunctionGuideWindowController.swift

@@ -23,9 +23,9 @@ class KMFunctionGuideWindowController: NSWindowController {
                 return true
             }
         } else if type == .functionMultiAIGuide {
-//            if (UserDefaults.standard.object(forKey: kKMGuideInfoMultiAIGuideKey) == nil) {
+            if (UserDefaults.standard.object(forKey: kKMGuideInfoMultiAIGuideKey) == nil) {
                 return true
-//            }
+            }
         } else if type == .aiInfoResultSave {
             if (UserDefaults.standard.object(forKey: kKMGuideInfoAIResultSaveKey) == nil) {
                 return true

+ 7 - 1
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeTableViewCell.swift

@@ -101,8 +101,14 @@ class KMMergeTableViewCell: NSTableCellView {
         callBack(self, fileModel)
     }
     
-    @IBAction func comboBoxAction(_ sender: Any) {
+    @IBAction func comboBoxAction(_ sender: NSComboBoxCell) {
+        guard let fileModel = fileModel else { return }
+        let type = KMPageRange.init(rawValue: sender.indexOfSelectedItem) ?? .all
+        fileModel.pagesType = type
         
+        if type == .custom {
+            fileModel.pagesString = sender.stringValue
+        }
     }
 }
 

+ 12 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarController.swift

@@ -828,3 +828,15 @@ extension KMToolbarController: KMToolbarViewControllerDelegate {
         self.delegate?.toolbarViewController?(viewController, menuItemDidClick: toolbarItem, index: index, info: info)
     }
 }
+
+extension KMToolbarController {
+    func updataItemVisible() {
+        guard let isCompareModel = self.mainViewController?.isCompareModel else { return }
+        if isCompareModel {
+            self.toolbarType = .None
+            self.mainToolBarView?.isEnable(isEnable: false)
+        } else {
+            self.mainToolBarView?.isEnable()
+        }
+    }
+}

+ 10 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -2028,3 +2028,13 @@ extension KMToolbarViewController: NSMenuItemValidation {
         return true
     }
 }
+
+extension KMToolbarViewController {
+    func isEnable(isEnable: Bool = true) {
+        for item in toolbarItems {
+            let itemView: KMToolbarMainItemView = item.value as? KMToolbarMainItemView ?? KMToolbarMainItemView()
+            itemView.unEnabled = !isEnable
+            itemView.isSelected = false
+        }
+    }
+}

+ 35 - 30
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -4247,10 +4247,10 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     return
                 }
             } else if type == .comparison {
-        if !IAPProductsManager.default().isAvailableAllFunction(){
-            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
-            return
-        }
+                if !IAPProductsManager.default().isAvailableAllFunction(){
+                    KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+                    return
+                }
                 
                 let controller = KMCompareWindowController(windowNibName: "KMCompareWindowController")
                 self.currentWindowController = controller
@@ -5044,6 +5044,8 @@ extension KMMainViewController {
 extension KMMainViewController {
     //文件对比
     func openContentCompareVC(with pdfCompareContent: CPDFCompareContent?, results: [CPDFCompareResults], oldDocument: CPDFDocument, document: CPDFDocument) {
+        self.isCompareModel = true
+        
         let compareContentView = KMCompareContentView()
         compareContentView.oldDocument = oldDocument
         compareContentView.document = document
@@ -5107,6 +5109,7 @@ extension KMMainViewController {
         
         compareContentView.closeHandle = { [unowned self] view in
 //            self.view.window!.endSheet(controller.window!)
+            self.isCompareModel = false
             view.removeFromSuperview()
         }
         
@@ -5115,6 +5118,34 @@ extension KMMainViewController {
         compareContentView.autoresizingMask = [.width,.height]
     }
 
+    func openCoveringCompareVC(with pdfDocument: CPDFDocument) {
+        self.isCompareModel = true
+        
+        let coveringView = KMCompareCoveringView()
+        coveringView.pdfDocument = pdfDocument
+        coveringView.closeHandle = { [unowned self] view in
+            self.isCompareModel = false
+            view.removeFromSuperview()
+        }
+        
+        coveringView.saveHandle = { [unowned self] view in
+            let savePanel = NSSavePanel()
+            savePanel.nameFieldStringValue = "untitled"
+            savePanel.allowedFileTypes = ["pdf"]
+            savePanel.beginSheetModal(for: NSWindow.currentWindow()) { result in
+                if result == .OK {
+                    pdfDocument.write(to: savePanel.url!)
+                    NSWorkspace.shared.activateFileViewerSelecting([savePanel.url!])
+                }
+            }
+        }
+        
+        
+        self.PDFContendView.addSubview(coveringView)
+        coveringView.frame = self.PDFContendView.bounds
+        coveringView.autoresizingMask = [.width,.height]
+    }
+
     func getValidFilePath(_ oldPath: String) -> String {
         let fileManager = FileManager.default
 
@@ -5143,30 +5174,4 @@ extension KMMainViewController {
             return oldPath
         }
     }
-
-    func openCoveringCompareVC(with pdfDocument: CPDFDocument) {
-        let coveringView = KMCompareCoveringView()
-        coveringView.pdfDocument = pdfDocument
-        coveringView.closeHandle = { [unowned self] view in
-            view.removeFromSuperview()
-        }
-        
-        coveringView.saveHandle = { [unowned self] view in
-            let savePanel = NSSavePanel()
-            savePanel.nameFieldStringValue = "untitled"
-            savePanel.allowedFileTypes = ["pdf"]
-            savePanel.beginSheetModal(for: NSWindow.currentWindow()) { result in
-                if result == .OK {
-                    pdfDocument.write(to: savePanel.url!)
-                    NSWorkspace.shared.activateFileViewerSelecting([savePanel.url!])
-                }
-            }
-        }
-        
-        
-        self.PDFContendView.addSubview(coveringView)
-        coveringView.frame = self.PDFContendView.bounds
-        coveringView.autoresizingMask = [.width,.height]
-    }
-
 }

+ 12 - 3
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift

@@ -577,11 +577,15 @@ extension KMMainViewController {
         readLeftViewShowPanel = self.leftSideViewController.isShowPanel
         readRightPanelOpen = rightPanelIsOpen
         readToolbarType = self.toolbarController.toolbarType
-        readToolbarItemIdentifier = self.toolbarController.lastItemBox.itemIdentifier ?? ""
         readToolMode = self.listView.toolMode
         readAnnotationType = self.listView.annotationType
         readSubViewType = self.rightSideViewController.subViewType ?? .None
         
+        if self.toolbarController.lastItemBox.isSelected {
+            readToolbarItemIdentifier = self.toolbarController.lastItemBox.itemIdentifier ?? ""
+        } else {
+            readToolbarItemIdentifier = ""
+        }
         //设置阅读模式
         self.isReadMode = true
         self.readModelView.isHidden = false
@@ -639,13 +643,18 @@ extension KMMainViewController {
                 self.openRightPane()
             }
             
+//            if readToolbarItemIdentifier.count == 0 {
+//                self.toolbarController.toolbarType = .None
+//            } else {
+//                self.toolbarController.selectItem(readToolbarItemIdentifier)
+//            }
+            self.toolbarController.selectItem(KMDocumentViewDisplayToolbarItemIdentifier)
+            
             self.leftSideViewController.showPanelView(show: readLeftViewShowPanel)
             if readLeftViewShowPanel {
                 self.toolbarController.selectItem(KMLeftControlToolbarItemIdentifier)
             }
             
-            self.toolbarController.selectItem(readToolbarItemIdentifier)
-//            self.toolbarController.toolbarType = .Annatiton
             self.toolbarController.view.isHidden = false
             self.listView.toolMode = readToolMode
             self.listView.annotationType = readAnnotationType

+ 8 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -81,6 +81,13 @@ let LOCKED_KEY  = "locked"
     //Form
     var formAlertView: KMFormAlertView?
     
+    //对比
+    var isCompareModel: Bool = false {
+        didSet {
+            self.toolbarController.updataItemVisible()
+        }
+    }
+    
     private var _needSave = false
     var needSave: Bool {
         set {
@@ -253,6 +260,7 @@ let LOCKED_KEY  = "locked"
         self.initPDFLeftViewVC()
         self.initRightSideView()
         self.toolbarController.listView = self.listView
+        self.toolbarController.mainViewController = self
         
         self.newPDFSplitView.delegate = self
     }