Browse Source

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

tangchao 1 year ago
parent
commit
6392add6be

+ 19 - 8
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift

@@ -327,21 +327,32 @@ import Cocoa
                 menuItemAction_newTagPageToNewWindow("")
             } else {
                 let window = NSWindow.currentWindow()
-                let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
-                tabbingWin.selectCallBack = { continueOrNot in
-                    window.km_quick_endSheet()
-                    if continueOrNot {
-                        self.menuItemAction_newTagPageToNewWindow("")
-                    } else {
-                        
+                if !KMTools.defaultManager.isTabbingWin{
+                    KMTools.defaultManager.isTabbingWin = true
+                    let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
+                    tabbingWin.selectCallBack = { continueOrNot in
+                        window.km_quick_endSheet()
+                        KMTools.defaultManager.isTabbingWin = false
+                        if continueOrNot {
+                            self.reopenDocument(forPaths: [])
+                        } else {
+                            
+                        }
                     }
+                    window.km_beginSheet(windowC: tabbingWin)
                 }
-                window.km_beginSheet(windowC: tabbingWin)
             }
         } else {
             openDocumentWindow()
         }
     }
+    
+    func reopenDocument(forPaths paths: [String]) -> Void {
+        let browser = KMBrowser.init() as KMBrowser
+        browser.windowController = KMBrowserWindowController.init(browser: browser)
+        browser.addHomeTabContents()
+        browser.windowController.showWindow(self)
+    }
 
     func closeAllTabs(_ sender: Any) -> Void {
         if self.browser != nil {

+ 7 - 0
PDF Office/PDF Master/Class/Common/Tools/KMTools.swift

@@ -10,6 +10,13 @@ import Cocoa
 @objc class KMTools: NSObject {
     // MARK: - 获取已打开的文件
     
+    static let defaultManager: KMTools = {
+        let manager = KMTools()
+        return manager
+    }()
+    
+    var isTabbingWin = false  //多页签提示页是否展示中
+    
     @objc class func getOpenDocumentURLs() -> [URL] {
         var files:[URL] = []
         for window in NSApp.windows {

+ 26 - 1
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -212,11 +212,36 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
                     }
                 }
             } else {
-                currentWindowController?.browser.add(self, at: Int32()-1, inForeground: true)
+                if currentWindowController?.browser.tabCount() ?? 0 > 1{
+                    let window = NSWindow.currentWindow()
+                    if !KMTools.defaultManager.isTabbingWin{
+                        KMTools.defaultManager.isTabbingWin = true
+                        let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
+                        tabbingWin.selectCallBack = { continueOrNot in
+                            window.km_quick_endSheet()
+                            KMTools.defaultManager.isTabbingWin = false
+                            if continueOrNot {
+                                self.reopenDocument(forPaths: [])
+                            } else {
+                                
+                            }
+                        }
+                        window.km_beginSheet(windowC: tabbingWin)
+                    }
+                }else {
+                    currentWindowController?.browser.add(self, at: Int32()-1, inForeground: true)
+                }
             }
         }
     }
     
+    func reopenDocument(forPaths paths: [String]) -> Void {
+        let browser = KMBrowser.init() as KMBrowser
+        browser.windowController = KMBrowserWindowController.init(browser: browser)
+        browser.addHomeTabContents()
+        browser.windowController.showWindow(self)
+    }
+    
     override func showWindows() {
         super.showWindows()
         

+ 19 - 8
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -322,19 +322,30 @@ extension KMHomeViewController {
             menuItemAction_newTagPageToNewWindow("")
         } else {
             let window = NSWindow.currentWindow()
-            let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
-            tabbingWin.selectCallBack = { continueOrNot in
-                window.km_quick_endSheet()
-                if continueOrNot {
-                    self.menuItemAction_newTagPageToNewWindow("")
-                } else {
-                    
+            if !KMTools.defaultManager.isTabbingWin{
+                KMTools.defaultManager.isTabbingWin = true
+                let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
+                tabbingWin.selectCallBack = { continueOrNot in
+                    window.km_quick_endSheet()
+                    KMTools.defaultManager.isTabbingWin = false
+                    if continueOrNot {
+                        self.reopenDocument(forPaths: [])
+                    } else {
+                        
+                    }
                 }
+                window.km_beginSheet(windowC: tabbingWin)
             }
-            window.km_beginSheet(windowC: tabbingWin)
         }
     }
     
+    func reopenDocument(forPaths paths: [String]) -> Void {
+        let browser = KMBrowser.init() as KMBrowser
+        browser.windowController = KMBrowserWindowController.init(browser: browser)
+        browser.addHomeTabContents()
+        browser.windowController.showWindow(self)
+    }
+    
     func openHistoryFilePath(url: URL) -> Void {
         if !url.path.isPDFValid() {
             let alert = NSAlert()

+ 6 - 8
PDF Office/PDF Master/Class/PDFTools/PageEdit/OCPart/CustomAlertView.swift

@@ -28,7 +28,8 @@ class CustomAlertView: NSView {
         let view = CustomAlertView()
         let style = NSMutableParagraphStyle()
         style.lineBreakMode = .byWordWrapping
-        style.lineHeightMultiple = 1.32
+//        style.lineHeightMultiple = 1.32
+        style.alignment = .center
         
         var fontSize: CGFloat = 0
         var offsetSize = CGSize.zero
@@ -44,7 +45,7 @@ class CustomAlertView: NSView {
         ]
         
         let maxSize = CGSize(width: min(supverView.frame.size.width - 80, 500), height: supverView.frame.size.height - 40)
-        let size = message.boundingRect(with: maxSize, options: [.truncatesLastVisibleLine, .usesLineFragmentOrigin, .usesFontLeading], attributes: attributes).size
+        let size = message.boundingRect(with: maxSize, options: [.usesLineFragmentOrigin], attributes: attributes).size
         
         let ceilSize = NSSize(width: ceil(size.width), height: ceil(size.height))
         
@@ -87,15 +88,12 @@ class CustomAlertView: NSView {
         messageLabel.backgroundColor = NSColor.clear
         messageLabel.isBordered = false
         messageLabel.isEditable = false
-        messageLabel.lineBreakMode = .byWordWrapping
         messageLabel.usesSingleLineMode = false
         messageLabel.cell?.wraps = true
-        if #available(OSX 10.11, *) {
-            messageLabel.lineBreakMode = .byWordWrapping
-        }
-        
         messageLabel.alignment = .center
-        messageLabel.stringValue = message
+        messageLabel.attributedStringValue = NSMutableAttributedString(string: NSLocalizedString(message, comment: ""),
+                                                                       attributes: [NSAttributedString.Key.paragraphStyle: style,
+                                                                                    NSAttributedString.Key.font : NSFont.systemFont(ofSize: fontSize)])
         view.addSubview(messageLabel)
         view.alphaAnimation(from: 0, to: 1, duration: 0.3) {
             DispatchQueue.main.asyncAfter(deadline: .now() + 2) {

+ 17 - 17
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/TransitionSheet.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
         <deployment version="1060" identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -32,13 +32,13 @@
             <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="282" y="439" width="426" height="280"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
             <value key="minSize" type="size" width="213" height="107"/>
             <view key="contentView" id="8">
                 <rect key="frame" x="0.0" y="0.0" width="426" height="280"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <button verticalHuggingPriority="750" tag="1" imageHugsTitle="YES" id="27">
+                    <button tag="1" imageHugsTitle="YES" verticalHuggingPriority="750" id="27">
                         <rect key="frame" x="330" y="12" width="82" height="32"/>
                         <autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
                         <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" tag="1" inset="2" id="436">
@@ -53,7 +53,7 @@ DQ
                             <action selector="okAction:" target="-2" id="3k6-Ji-BSx"/>
                         </connections>
                     </button>
-                    <button verticalHuggingPriority="750" imageHugsTitle="YES" id="31">
+                    <button imageHugsTitle="YES" verticalHuggingPriority="750" id="31">
                         <rect key="frame" x="248" y="12" width="82" height="32"/>
                         <autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
                         <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="437">
@@ -71,10 +71,10 @@ Gw
                         <rect key="frame" x="123" y="120" width="286" height="118"/>
                         <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
                         <view key="contentView" id="nHl-1V-Bnj">
-                            <rect key="frame" x="3" y="3" width="280" height="100"/>
+                            <rect key="frame" x="4" y="5" width="278" height="98"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <textField verticalHuggingPriority="750" id="28">
+                                <textField focusRingType="none" verticalHuggingPriority="750" id="28">
                                     <rect key="frame" x="216" y="42" width="50" height="22"/>
                                     <autoresizingMask key="autoresizingMask"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="1.0" drawsBackground="YES" id="442">
@@ -98,7 +98,7 @@ Gw
                                         <action selector="changeDurationSlider:" target="-2" id="2QH-Mx-YnZ"/>
                                     </connections>
                                 </slider>
-                                <popUpButton verticalHuggingPriority="750" imageHugsTitle="YES" id="13">
+                                <popUpButton imageHugsTitle="YES" verticalHuggingPriority="750" id="13">
                                     <rect key="frame" x="81" y="68" width="188" height="26"/>
                                     <autoresizingMask key="autoresizingMask"/>
                                     <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="439">
@@ -107,7 +107,7 @@ Gw
                                         <menu key="menu" id="14"/>
                                     </popUpButtonCell>
                                 </popUpButton>
-                                <textField verticalHuggingPriority="750" id="9">
+                                <textField focusRingType="none" verticalHuggingPriority="750" id="9">
                                     <rect key="frame" x="35" y="75" width="44" height="17"/>
                                     <autoresizingMask key="autoresizingMask"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Effect:" id="438">
@@ -116,7 +116,7 @@ Gw
                                         <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                     </textFieldCell>
                                 </textField>
-                                <textField verticalHuggingPriority="750" id="25">
+                                <textField focusRingType="none" verticalHuggingPriority="750" id="25">
                                     <rect key="frame" x="15" y="44" width="64" height="17"/>
                                     <autoresizingMask key="autoresizingMask"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Duration:" id="440">
@@ -150,7 +150,7 @@ Gw
                                         </column>
                                     </cells>
                                 </matrix>
-                                <textField verticalHuggingPriority="750" id="26">
+                                <textField focusRingType="none" verticalHuggingPriority="750" id="26">
                                     <rect key="frame" x="30" y="15" width="49" height="17"/>
                                     <autoresizingMask key="autoresizingMask"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Extent:" id="441">
@@ -166,11 +166,11 @@ Gw
                         <rect key="frame" x="123" y="56" width="286" height="60"/>
                         <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
                         <view key="contentView" id="mnE-pI-3iK">
-                            <rect key="frame" x="3" y="3" width="280" height="42"/>
+                            <rect key="frame" x="4" y="5" width="278" height="40"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <popUpButton verticalHuggingPriority="750" imageHugsTitle="YES" id="69">
-                                    <rect key="frame" x="15" y="10" width="244" height="26"/>
+                                <popUpButton imageHugsTitle="YES" verticalHuggingPriority="750" id="69">
+                                    <rect key="frame" x="15" y="10" width="242" height="26"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
                                     <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="81" id="444">
                                         <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@@ -200,11 +200,11 @@ Gw
                         <rect key="frame" x="20" y="20" width="98" height="240"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                         <clipView key="contentView" id="wPo-Zi-yxU">
-                            <rect key="frame" x="1" y="1" width="96" height="238"/>
+                            <rect key="frame" x="1" y="1" width="85" height="238"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
                                 <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnResizing="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="32" id="279" customClass="KMBotaTableView" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                                    <rect key="frame" x="0.0" y="0.0" width="96" height="238"/>
+                                    <rect key="frame" x="0.0" y="0.0" width="85" height="238"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <size key="intercellSpacing" width="3" height="2"/>
                                     <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -242,7 +242,7 @@ Gw
                             <autoresizingMask key="autoresizingMask"/>
                         </scroller>
                         <scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" controlSize="small" horizontal="NO" id="447" userLabel="Vertical Scroller" customClass="SKScroller">
-                            <rect key="frame" x="83" y="1" width="14" height="238"/>
+                            <rect key="frame" x="86" y="1" width="11" height="238"/>
                             <autoresizingMask key="autoresizingMask"/>
                         </scroller>
                     </scrollView>

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Thumbnail.swift

@@ -99,7 +99,7 @@ extension KMLeftSideViewController {
     }
     
     func thumb_selectRowIndexsIfNeed(_ indexs: IndexSet) {
-        if self.type.methodType != .Thumbnail {
+        if self.type.methodType != .Thumbnail && self.mainViewController.isReadMode == false {
             return
         }
         

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

@@ -4576,22 +4576,33 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 menuItemAction_newTagPageToNewWindow("")
             } else {
                 let window = NSWindow.currentWindow()
-                let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
-                tabbingWin.selectCallBack = { continueOrNot in
-                    window.km_quick_endSheet()
-                    if continueOrNot {
-                        self.menuItemAction_newTagPageToNewWindow("")
-                    } else {
-                        
+                if !KMTools.defaultManager.isTabbingWin{
+                    KMTools.defaultManager.isTabbingWin = true
+                    let tabbingWin: KMTabbingHintWindowController = KMTabbingHintWindowController()
+                    tabbingWin.selectCallBack = { continueOrNot in
+                        window.km_quick_endSheet()
+                        KMTools.defaultManager.isTabbingWin = false
+                        if continueOrNot {
+                            self.reopenDocument(forPaths: [])
+                        } else {
+                            
+                        }
                     }
+                    window.km_beginSheet(windowC: tabbingWin)
                 }
-                window.km_beginSheet(windowC: tabbingWin)
             }
         }else{
            handleTabbingLogic()
         }
     }
     
+    func reopenDocument(forPaths paths: [String]) -> Void {
+        let browser = KMBrowser.init() as KMBrowser
+        browser.windowController = KMBrowserWindowController.init(browser: browser)
+        browser.addHomeTabContents()
+        browser.windowController.showWindow(self)
+    }
+    
     func handleTabbingLogic() {
         self.browserWindowController?.browser.selectTabContents(at: 0, userGesture: true)
         self.toolbarController.findItem(KMDocumentHomeToolbarItemIdentifier)?.isSelected = false

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

@@ -267,6 +267,7 @@ let LOCKED_KEY  = "locked"
         self.initRightSideView()
         self.toolbarController.listView = self.listView
         self.toolbarController.mainViewController = self
+        self.leftSideViewController.mainViewController = self
         
         self.newPDFSplitView.delegate = self
     }