瀏覽代碼

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

tangchao 11 月之前
父節點
當前提交
2f1ff5623d

+ 8 - 8
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -1052,14 +1052,14 @@ let KMColorPickerViewHeight: CGFloat = 64
         helpButton.toolTip = NSLocalizedString("Help", comment: "")
         helpButton.setTitleColor(KMAppearance.Layout.h0Color())
 
-        let languages = NSLocale.preferredLanguages
-        var currentLocaleLanguageCode = "en"
-        if let firstLanguage = languages.first {
-            currentLocaleLanguageCode = firstLanguage
-            if currentLocaleLanguageCode.hasPrefix("zh") {
-                currentLocaleLanguageCode = "zh"
-            }
-        }
+//        let languages = NSLocale.preferredLanguages
+        var currentLocaleLanguageCode = NSLocalizedString("en-new", comment: "")
+//        if let firstLanguage = languages.first {
+//            currentLocaleLanguageCode = firstLanguage
+//            if currentLocaleLanguageCode.hasPrefix("zh") {
+//                currentLocaleLanguageCode = "zh"
+//            }
+//        }
 
         let buttonArray: [NSButton] = [commentButton, keyButton, noteButton, helpButton, addParagraphButton, paragraphButton, insertButton]
         for button in buttonArray {

+ 9 - 9
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="Named colors" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -974,7 +974,7 @@
                                             <subviews>
                                                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3Ed-Ae-CMS">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteAnnotationNor" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="8we-yJ-WKl" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteAnnotationNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="8we-yJ-WKl" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>
@@ -1004,7 +1004,7 @@
                                             <subviews>
                                                 <button tag="1" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pNP-oo-3HC">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteKeywordNor" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="x9S-PD-K5t" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteKeywordNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="x9S-PD-K5t" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>
@@ -1030,7 +1030,7 @@
                                             <subviews>
                                                 <button tag="3" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VCq-Fv-Klu">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteHelpNor" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="kSq-7X-thX" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteHelpNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="kSq-7X-thX" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>
@@ -1056,7 +1056,7 @@
                                             <subviews>
                                                 <button tag="4" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="d7b-6U-kd3">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteNewparagraphNor" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="Xdy-yH-fug" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteNewparagraphNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="Xdy-yH-fug" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>
@@ -1082,7 +1082,7 @@
                                             <subviews>
                                                 <button tag="5" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sxj-hT-PcD">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteParagraphNor" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="uwc-Vw-AjX" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteParagraphNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="uwc-Vw-AjX" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>
@@ -1108,7 +1108,7 @@
                                             <subviews>
                                                 <button tag="6" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fgj-OF-eg6">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteInsertNor" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="OSE-y6-2oj" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteInsertNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="OSE-y6-2oj" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>
@@ -1134,7 +1134,7 @@
                                             <subviews>
                                                 <button tag="2" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="InC-Sr-498">
                                                     <rect key="frame" x="28" y="0.0" width="50" height="56"/>
-                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteNotesNor" imagePosition="above" alignment="center" imageScaling="proportionallyDown" inset="2" id="4HQ-Cw-eAg" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                                                    <buttonCell key="cell" type="square" title="Button" bezelStyle="shadowlessSquare" image="KMImageNameUXIconPropertybarNoteNotesNor" imagePosition="above" alignment="center" scrollable="YES" lineBreakMode="clipping" imageScaling="proportionallyDown" inset="2" id="4HQ-Cw-eAg" customClass="KMNoteIconButtonCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                                         <font key="font" metaFont="smallSystem"/>
                                                     </buttonCell>

+ 103 - 9
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -126,6 +126,8 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
     @IBOutlet var zoomButton: NSPopUpButton!
     @IBOutlet var zoomView: NSView!
     @IBOutlet weak var zoomTextField: NSTextField!
+    
+    var searchField: NSSearchField = NSSearchField()
     var pdfView : CPDFListView = CPDFListView()
     var shareButton = KMToolbarClickButton()
     private var bottomLine = NSView()
@@ -519,7 +521,7 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
                     KMPrint("按下 enter")
                     self.delegate?.toolbarViewController?(self, zoomSting: self.zoomTextField.stringValue)
                 } else if let _ = control as? NSSearchField {
-                    self.delegate?.toolbarViewController?(self, searchAction: control.stringValue, forward: true)
+                    self.searchPDFKey(control.stringValue)
                 }
             }
             return true
@@ -528,11 +530,6 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
         }
     }
     
-    @objc func toggleCaseInsensitiveSearch(_ sender: NSMenuItem) {
-        var value = KMDataManager.ud_integer(forKey: SKCaseInsensitiveSearchKey)
-        KMDataManager.ud_set(value == 0 ? 1 : 0, forKey: SKCaseInsensitiveSearchKey)
-    }
-    
     // MARK: - Private Methods
     
     private func _itemSetPromptFlag(item: KMToolbarItemView?) {
@@ -1295,9 +1292,9 @@ extension KMToolbarViewController {
             searchView.sendsSearchStringImmediately = true
             searchView.drawsBackground = false
             searchView.delegate = self
-            let menu = NSMenu()
-            let searchItem = menu.addItem(title: KMLocalizedString("Ignore Case", "Menu item title"), action: #selector(toggleCaseInsensitiveSearch), target: self)
-            (searchView.cell as? NSSearchFieldCell)?.searchMenuTemplate = menu
+            self.searchField = searchView
+            
+            self.refreshSearchBarMenu()
             
             boxView.addSubview(searchView)
             let titleLabel = NSTextField(labelWithString: NSLocalizedString("Search", comment: ""))
@@ -2115,3 +2112,100 @@ extension KMToolbarViewController {
         }
     }
 }
+
+extension KMToolbarViewController {
+    func refreshSearchBarMenu() {
+        let words = UserDefaults.standard.array(forKey: "kmDocumentSearchWordArrays") as? [String] ?? []
+        let searchMenu = NSMenu()
+        
+        for word in words {
+            var truncatedWord = word
+            if word.count > 15 {
+                truncatedWord = String(word.prefix(15)) + "..."
+            }
+            let item = searchMenu.addItem(withTitle: truncatedWord, action: #selector(searchPDFKeyWord(_:)), keyEquivalent: "")
+            item.representedObject = word
+        }
+        
+        let attributes: [NSAttributedString.Key: Any] = [.font: NSFont(name: "Helvetica", size: 12.0)!]
+
+        if !words.isEmpty {
+            let attributedString = NSAttributedString(string: NSLocalizedString("Search History", comment: ""), attributes: attributes)
+            let item = NSMenuItem()
+            item.attributedTitle = attributedString
+            searchMenu.insertItem(item, at: 0)
+            searchMenu.addItem(NSMenuItem.separator())
+            
+            let attributedString1 = NSAttributedString(string: NSLocalizedString("Clear Search History", comment: ""), attributes: attributes)
+            let item1 = NSMenuItem()
+            item1.attributedTitle = attributedString1
+            item1.action = #selector(clearSearchWordHistory(_:))
+            item1.target = self
+            searchMenu.addItem(item1)
+            
+            searchMenu.insertItem(NSMenuItem.separator(), at: 0)
+        }
+        
+        let attributedString2 = NSAttributedString(string: NSLocalizedString("Ignore Case", comment: ""), attributes: attributes)
+        let ignoreItem = NSMenuItem()
+        ignoreItem.attributedTitle = attributedString2
+        ignoreItem.action = #selector(toggleCaseInsensitiveSearch)
+        ignoreItem.target = self
+        searchMenu.insertItem(ignoreItem, at: 0)
+
+        (self.searchField.cell as? NSSearchFieldCell)?.searchMenuTemplate = searchMenu
+    
+    }
+    
+    @objc func toggleCaseInsensitiveSearch(_ sender: NSMenuItem) {
+        var value = KMDataManager.ud_integer(forKey: SKCaseInsensitiveSearchKey)
+        KMDataManager.ud_set(value == 0 ? 1 : 0, forKey: SKCaseInsensitiveSearchKey)
+        
+        let caseInsensitive = UserDefaults.standard.bool(forKey: "SKCaseInsensitiveFindKey")
+        UserDefaults.standard.set(!caseInsensitive, forKey: "SKCaseInsensitiveFindKey")
+    }
+    
+    @objc func searchPDFKeyWord(_ item: NSMenuItem) {
+        guard let word = item.representedObject as? String else {
+            return
+        }
+        
+        self.searchPDFKey(word)
+    }
+    
+    func searchPDFKey(_ string: String) {
+        self.searchField.stringValue = string
+        self.delegate?.toolbarViewController?(self, searchAction: string, forward: true)
+        
+        let word = string
+        var words = UserDefaults.standard.array(forKey: "kmDocumentSearchWordArrays") as? [String] ?? []
+        var mutableWords = words
+        
+        if let index = mutableWords.firstIndex(of: word) {
+            mutableWords.remove(at: index)
+        }
+        
+        mutableWords.insert(word, at: 0)
+        
+        if mutableWords.count > 10 {
+            mutableWords.removeLast()
+        }
+        
+        UserDefaults.standard.set(mutableWords, forKey: "kmDocumentSearchWordArrays")
+        UserDefaults.standard.synchronize()
+        
+        refreshSearchBarMenu()
+    }
+
+    @objc func clearSearchWordHistory(_ sender: Any) {
+        UserDefaults.standard.removeObject(forKey: "kmDocumentSearchWordArrays")
+        UserDefaults.standard.synchronize()
+        
+        refreshSearchBarMenu()
+    }
+
+//    @IBAction func toggleCaseInsensitiveFind(_ sender: Any) {
+//        let caseInsensitive = UserDefaults.standard.bool(forKey: "SKCaseInsensitiveFindKey")
+//        UserDefaults.standard.set(!caseInsensitive, forKey: "SKCaseInsensitiveFindKey")
+//    }
+}

+ 6 - 0
PDF Office/PDF Master/Strings/zh-Hans.lproj/Localizable.strings

@@ -3795,3 +3795,9 @@
 "Each use of the AI tools costs 1 or more credits."="每使用一次AI工具将消耗一个或多个权益点。";
 "Please Enter AI License"="请输入AI序列码";
 "For PDF Reader Pro Permanent/Premium License, please click PDF Reader Pro on the menubar, then tap \"Enter License\"."="如果您购买的是PDF Reader Pro高级版/标准版序列码,请点击菜单栏中“PDF Reader Pro” - “输入序列码”激活。";
+
+"en-new" = "zh";
+"Comment" = "注释";
+"Key" = "关键字";
+"New Paragraph" = "新增段落";
+"Paragraph" = "段落";

+ 6 - 0
PDF Office/PDF Master/Strings/zh-Hant.lproj/Localizable.strings

@@ -3914,3 +3914,9 @@
 "Please Enter AI License"="請輸入AI序列碼";
 "For PDF Reader Pro Permanent/Premium License, please click PDF Reader Pro on the menubar, then tap \"Enter License\"."="如果您購買的是PDF Reader Pro高級版/標準版序列碼,請點擊菜單欄中“PDF Reader Pro” - “輸入序列碼”激活。";
 
+"en-new" = "zh";
+"Comment" = "註解";
+"Key" = "關鍵字";
+"New Paragraph" = "新增段落";
+"Paragraph" = "段落";
+