Quellcode durchsuchen

【编辑工具】压缩设置界面PPI参数设置交互

lizhe vor 6 Tagen
Ursprung
Commit
bef782fe86

+ 70 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/Compress/SettingView/View/KMCompressImagesPanelTableCellView.swift

@@ -7,8 +7,15 @@
 
 import Cocoa
 
-class KMCompressImagesPanelTableCellView: KMBaseCompressTableCellView, NibLoadable {
+class KMCompressImagesPanelTableCellView: KMBaseCompressTableCellView, NibLoadable, NSTextFieldDelegate {
     @IBOutlet weak var titleLabel: NSTextField!
+    @IBOutlet weak var imagePPITextField: NSTextField!
+    @IBOutlet weak var imageAbovePPITextField: NSTextField!
+    @IBOutlet weak var comboBox: NSComboBox!
+    
+    // 允许输入的数字范围
+    let minValue = 10
+    let maxValue = 100
     
     override var model: KMCompressSettingModel? {
         didSet {
@@ -22,8 +29,34 @@ class KMCompressImagesPanelTableCellView: KMBaseCompressTableCellView, NibLoadab
         // Drawing code here.
     }
     
+    override func setup() {
+        guard let  imagePPITextField = imagePPITextField else { return }
+        
+        imagePPITextField.delegate = self
+        imageAbovePPITextField.delegate = self
+    }
+    
     override func updateUI() {
         super.updateUI()
+        
+        guard let  imagePPITextField = imagePPITextField else { return }
+        // 设置 NumberFormatter
+        var formatter = NumberFormatter()
+        formatter.numberStyle = .decimal
+//        formatter.minimum = 10 // 设置最小值(可选)
+//        formatter.maximum = 24000 // 设置最大值(可选)
+
+//        let formatter = TextFieldFormatter.init()
+//        formatter.allowedCharacterSet = "-"
+//        self.angleTextF.formatter = formatter
+        
+        imagePPITextField.formatter = formatter
+        
+        formatter = NumberFormatter()
+        formatter.numberStyle = .decimal
+//        formatter.minimum = 10 // 设置最小值(可选)
+//        formatter.maximum = 24000 // 设置最大值(可选)
+        imageAbovePPITextField.formatter = formatter
     }
     
     override func reloadData() {
@@ -31,4 +64,40 @@ class KMCompressImagesPanelTableCellView: KMBaseCompressTableCellView, NibLoadab
         
         self.titleLabel.stringValue = NSLocalizedString(model.title, comment: "")
     }
+    
+}
+
+extension KMCompressImagesPanelTableCellView {
+    // 实时过滤输入,限制为数字
+    func controlTextDidChange(_ obj: Notification) {
+        guard let textField = obj.object as? NSTextField else { return }
+
+        // 仅保留数字字符
+        let filtered = textField.stringValue.filter { $0.isNumber }
+//        if textField.stringValue != filtered {
+            textField.stringValue = filtered
+//        }
+    }
+
+    // 检查输入范围并提示
+    func controlTextDidEndEditing(_ obj: Notification) {
+        guard let textField = obj.object as? NSTextField,
+              let value = Int(textField.stringValue) else { return }
+
+        // 检查是否超出范围
+        if value < minValue || value > maxValue {
+            showAlert(message: "请输入范围 \(minValue) 到 \(maxValue) 的数字")
+            textField.stringValue = "" // 清空无效输入
+        }
+    }
+
+    // 显示警告提示
+    private func showAlert(message: String) {
+        let alert = NSAlert()
+        alert.messageText = "输入无效"
+        alert.informativeText = message
+        alert.alertStyle = .warning
+        alert.addButton(withTitle: "确定")
+        alert.runModal()
+    }
 }

+ 56 - 4
PDF Office/PDF Master/Class/Batch/WindowController/VC/Compress/SettingView/View/KMCompressImagesPanelTableCellView.xib

@@ -3,7 +3,6 @@
     <dependencies>
         <deployment identifier="macosx"/>
         <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
-        <capability name="System colors introduced in macOS 10.13" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -41,12 +40,27 @@
                                     <view key="contentView" id="ADh-6q-unE">
                                         <rect key="frame" x="0.0" y="0.0" width="50" height="20"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                        <subviews>
+                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YEb-Wo-gCO">
+                                                <rect key="frame" x="0.0" y="0.0" width="50" height="20"/>
+                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="iE6-OF-SCe">
+                                                    <font key="font" usesAppearanceFont="YES"/>
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                </textFieldCell>
+                                            </textField>
+                                        </subviews>
+                                        <constraints>
+                                            <constraint firstAttribute="bottom" secondItem="YEb-Wo-gCO" secondAttribute="bottom" id="471-q4-tno"/>
+                                            <constraint firstItem="YEb-Wo-gCO" firstAttribute="top" secondItem="ADh-6q-unE" secondAttribute="top" id="L2k-hm-JXd"/>
+                                            <constraint firstItem="YEb-Wo-gCO" firstAttribute="leading" secondItem="ADh-6q-unE" secondAttribute="leading" id="P0n-SG-rsj"/>
+                                            <constraint firstAttribute="trailing" secondItem="YEb-Wo-gCO" secondAttribute="trailing" id="SWZ-gr-ACH"/>
+                                        </constraints>
                                     </view>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="20" id="AZ4-sb-4TZ"/>
                                         <constraint firstAttribute="width" constant="50" id="jZL-ix-Q12"/>
                                     </constraints>
-                                    <color key="fillColor" name="findHighlightColor" catalog="System" colorSpace="catalog"/>
                                 </box>
                                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="taM-CD-cQz">
                                     <rect key="frame" x="147" y="17" width="24" height="16"/>
@@ -69,12 +83,27 @@
                                     <view key="contentView" id="yLL-Y6-iJB">
                                         <rect key="frame" x="0.0" y="0.0" width="50" height="20"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                        <subviews>
+                                            <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iP8-Kl-ohG">
+                                                <rect key="frame" x="0.0" y="0.0" width="50" height="20"/>
+                                                <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="LxG-T2-nGg">
+                                                    <font key="font" usesAppearanceFont="YES"/>
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                </textFieldCell>
+                                            </textField>
+                                        </subviews>
+                                        <constraints>
+                                            <constraint firstAttribute="trailing" secondItem="iP8-Kl-ohG" secondAttribute="trailing" id="VZA-lh-a0K"/>
+                                            <constraint firstItem="iP8-Kl-ohG" firstAttribute="leading" secondItem="yLL-Y6-iJB" secondAttribute="leading" id="bm8-Fi-Ylh"/>
+                                            <constraint firstItem="iP8-Kl-ohG" firstAttribute="top" secondItem="yLL-Y6-iJB" secondAttribute="top" id="lsd-zB-sGA"/>
+                                            <constraint firstAttribute="bottom" secondItem="iP8-Kl-ohG" secondAttribute="bottom" id="sb7-i0-laX"/>
+                                        </constraints>
                                     </view>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="20" id="PCm-5n-mSf"/>
                                         <constraint firstAttribute="width" constant="50" id="raH-h1-YEU"/>
                                     </constraints>
-                                    <color key="fillColor" name="findHighlightColor" catalog="System" colorSpace="catalog"/>
                                 </box>
                                 <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vte-w4-cRw">
                                     <rect key="frame" x="380" y="17" width="24" height="16"/>
@@ -97,12 +126,32 @@
                                     <view key="contentView" id="xbz-NL-sTL">
                                         <rect key="frame" x="0.0" y="0.0" width="76" height="20"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                        <subviews>
+                                            <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="05O-ID-Yh1">
+                                                <rect key="frame" x="-1" y="-2" width="80" height="23"/>
+                                                <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="jEM-6s-eQ3">
+                                                    <font key="font" metaFont="system"/>
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                    <objectValues>
+                                                        <string>Low</string>
+                                                        <string>Medium</string>
+                                                        <string>Hight</string>
+                                                    </objectValues>
+                                                </comboBoxCell>
+                                            </comboBox>
+                                        </subviews>
+                                        <constraints>
+                                            <constraint firstItem="05O-ID-Yh1" firstAttribute="leading" secondItem="xbz-NL-sTL" secondAttribute="leading" id="0R5-uC-NfT"/>
+                                            <constraint firstItem="05O-ID-Yh1" firstAttribute="top" secondItem="xbz-NL-sTL" secondAttribute="top" id="6IJ-Am-u7u"/>
+                                            <constraint firstAttribute="trailing" secondItem="05O-ID-Yh1" secondAttribute="trailing" id="Cgz-ve-0ad"/>
+                                            <constraint firstAttribute="bottom" secondItem="05O-ID-Yh1" secondAttribute="bottom" id="tDi-cZ-uBN"/>
+                                        </constraints>
                                     </view>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="20" id="gKI-Vf-5GK"/>
                                         <constraint firstAttribute="width" constant="76" id="gOn-AM-2mB"/>
                                     </constraints>
-                                    <color key="fillColor" name="findHighlightColor" catalog="System" colorSpace="catalog"/>
                                 </box>
                             </subviews>
                             <constraints>
@@ -143,6 +192,9 @@
             </constraints>
             <connections>
                 <outlet property="buttonConetntView" destination="Yqh-YR-NAF" id="UP5-Yj-8FY"/>
+                <outlet property="comboBox" destination="05O-ID-Yh1" id="Pih-F9-7qe"/>
+                <outlet property="imageAbovePPITextField" destination="iP8-Kl-ohG" id="OCs-YY-RhH"/>
+                <outlet property="imagePPITextField" destination="YEb-Wo-gCO" id="B1C-AV-pdz"/>
                 <outlet property="titleLabel" destination="Ht4-BQ-Ga8" id="qMg-MO-MFT"/>
             </connections>
             <point key="canvasLocation" x="100" y="5"/>

+ 1 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/Compress/SettingView/View/KMCompressModesTableCellView.swift

@@ -10,7 +10,7 @@ import Cocoa
 class KMCompressModesTableCellView: KMBaseCompressTableCellView, NibLoadable {
 
     @IBOutlet weak var titleLabel: NSTextField!
-    @IBOutlet weak var comboBox: KMComboBox!
+    @IBOutlet weak var comboBox: NSComboBox!
     
     override var model: KMCompressSettingModel? {
         didSet {

+ 6 - 6
PDF Office/PDF Master/Class/Batch/WindowController/VC/Compress/SettingView/View/KMCompressModesTableCellView.xib

@@ -24,19 +24,19 @@
                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                             </textFieldCell>
                         </textField>
-                        <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cuA-kr-lmT" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                        <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cuA-kr-lmT">
                             <rect key="frame" x="61" y="0.0" width="116" height="23"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="112" id="QC1-ot-AoB"/>
                             </constraints>
-                            <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="mKD-ja-P6j" customClass="KMComboBoxCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                            <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="mKD-ja-P6j">
                                 <font key="font" metaFont="system"/>
                                 <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 <objectValues>
-                                    <string>Item 1</string>
-                                    <string>Item 2</string>
-                                    <string>Item 3</string>
+                                    <string>Standard</string>
+                                    <string>Mobile</string>
+                                    <string>Custom</string>
                                 </objectValues>
                             </comboBoxCell>
                         </comboBox>
@@ -56,7 +56,7 @@
                 <constraint firstAttribute="bottom" secondItem="yHv-cb-JkX" secondAttribute="bottom" constant="24" id="vjT-XX-HY8"/>
             </constraints>
             <connections>
-                <outlet property="comboBox" destination="cuA-kr-lmT" id="4vO-FB-KGp"/>
+                <outlet property="comboBox" destination="cuA-kr-lmT" id="dE3-Dg-C73"/>
                 <outlet property="titleLabel" destination="Odo-EZ-jmE" id="3Ko-Zp-cC5"/>
             </connections>
             <point key="canvasLocation" x="132" y="29"/>

+ 15 - 13
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -3391,7 +3391,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "374"
             endingLineNumber = "374"
-            landmarkName = "reloadData()"
+            landmarkName = "setup()"
             landmarkType = "7">
             <Locations>
                <Location
@@ -4717,7 +4717,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "483"
             endingLineNumber = "483"
-            landmarkName = "updateImageAreasOpacity(opacity:state:needListView:)"
+            landmarkName = "updateUI()"
             landmarkType = "7">
             <Locations>
                <Location
@@ -23496,7 +23496,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "524"
             endingLineNumber = "524"
-            landmarkName = "controlTextDidEndEditing(_:)"
+            landmarkName = "checkPageRangeValidate(_:)"
             landmarkType = "7">
             <Locations>
                <Location
@@ -25429,8 +25429,8 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "784"
             endingLineNumber = "784"
-            landmarkName = "KMWatermarkView"
-            landmarkType = "21">
+            landmarkName = "buttonClicked_BrowseFile(_:)"
+            landmarkType = "7">
             <Locations>
                <Location
                   uuid = "C2B378E2-00D3-429F-A2B4-7DB132E9F6D0 - 9f4a06c3dd13a66"
@@ -26152,7 +26152,9 @@
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1251"
-            endingLineNumber = "1251">
+            endingLineNumber = "1251"
+            landmarkName = "KMWatermarkView"
+            landmarkType = "21">
             <Locations>
                <Location
                   uuid = "DCE593F5-0330-4DF3-BD7D-1D81D887F0B3 - dae942b19efa51f3"
@@ -26277,7 +26279,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1248"
             endingLineNumber = "1248"
-            landmarkName = "deleteWatermarks(toPath:completion:)"
+            landmarkName = "addWatermark(model:toPath:completion:)"
             landmarkType = "7">
             <Locations>
                <Location
@@ -26356,8 +26358,8 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "106"
             endingLineNumber = "106"
-            landmarkName = "changeEffectiveAppearance()"
-            landmarkType = "7">
+            landmarkName = "editingAreas"
+            landmarkType = "24">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -29011,7 +29013,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "682"
             endingLineNumber = "682"
-            landmarkName = "buttonClicked_BrowseFile(_:)"
+            landmarkName = "buttonClicked_SwitchTextWatermark(_:)"
             landmarkType = "7">
             <Locations>
                <Location
@@ -29059,7 +29061,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "669"
             endingLineNumber = "669"
-            landmarkName = "buttonClicked_BrowseFile(_:)"
+            landmarkName = "hideWaitting()"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
@@ -31624,7 +31626,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "278"
             endingLineNumber = "278"
-            landmarkName = "updateLanguage()"
+            landmarkName = "setup()"
             landmarkType = "7">
             <Locations>
                <Location
@@ -32386,7 +32388,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1064"
             endingLineNumber = "1064"
-            landmarkName = "addWatermark(model:toPath:completion:)"
+            landmarkName = "pageRangeComboxAction(_:)"
             landmarkType = "7">
             <Locations>
                <Location