Ver Fonte

【2025】【Edit】工具栏串接批量内容

niehaoyu há 2 meses atrás
pai
commit
d3aee5f5cf

+ 15 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBackgroundPropertyController.swift

@@ -39,6 +39,8 @@ class KMBackgroundPropertyController: NSViewController {
     
     @IBOutlet var infoContendView: NSView!
     @IBOutlet var infoContendTopConst: NSLayoutConstraint!
+    @IBOutlet var infoContendBottomConst: NSLayoutConstraint!
+    
     //Text
     @IBOutlet var textBGView: NSView!
     @IBOutlet var colorLabel: NSTextField!
@@ -71,8 +73,7 @@ class KMBackgroundPropertyController: NSViewController {
     
     private var textTabProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("Color"))
     private var fileTabProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("File"))
-    
-    
+     
     weak open var delegate: KMBackgroundPropertyControllerDelegate?
     
     var originalDataDict: Dictionary<String, Any>?
@@ -80,6 +81,8 @@ class KMBackgroundPropertyController: NSViewController {
     
     var editSubType: KMPDFEditSubModeType = .none
     
+    var isInBatchMode: Bool = false
+    
     //MARK: - func
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -218,6 +221,8 @@ class KMBackgroundPropertyController: NSViewController {
         
     }
     
+    
+    
     func reloadData() {
         
         titleLabel.stringValue = KMLocalizedString("Add Background")
@@ -226,6 +231,14 @@ class KMBackgroundPropertyController: NSViewController {
         templateButton.properties.icon = NSImage(named: "icon_wm_template")
         templateButton.properties.isDisabled = false
         
+        if self.isInBatchMode {
+            infoContendBottomConst.constant = 0
+            saveTemplateBGView.isHidden = true
+        } else {
+            infoContendTopConst.constant = 72
+            saveTemplateBGView.isHidden = false
+        }
+        
         infoContendTopConst.constant = 56
         typeTabsBGView.isHidden = false
         if editSubType == .edit {

+ 14 - 13
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBackgroundPropertyController.xib

@@ -21,6 +21,7 @@
                 <outlet property="fileInputAddonView" destination="td8-2n-Z9H" id="NWb-q6-Ccr"/>
                 <outlet property="fileInputView" destination="dMT-80-cRR" id="eXe-DS-6X3"/>
                 <outlet property="fontColorGroup" destination="HRP-Of-jmt" id="AGC-aG-TIW"/>
+                <outlet property="infoContendBottomConst" destination="HDK-Tk-V2h" id="NaU-Ls-xI1"/>
                 <outlet property="infoContendTopConst" destination="bqf-4L-XCU" id="j1X-q1-Ttk"/>
                 <outlet property="infoContendView" destination="2r8-sI-aCB" id="eKf-y5-7xw"/>
                 <outlet property="leftTopButton" destination="fkD-oz-UOI" id="jl8-Oa-sDw"/>
@@ -42,14 +43,14 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="281" height="831"/>
+            <rect key="frame" x="0.0" y="0.0" width="281" height="581"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="rFc-TS-7es">
-                    <rect key="frame" x="0.0" y="0.0" width="281" height="831"/>
+                    <rect key="frame" x="0.0" y="0.0" width="281" height="581"/>
                     <subviews>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="4tG-T7-TSW">
-                            <rect key="frame" x="0.0" y="791" width="281" height="40"/>
+                            <rect key="frame" x="0.0" y="541" width="281" height="40"/>
                             <subviews>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="fkD-oz-UOI" customClass="ComponentButton" customModule="KMComponentLibrary">
                                     <rect key="frame" x="8" y="8" width="24" height="24"/>
@@ -59,8 +60,8 @@
                                     </constraints>
                                 </customView>
                                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wwm-pR-ypi">
-                                    <rect key="frame" x="92" y="12" width="98" height="16"/>
-                                    <textFieldCell key="cell" lineBreakMode="clipping" title="Add Watermark" id="r1J-ly-gkd">
+                                    <rect key="frame" x="88" y="12" width="105" height="16"/>
+                                    <textFieldCell key="cell" lineBreakMode="clipping" title="Add Background" id="r1J-ly-gkd">
                                         <font key="font" usesAppearanceFont="YES"/>
                                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -94,7 +95,7 @@
                             </constraints>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="3bI-RP-0y4">
-                            <rect key="frame" x="0.0" y="735" width="281" height="56"/>
+                            <rect key="frame" x="0.0" y="485" width="281" height="56"/>
                             <subviews>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="7I9-B4-CbU" customClass="ComponentTabs" customModule="KMComponentLibrary">
                                     <rect key="frame" x="25" y="16" width="232" height="32"/>
@@ -111,10 +112,10 @@
                             </constraints>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="2r8-sI-aCB">
-                            <rect key="frame" x="0.0" y="69" width="281" height="666"/>
+                            <rect key="frame" x="0.0" y="72" width="281" height="413"/>
                             <subviews>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="MiZ-mc-j5Q">
-                                    <rect key="frame" x="25" y="594" width="232" height="72"/>
+                                    <rect key="frame" x="25" y="341" width="232" height="72"/>
                                     <subviews>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="5Sz-4h-cCv">
                                             <rect key="frame" x="0.0" y="32" width="232" height="40"/>
@@ -153,7 +154,7 @@
                                     </constraints>
                                 </customView>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="SYp-51-eQM">
-                                    <rect key="frame" x="25" y="634" width="232" height="32"/>
+                                    <rect key="frame" x="25" y="381" width="232" height="32"/>
                                     <subviews>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="dMT-80-cRR" customClass="ComponentInput" customModule="KMComponentLibrary">
                                             <rect key="frame" x="0.0" y="0.0" width="201" height="32"/>
@@ -180,7 +181,7 @@
                                     </constraints>
                                 </customView>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="BhY-Hs-5iE">
-                                    <rect key="frame" x="25" y="426" width="232" height="152"/>
+                                    <rect key="frame" x="25" y="173" width="232" height="152"/>
                                     <subviews>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="qqz-0x-e9m">
                                             <rect key="frame" x="0.0" y="112" width="232" height="40"/>
@@ -277,7 +278,7 @@
                                     </constraints>
                                 </customView>
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="cw7-VT-eh2">
-                                    <rect key="frame" x="25" y="298" width="232" height="112"/>
+                                    <rect key="frame" x="25" y="45" width="232" height="112"/>
                                     <subviews>
                                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="4nv-va-3Dv">
                                             <rect key="frame" x="0.0" y="72" width="232" height="40"/>
@@ -358,7 +359,6 @@
                                 <constraint firstItem="MiZ-mc-j5Q" firstAttribute="centerX" secondItem="2r8-sI-aCB" secondAttribute="centerX" id="6Lq-Ik-Psx"/>
                                 <constraint firstItem="BhY-Hs-5iE" firstAttribute="centerX" secondItem="2r8-sI-aCB" secondAttribute="centerX" id="JcU-fC-Cz4"/>
                                 <constraint firstItem="cw7-VT-eh2" firstAttribute="centerX" secondItem="2r8-sI-aCB" secondAttribute="centerX" id="OtR-h7-YqC"/>
-                                <constraint firstAttribute="height" constant="666" id="SUY-V8-XeS"/>
                                 <constraint firstItem="SYp-51-eQM" firstAttribute="centerX" secondItem="2r8-sI-aCB" secondAttribute="centerX" id="UT7-nX-fYi"/>
                                 <constraint firstItem="MiZ-mc-j5Q" firstAttribute="top" secondItem="2r8-sI-aCB" secondAttribute="top" id="We6-dZ-0yk"/>
                                 <constraint firstItem="SYp-51-eQM" firstAttribute="top" secondItem="2r8-sI-aCB" secondAttribute="top" id="hwK-ZC-TI7"/>
@@ -398,6 +398,7 @@
                         <constraint firstAttribute="trailing" secondItem="4tG-T7-TSW" secondAttribute="trailing" id="4dj-ve-myU"/>
                         <constraint firstItem="3bI-RP-0y4" firstAttribute="leading" secondItem="rFc-TS-7es" secondAttribute="leading" id="Bwn-2s-2OS"/>
                         <constraint firstItem="NEs-0d-c4M" firstAttribute="leading" secondItem="rFc-TS-7es" secondAttribute="leading" id="EgW-H3-SQj"/>
+                        <constraint firstAttribute="bottom" secondItem="2r8-sI-aCB" secondAttribute="bottom" constant="72" id="HDK-Tk-V2h"/>
                         <constraint firstAttribute="trailing" secondItem="3bI-RP-0y4" secondAttribute="trailing" id="Kf8-Hc-yPg"/>
                         <constraint firstItem="4tG-T7-TSW" firstAttribute="top" secondItem="rFc-TS-7es" secondAttribute="top" id="O51-fq-Ctd"/>
                         <constraint firstItem="2r8-sI-aCB" firstAttribute="top" secondItem="4tG-T7-TSW" secondAttribute="bottom" constant="56" id="bqf-4L-XCU"/>
@@ -415,7 +416,7 @@
                 <constraint firstAttribute="trailing" secondItem="rFc-TS-7es" secondAttribute="trailing" id="XQD-h0-Twd"/>
                 <constraint firstItem="rFc-TS-7es" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="rOm-T5-hIC"/>
             </constraints>
-            <point key="canvasLocation" x="30.5" y="329.5"/>
+            <point key="canvasLocation" x="30.5" y="204.5"/>
         </customView>
     </objects>
     <resources>

+ 14 - 14
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -593,12 +593,12 @@ struct KMNMWCFlags {
         } else if toolbarMode == .Edit {
             //MARK: -编辑
             if subToolMode == .None {
-                if listView.toolMode != .CEditPDFToolMode {
-                    listView.toolMode = .CEditPDFToolMode
-                    listView.configPDFEditingInfo()
-                }
-                listView.setShouAddEdit([])
-                listView.change([.text, .image])
+//                if listView.toolMode != .CEditPDFToolMode {
+//                    listView.toolMode = .CEditPDFToolMode
+//                    listView.configPDFEditingInfo()
+//                }
+//                listView.setShouAddEdit([])
+//                listView.change([.text, .image])
                 
             } else if subToolMode == .Edit_text {
                 if listView.toolMode != .CEditPDFToolMode {
@@ -1795,11 +1795,11 @@ struct KMNMWCFlags {
     }
     
     func batchAddWatermark() {
-        
+        self.showBatchWindow(type: .watermark, files: nil)
     }
     
     func batchRemoveWatermark() {
-        
+        self.showBatchWindow(type: .batchRemove, files: nil)
     }
     
     //MARK: - PopUI
@@ -2098,11 +2098,11 @@ struct KMNMWCFlags {
     }
     
     func batchAddBackground() {
-        
+        self.showBatchWindow(type: .background, files: nil)
     }
     
     func batchRemoveBackground() {
-        
+        self.showBatchWindow(type: .batchRemove, files: nil)
     }
     
     //MARK: - header&footer
@@ -2172,11 +2172,11 @@ struct KMNMWCFlags {
     }
     
     func batchAddHeaderFooter() {
-        
+        self.showBatchWindow(type: .headerAndFooter, files: nil)
     }
     
     func batchRemoveHeaderFooter() {
-        
+        self.showBatchWindow(type: .batchRemove, files: nil)
     }
     
     //MARK: - Bates
@@ -2247,11 +2247,11 @@ struct KMNMWCFlags {
     }
     
     func batchAddBates() {
-        
+        self.showBatchWindow(type: .batesNumber, files: nil)
     }
     
     func batchRemoveBates() {
-        
+        self.showBatchWindow(type: .batchRemove, files: nil)
     }
     
     //MARK: - Crop Action

+ 175 - 2
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/Background/KMBatchBackgroundView.swift

@@ -6,11 +6,23 @@
 //
 
 import Cocoa
+import KMComponentLibrary
 
 class KMBatchBackgroundView: KMBatchSettingItemView {
     @IBOutlet weak var applyButton: NSButton!
     @IBOutlet weak var itemContentView: NSView!
     
+    var propertyController: KMBackgroundPropertyController = KMBackgroundPropertyController.init()
+    var templatesController: KMBGTemplateController = KMBGTemplateController()
+    
+    var saveTemplateMessage: ComponentMessage = ComponentMessage()
+    
+    var pdfDocument: CPDFDocument?
+    
+    var backgroundModel: KMBackgroundModel?
+    
+    var editSubType: KMPDFEditSubModeType = .none
+    
     override func setup() {
         super.setup()
         
@@ -20,6 +32,21 @@ class KMBatchBackgroundView: KMBatchSettingItemView {
         self.applyButton.stringValue = NSLocalizedString("Compress", comment: "")
         self.applyButton.font = NSFont.SFProTextRegularFont(14.0)
         self.applyButton.layer?.backgroundColor = NSColor.km_init(hex: "#BDDFFD").cgColor
+         
+        propertyController.view.frame = itemContentView.bounds
+        propertyController.view.autoresizingMask = [.width, .height]
+        propertyController.delegate = self
+        propertyController.view.isHidden = true
+        propertyController.isInBatchMode = true
+        itemContentView.addSubview(propertyController.view)
+        
+        templatesController.view.frame = itemContentView.bounds
+        templatesController.view.autoresizingMask = [.width, .height]
+        templatesController.delegate = self
+        templatesController.view.isHidden = true
+        itemContentView.addSubview(templatesController.view)
+        
+        setupProperty()
     }
     
     override func reloadData() {
@@ -31,13 +58,159 @@ class KMBatchBackgroundView: KMBatchSettingItemView {
             self.applyButton.layer?.backgroundColor = NSColor.km_init(hex: "#BDDFFD").cgColor
             self.applyButton.isEnabled = false
         }
+        
+        if editSubType == .template {
+            templatesController.reloadData()
+            
+            backgroundModel = templatesController.selectedBackground
+        } else if editSubType == .add {
+            propertyController.editSubType = editSubType
+            propertyController.backgroundData = KMBackgroundManager.defaultManager.defaultModel
+            propertyController.reloadData()
+            
+            backgroundModel = propertyController.backgroundData
+        } else if editSubType == .edit {
+            propertyController.editSubType = editSubType
+            propertyController.reloadData()
+            
+            backgroundModel = propertyController.backgroundData
+        }
+        
+        updatePDFDocumentBackground()
+    }
+    
+    func setupProperty() {
+        saveTemplateMessage.properties = ComponentMessageProperty(messageType: .success, title: KMLocalizedString("Saved Template"))
+        
+    }
+    
+    func resetUI() {
+        propertyController.view.isHidden = true
+        templatesController.view.isHidden = true
+        
+        if editSubType == .template {
+            templatesController.view.isHidden = false
+            
+        } else if editSubType == .add {
+            propertyController.view.isHidden = false
+            propertyController.editSubType = editSubType
+            
+        } else if editSubType == .edit {
+            propertyController.view.isHidden = false
+            propertyController.editSubType = editSubType
+            
+        }
+    }
+    
+    func updatePDFDocumentBackground() {
+        
+    }
+    
+    override func mouseUp(with event: NSEvent) {
+        super.mouseUp(with: event)
+        
+        
+    }
+    
+}
+
+//MARK: - KMBackgroundPropertyControllerDelegate
+extension KMBatchBackgroundView: KMBackgroundPropertyControllerDelegate {
+    func backgroundPropertyControllerDidUpdate(_ controller: KMBackgroundPropertyController) {
+        backgroundModel = controller.backgroundData
+        
+        updatePDFDocumentBackground()
+        
+    }
+    
+    func backgroundPropertyControllerDidChangetoTemplate(_ controller: KMBackgroundPropertyController) {
+        editSubType = .template
+        resetUI()
+        
+        backgroundModel = templatesController.selectedBackground
+        reloadData()
+    }
+    
+    func backgroundPropertyControllerSaveTemplateSuccess(_ controller: KMBackgroundPropertyController, _ data: KMBackgroundModel) {
+        saveTemplateMessage.frame = CGRectMake((CGRectGetWidth(self.frame) - saveTemplateMessage.properties.propertyInfo.viewWidth)/2,
+                                               CGRectGetHeight(self.frame) - saveTemplateMessage.properties.propertyInfo.viewHeight - 8,
+                                               saveTemplateMessage.properties.propertyInfo.viewWidth,
+                                               saveTemplateMessage.properties.propertyInfo.viewHeight)
+        saveTemplateMessage.reloadData()
+        saveTemplateMessage.show(inView: self, autoHideSeconde: 2)
+        
+        editSubType = .template
+        resetUI()
+        
+        templatesController.selectedBackground = data
+        
+        reloadData()
+        
+        KMBackgroundManager.defaultManager.defaultModel = KMBackgroundModel()
+    }
+    
+    func backgroundPropertyControllerCancelTemplateEdit(_ controller: KMBackgroundPropertyController) {
+        editSubType = .template
+        resetUI()
+        
+        templatesController.selectedBackground = controller.backgroundData
+        
+        reloadData()
+        
+    }
+    
+    func backgroundPropertyControllerFinishTemplateEdit(_ controller: KMBackgroundPropertyController) {
+        editSubType = .template
+        resetUI()
+        
+        templatesController.selectedBackground = controller.backgroundData
+        
+        reloadData()
+    }
+}
+
+//MARK: - KMBGTemplateControllerDelegate
+extension KMBatchBackgroundView: KMBGTemplateControllerDelegate {
+    func templateControllerDidSelectedChanged(_ controller: KMBGTemplateController) {
+        backgroundModel = controller.selectedBackground
+        
+        updatePDFDocumentBackground()
+        
+    }
+    
+    func templateControllerDidAddData(_ controller: KMBGTemplateController) {
+        editSubType = .add
+        resetUI()
+        
+        propertyController.backgroundData = KMBackgroundManager.defaultManager.defaultModel
+        
+        templatesController.selectedBackground = nil
+        templatesController.reloadData()
+        
+        reloadData()
+        
+    }
+    
+    func templateControllerDidEditData(_ controller: KMBGTemplateController, _ data: KMBackgroundModel) {
+        editSubType = .edit
+        resetUI()
+        
+        propertyController.originalDataDict = KMBackgroundManager.defaultManager.parseModelToDict(model: data)
+        propertyController.backgroundData = data
+        
+        templatesController.selectedBackground = nil
+        templatesController.reloadData()
+        
+        reloadData()
     }
 }
 
+protocol KMBatchBackgroundViewAction: KMBatchBackgroundView {
+    
+}
 
-protocol KMBatchBackgroundViewAction: KMBatchBackgroundView {}
 extension KMBatchBackgroundView: KMBatchBackgroundViewAction {
     @IBAction func applyButtonAction(_ sender: NSButton) {
-
+        
     }
 }

+ 5 - 0
PDF Office/PDF Master/KMClass/NewBatch/View/Setting/KMBatchSettingView.swift

@@ -114,6 +114,10 @@ class KMBatchSettingView: BaseXibView {
                 break
             case .background:
                 resultView = KMBatchBackgroundView.init()
+                if let view = resultView as? KMBatchBackgroundView {
+                    view.editSubType = .template
+                    view.resetUI()
+                }
                 resultView.batchExport = { [unowned self] (view, data) in
                     KMBatchManager.manager.batch(type: type, data: data)
                 }
@@ -144,6 +148,7 @@ class KMBatchSettingView: BaseXibView {
             resultView.subType = subType
             resultView.filesData = self.filesData ?? []
             resultView.isDisable = self.isDisable
+            resultView.reloadData()
             self.itemViewArray.append(resultView)
         } else {
             if resultView.filesData.count == 0 && self.filesData?.count != 0{

+ 0 - 1
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -10274,7 +10274,6 @@
 			children = (
 				BB2EDF64296ECE17003BCF58 /* KMPageEditInsertTypeItemView.swift */,
 				BB2EDF65296ECE17003BCF58 /* KMPageEditInsertDirectionItemView.swift */,
-				BB2EDF66296ECE17003BCF58 /* KMPageEditThumbnailView.swift */,
 				BB2EDF67296ECE17003BCF58 /* KMPageEditThumbnailItem.xib */,
 				BB2EDF69296ECE17003BCF58 /* KMPageEditThumbnailItem.swift */,
 				BBD1F78A296FACA300343885 /* KMPageEditExtractSettingView.swift */,