Browse Source

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

tangchao 4 months ago
parent
commit
e7cd091571
18 changed files with 624 additions and 801 deletions
  1. 2 0
      PDF Office/KMComponentLibrary/KMComponentLibrary/View/ToolTips/ComponentToolTip.swift
  2. 0 53
      PDF Office/PDF Master/Class/Batch/Catogary/NSWindow+PopOver.swift
  3. 8 38
      PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController+Actions.swift
  4. 0 44
      PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift
  5. 0 24
      PDF Office/PDF Master/Class/Common/Category/NSResponder+KMExtension.swift
  6. 0 60
      PDF Office/PDF Master/Class/Common/Category/NSWindow+KMExtension.swift
  7. 1 12
      PDF Office/PDF Master/Class/KMLightMember/Manager/KMRequestServerManager.swift
  8. 0 5
      PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/KMFullScreenWindow.swift
  9. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift
  10. 3 179
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  11. 0 9
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift
  12. 5 1
      PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/KMHomeRightView.swift
  13. 299 97
      PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift
  14. 58 162
      PDF Office/PDF Master/Class/Common/Category/NSWindowController+KMExtension.swift
  15. 32 0
      PDF Office/PDF Master/KMClass/Tools/NSWindowController+Extension/NSWindowController+Extension.swift
  16. 163 0
      PDF Office/PDF Master/KMClass/Tools/NSWindowController+Extension/NSWindowController+KMExtension.swift
  17. 18 18
      PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj
  18. 34 98
      PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+ 2 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/ToolTips/ComponentToolTip.swift

@@ -175,6 +175,7 @@ public class ComponentToolTip: ComponentBaseXibView {
             
             titleLabel.stringValue = properties.title
             titleLabel.sizeToFit()
+            titleLabel.alignment = .left
              
             infoLabel.stringValue = properties.infoString ?? ""
             let infoSize = infoLabel.sizeThatFits(NSSize(width: 304, height: 1000))
@@ -191,6 +192,7 @@ public class ComponentToolTip: ComponentBaseXibView {
             
             titleLabel.font = properties.propertyInfo.subTextFont
             titleLabel.stringValue = properties.title
+            titleLabel.alignment = .center
             
             let size = titleLabel.sizeThatFits(CGSizeMake(properties.textMaxWidth, 500))
             var rect = titleLabel.frame

+ 0 - 53
PDF Office/PDF Master/Class/Batch/Catogary/NSWindow+PopOver.swift

@@ -1,53 +0,0 @@
-//
-//  NSWindow+PopOver.swift
-//  PDF Reader Pro
-//
-//  Created by kdanmobile on 2023/10/26.
-//
-
-import Foundation
-
-//var KMWindowPopOverKey = "KMWindowPopOverKey"
-//var KMWindowPopOverSourcesRectKey = "KMWindowPopOverSourcesRectKey"
-//extension NSWindow {
-//    var popover: NSPopover? {
-//        get {
-//            return objc_getAssociatedObject(self, &KMWindowPopOverKey) as? NSPopover
-//        }
-//        set {
-//            objc_setAssociatedObject(self, &KMWindowPopOverKey, newValue, .OBJC_ASSOCIATION_RETAIN)
-//        }
-//    }
-//    
-//    var sourcesRect: CGRect? {
-//        get {
-//            guard let value = objc_getAssociatedObject(self, &KMWindowPopOverSourcesRectKey) as? NSValue else {
-//                return nil
-//            }
-//            return value.rectValue
-//        }
-//        set {
-//            if let newValue = newValue {
-//                let value = NSValue(rect: newValue)
-//                objc_setAssociatedObject(self, &KMWindowPopOverSourcesRectKey, value, .OBJC_ASSOCIATION_RETAIN)
-//            } else {
-//                objc_setAssociatedObject(self, &KMWindowPopOverSourcesRectKey, nil, .OBJC_ASSOCIATION_RETAIN)
-//            }
-//        }
-//    }
-//    
-//    open override func mouseMoved(with event: NSEvent)  {
-//        super.mouseMoved(with: event)
-//        let point = event.locationInWindow
-//        if NSStringFromClass(event.window!.classForCoder).elementsEqual("_NSPopoverWindow") == false {
-//            if let data = sourcesRect?.contains(point), data == false {
-//                if (self.popover != nil) {
-//                    NotificationCenter.default.post(name: NSNotification.Name("KMPopOverClosedByWindowNotification"), object: self.popover)
-//                    popover!.close()
-//                    self.popover = nil
-//                    self.sourcesRect = CGRect.null
-//                }
-//            }
-//        }
-//    }
-//}

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

@@ -7,22 +7,12 @@
 
 import Foundation
 
-// MARK: - Actions
-
-@objc extension KMBrowserWindowController {
-    
-}
-
 // MARK: - 幻灯片
-
 extension KMBrowserWindowController {
     func canEnterFullscreen() -> Bool {
         if self.isSwitchingFullScreen {
             return false
         }
-//        if useNativeFullScreen() {
-//            return interactionMode == .SKNormalMode || interactionMode == .SKPresentationMode
-//        } else {
         if let mainVc = (self.document as? KMMainDocument)?.mainViewController {
             if mainVc.canEnterFullscreen() == false {
                 return false
@@ -62,8 +52,6 @@ extension KMBrowserWindowController {
         return false
     }
     
-    // 进入幻灯片
-    
     func enterPresentation() {
         self.window?.enterPresentation()
     }
@@ -89,27 +77,21 @@ extension KMBrowserWindowController {
         } else {
             let doc = self.document as? KMMainDocument
             view = doc?.mainViewController?.listView
-            contentView = doc?.mainViewController?.readContentView
+            contentView = doc?.mainViewController?.centerContentView
         }
-
-        self.hideLeftSideWindow()
-        self.hideRightSideWindow()
+ 
 
         let doc = self.document as? KMMainDocument
-       let mainViewController = doc?.mainViewController
+        let mainViewController = doc?.mainViewController
         
         mainViewController?.presentationTopViewController?.view.removeFromSuperview()
-
+        
         if let v = view {
             self.fadeOutFullScreenView(v)
             view?.frame = contentView?.bounds ?? .zero
+            view?.autoresizingMask = [.width, .height]
             contentView?.addSubview(v)
-            v.mas_makeConstraints { make in
-                make?.left.mas_equalTo()(0)
-                make?.right.mas_equalTo()(0)
-                make?.top.mas_equalTo()(0)
-                make?.bottom.mas_equalTo()(0)
-            }
+            
             (v as? CPDFListView)?.isPresentationMode = false
             (v as? CPDFListView)?.layoutDocumentView()
             (v as? CPDFListView)?.requiresDisplay()
@@ -121,6 +103,7 @@ extension KMBrowserWindowController {
         if let mainVc = (self.document as? KMMainDocument)?.mainViewController {
             mainVc.exitFullscreenMode()
         }
+        
         self.window?.isSwitchingFullScreen = false
 
         self.forceSubwindowsOnTop(false)
@@ -130,22 +113,9 @@ extension KMBrowserWindowController {
         self.fadeOutFullScreenWindow()
  
         self.synchronizeWindowTitleWithDocumentName()
-
-        self.removeBlankingWindows()
-    }
-    
-    func hideLeftSideWindow() {
-
-    }
-    
-    func hideRightSideWindow() {
-
+ 
     }
     
-    func removeBlankingWindows() {
-
-    }
-     
     func fadeOutFullScreenView(_ view: NSView) {
         guard let fullScreenWindow = self.window as? KMFullScreenWindow else {
             NSSound.beep()

+ 0 - 44
PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift

@@ -63,50 +63,6 @@ extension KMBaseWindowController {
     }
 }
 
-extension NSWindowController {
-    func kCheckPassword(url: URL, type: KMPasswordInputWindowType, password: String = "", completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
-        // 判断路径 + document
-        guard let document = CPDFDocument.init(url: url) else {
-            return completion(false, "")
-        }
-
-        // 判断是否为加密文档
-        if document.isLocked == false {
-            if type == .open {
-                completion(true, "")
-                return
-            }
-        }
-        
-        if document.isLocked == false && (document.allowsCopying && document.allowsPrinting) {
-            completion(true, "")
-            return
-        }
-        
-        // 加密文件,尝试解锁
-        if password.isEmpty == false {
-            let preStatus = document.permissionsStatus
-            document.unlock(withPassword: password)
-            if document.permissionsStatus.rawValue > preStatus.rawValue { // 解密成功
-                completion(true, password)
-                return
-            }
-        }
-        
-        // 弹密码弹窗
-        Task { @MainActor in
-            KMPasswordInputWindow.openWindow(window: self.window!, type: type, url: url) { result , password in
-                if (result == .cancel) {
-                    completion(false, "")
-                    return
-                } else {
-                    completion(true, password ?? "")
-                }
-            }
-        }
-    }
-}
-
 extension KMBaseWindowController {
     static func checkPassword(url: URL, type: KMPasswordInputWindowType, password: String = "", completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
         // 判断路径 + document

+ 0 - 24
PDF Office/PDF Master/Class/Common/Category/NSResponder+KMExtension.swift

@@ -194,28 +194,4 @@ extension NSResponder: KMWindowSheetProtocol {
     }
 }
 
-// MARK: - Sheet
 
-extension NSWindowController {
-    private static var _sheetParentResponderKey = "KMSheetParentResponderKey"
-    unowned var sheetParentResponder: NSResponder? {
-        get {
-            return objc_getAssociatedObject(self, &Self._sheetParentResponderKey) as? NSResponder
-        }
-    }
-    
-    private static var _sheetFlagKey = "KMSheetFlagKey"
-    var sheetFlag: Bool {
-        get {
-            return objc_getAssociatedObject(self, &Self._sheetFlagKey) as? Bool ?? false
-        }
-        set {
-            objc_setAssociatedObject(self, &Self._sheetFlagKey, newValue, .OBJC_ASSOCIATION_ASSIGN)
-        }
-    }
-    
-    // MARK: - Private Methods
-    fileprivate func _setSheetParentResponder(_ newValue: NSResponder?) {
-        objc_setAssociatedObject(self, &Self._sheetParentResponderKey, newValue, .OBJC_ASSOCIATION_ASSIGN)
-    }
-}

+ 0 - 60
PDF Office/PDF Master/Class/Common/Category/NSWindow+KMExtension.swift

@@ -1,60 +0,0 @@
-//
-//  NSWindow+KMExtension.swift
-//  PDF Reader Pro
-//
-//  Created by tangchao on 2023/10/30.
-//
-
-import Foundation
-
-private var _KMWindowPopOverKey = "KMWindowPopOverKey"
-private var _KMWindowPopOverSourcesRectKey = "KMWindowPopOverSourcesRectKey"
-extension NSWindow {
-    var popover: NSPopover? {
-        get {
-            return objc_getAssociatedObject(self, &_KMWindowPopOverKey) as? NSPopover
-        }
-        set {
-            objc_setAssociatedObject(self, &_KMWindowPopOverKey, newValue, .OBJC_ASSOCIATION_RETAIN)
-        }
-    }
-    
-    var sourcesRect: NSRect {
-        get {
-            if let data = objc_getAssociatedObject(self, &_KMWindowPopOverSourcesRectKey) as? NSValue {
-                return data.rectValue
-            }
-            return NSZeroRect
-        }
-        set {
-            objc_setAssociatedObject(self, &_KMWindowPopOverSourcesRectKey, NSValue(rect: newValue), .OBJC_ASSOCIATION_RETAIN)
-        }
-    }
-    
-    open override func mouseMoved(with event: NSEvent) {
-        super.mouseMoved(with: event)
-        
-        let point = event.locationInWindow
-        var need = true
-        if let data = event.window?.isKind(of: NSClassFromString("_NSPopoverWindow")!) {
-//            need = !data
-            if data {
-                need = false
-            } else {
-                need = true
-            }
-        } else {
-            need = true
-        }
-        if (need) {
-            if (self.sourcesRect.contains(point) == false) {
-                if self.popover != nil {
-                    NotificationCenter.default.post(name: Notification.Name("KMPopOverClosedByWindowNotification"), object: self.popover!)
-                    self.popover?.close()
-                    self.popover = nil
-                    self.sourcesRect = NSRect.null
-                }
-            }
-        }
-    }
-}

+ 1 - 12
PDF Office/PDF Master/Class/KMLightMember/Manager/KMRequestServerManager.swift

@@ -976,15 +976,4 @@ extension KMRequestServerManager {
     }
 }
 
-extension NSWindow {
-    static func currentWindow() -> NSWindow {
-        var window = NSApp.mainWindow
-        if NSApp.mainWindow?.sheets.first != nil {
-            window = NSApp.mainWindow?.sheets.first
-        }
-        if window == nil {
-            window = NSApplication.shared.windows.first
-        }
-        return window ?? NSWindow()
-    }
-}
+

+ 0 - 5
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/KMFullScreenWindow.swift

@@ -157,9 +157,4 @@ class KMFullScreenWindow: NSWindow, NSAnimationDelegate{
     }
 }
 
-extension NSWindowController{
-    func handleRightMouseDown(theEvent: NSEvent) -> Bool {
-        return false
-    }
-}
 

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

@@ -1514,7 +1514,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
                 if pathExtension == "pdf" {
                     let pdf = CPDFDocument(url: url!)
                     if let data = pdf?.isEncrypted, data {
-                        self.view.window?.windowController?.kCheckPassword(url: url!, type: .owner, completion: { [weak self] success, resultPassword in
+                        self.view.window?.windowController?.knCheckPassword(url: url!, type: .owner, completion: { [weak self] success, resultPassword in
                             if success && resultPassword.isEmpty == false {
                                 pdf?.unlock(withPassword: resultPassword)
                                 self?.model.insertedDocumentSet.insert(pdf!)

+ 3 - 179
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -698,27 +698,6 @@ extension KMMainViewController {
         return false
     }
     
-    func canEnterFullscreen() -> Bool {
-        if (mwcFlags.isSwitchingFullScreen != 0) {
-            return false
-        }
-        if useNativeFullScreen() {
-            return interactionMode == .normal || interactionMode == .presentation
-        } else {
-            return !self.listView.document.isLocked && (interactionMode == .normal || interactionMode == .presentation) && self.view.window?.tabbedWindows?.count ?? 0 < 2
-        }
-    }
-    
-    override func canEnterPresentation() -> Bool {
-        let can = super.canEnterPresentation()
-        if can == false {
-            return false
-        }
-        guard let doc = self.listView.document, doc.isLocked == false else {
-            return false
-        }
-        return can
-    }
     
     func useNativeFullScreen() -> Bool {
         var isFull = false
@@ -729,104 +708,12 @@ extension KMMainViewController {
         return isFull
     }
     
-    func enterPresentation() {
-        self.view.window?.enterPresentation(provider: self)
-    }
-    
-    func removeBlankingWindows() {
-    }
-    
-    func hideLeftSideWindow() {
-        
-    }
-    
-    func hideRightSideWindow() {
-        
-    }
+   
     
     func forceSubwindowsOnTop(_ flag: Bool) {
         
     }
     
-    func enterPresentationMode() {
-        let scrollView = listView.documentView().enclosingScrollView
-        savedNormalSetup.setValue(scrollView?.hasHorizontalScroller, forKey: KMMainModel.Key.kHasHorizontalScroller)
-        savedNormalSetup.setValue(scrollView?.hasVerticalScroller, forKey: KMMainModel.Key.kHasVerticalsCroller)
-        savedNormalSetup.setValue(scrollView?.autohidesScrollers, forKey: KMMainModel.Key.kAutoHidesScrollers)
-        
-        listView.backgroundColor = NSColor.clear
-        listView.setDisplay(.singlePage)
-        listView.autoScales = true
-        listView.displayBox = .cropBox
-        listView.displaysPageBreaks = false
-        scrollView?.autohidesScrollers = true
-        scrollView?.hasHorizontalScroller = false
-        scrollView?.hasVerticalScroller = false
-        
-        listView.setCurrentSelection(nil, animate: true)
-        
-    }
-    
-    func exitFullscreenMode() {
-        if self.interactionMode == .presentation {
-            self.exitPresentationMode()
-        }
-        
-        self.applyPDFSettings(self.savedNormalSetup)
-        self.savedNormalSetup.removeAllObjects()
-        
-        self.listView.layoutDocumentView()
-        self.listView.requiresDisplay()
-        
-        if let backgroundColor = UserDefaults.standard.color(forKey: KMBackgroundColorKey) {
-            self.listView.backgroundColor = backgroundColor
-         }
-    }
-    
-    func applyPDFSettings(_ setup: NSDictionary) {
-        if let data = setup.object(forKey: KMMainModel.Key.kAutoScales) as? NSNumber {
-            self.listView.autoScales = data.boolValue
-        }
-        if self.listView.autoScales == false {
-            if let data = setup.object(forKey: KMMainModel.Key.kScaleFactor) as? NSNumber {
-                self.listView.scaleFactor = data.floatValue.cgFloat
-            }
-        }
-        
-        if let data = setup.object(forKey: KMMainModel.Key.kDisplayMode) as? NSNumber {
-            self.listView.setDisplay(CPDFDisplayViewMode(rawValue: data.intValue) ?? .singlePage)
-        }
-        
-        if let data = setup.object(forKey: KMMainModel.Key.kDisplaysAsBook) as? NSNumber {
-            self.listView.displaysAsBook = data.boolValue
-        }
-        
-        if let data = setup.object(forKey: KMMainModel.Key.kDisplaysPageBreaks) as? NSNumber {
-            self.listView.displaysPageBreaks = data.boolValue
-        }
-        
-        if let data = setup.object(forKey: KMMainModel.Key.kDisplayBox) as? NSNumber {
-        }
-        
-        self.listView.layoutDocumentView()
-    }
-    
-    func exitPresentationMode() {
-        
-        self.selectDisplay(display: KMPDFDisplayType(rawValue: KMPDFDisplayType.RawValue(self.listView.fetchDisplayViewMode().rawValue)) ?? .singlePage, viewSettingIsReload: false)
-    }
-    
-    func currentPDFSettings() -> NSDictionary {
-        let setup = NSMutableDictionary()
-        setup[KMMainModel.Key.kDisplaysPageBreaks] = NSNumber(value: listView.displaysPageBreaks)
-        setup[KMMainModel.Key.kDisplaysAsBook] = NSNumber(value: listView.displaysAsBook)
-        setup[KMMainModel.Key.kDisplayBox] = NSNumber(value: listView.displayBox.rawValue)
-        setup[KMMainModel.Key.kScaleFactor] = NSNumber(value: listView.scaleFactor)
-        setup[KMMainModel.Key.kAutoScales] = NSNumber(value: listView.autoScales)
-        setup[KMMainModel.Key.kDisplayMode] = NSNumber(value: listView.fetchDisplayViewMode().rawValue)
-        
-        return setup
-    }
     
     //MARK: menuItem Action
     
@@ -4318,7 +4205,7 @@ extension KMMainViewController : KMToolbarViewControllerDelegate {
                 } else if itemID == KMDocumentPrintToolbarItemIdentifier {
                     self.showPrintWindow()
                 } else if itemID == KMDocumentPresentationToolbarItemIdentifier {
-                    self.enterPresentation()
+                    self.togglePresentation(nil)
                 } else if itemID == KMDocumentSignToolbarItemIdentifier {
                     let isSelected = toolbarItem.isSelected
                     self.toolbarController.toolbarType = isSelected ? .None : .sign
@@ -4974,39 +4861,7 @@ extension KMMainViewController: KMPageNumberDisplayViewDelegate {
     }
 }
 
-extension KMMainViewController: KMInteractionProviderProtocol {
-    func providerContentView(fullScreenWindow: NSWindow, inset: CGFloat) -> NSView? {
-        let view = self.listView
-        if(interactionMode == .presentation) {
-            if view.presentationDrawView == nil {
-                view.createPresentationDraw()
-            }
-            
-            presentationTopViewController = KMPresentationTopViewController.init(nibName: "KMPresentationTopViewController", bundle: nil)
-            presentationTopViewController?.pdfView = view
-            presentationTopViewController?.delegate = self
-            presentationTopViewController?.isSelectionPre = true
-            listView.isPresentationMode = true
-            presentationTopViewController?.view.frame = CGRect(x: 0, y: (fullScreenWindow.contentView?.bounds.height ?? 0) - 42, width: fullScreenWindow.contentView?.bounds.width ?? 0, height: 42)
-            if((presentationTopViewController) != nil) {
-                fullScreenWindow.contentView?.addSubview(presentationTopViewController!.view)
-            }
-        } else {
-            view.frame = NSInsetRect(fullScreenWindow.contentView?.bounds ?? .zero, 0, 0)
-        }
-        
-        fullScreenWindow.contentView?.addSubview(view)
-        if(interactionMode == .presentation) {
-            view.mas_makeConstraints { make in
-                make?.left.mas_equalTo()(0)
-                make?.right.mas_equalTo()(0)
-                make?.top.mas_equalTo()(presentationTopViewController!.view.frame.height)
-                make?.bottom.mas_equalTo()(0)
-            }
-        }
-        return view
-    }
-}
+
 
 // MARK: - Analytics (埋点)
 
@@ -5385,37 +5240,6 @@ extension KMMainViewController {
     }
     
     
-    @objc func didEnterInteractionModeNotification(_ sender: Notification) {
-        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
-            return
-        }
-        if self.interactionMode == .presentation {
-            
-            self.listView.layoutDocumentView()
-            self.listView.requiresDisplay()
-        }
-    }
-    
-    @objc func willShowFullScreenNotification(_ sender: Notification) {
-        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
-            return
-        }
-        if self.interactionMode == .presentation {
-            let view = self.view.window?.firstResponder as? NSView
-            if let data = view?.isDescendant(of: self.pdfSplitView), data {
-                self.view.window?.makeFirstResponder(nil)
-            }
-        }
-    }
-    
-    @objc func didShowFullScreenNotification(_ sender: Notification) {
-        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
-            return
-        }
-        if self.interactionMode == .presentation {
-            self.enterPresentationMode()
-        }
-    }
     
     @objc func didAddContentViewNotification(_ sender: Notification) {
         guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {

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

@@ -10,15 +10,6 @@ import Foundation
 extension KMMainViewController {
     // MARK: - 退出全屏
     
-    @IBAction func exitFullScreen(_ sender: Any) {
-        if (self.view.window == nil) {
-            return
-        }
-        
-        if (KMTools.isFullScreen(self.view.window!)) {
-            self.view.window?.toggleFullScreen(nil)
-        }
-    }
     
     @IBAction func startSpeaking(_ sender: Any) {
         self.showTTSWindow()

+ 5 - 1
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/KMHomeRightView.swift

@@ -186,7 +186,11 @@ public class KMHomeRightView: BaseXibView {
         groupView.groupDelegate = self
         groupView?.frame = CGRectMake(0, 0, 180, viewHeight)
         groupView.updateGroupInfo(menuItemArr)
-        groupView.showWithPoint(CGPoint(x: point.x + 40 + CGRectGetWidth(groupView.frame), y: point.y - viewHeight/2), relativeTo: self)
+        if HistoryFilesManager.manager.showMode == .Thumbnail {
+            groupView.showWithPoint(CGPoint(x: point.x + 60 + CGRectGetWidth(groupView.frame), y: point.y - viewHeight), relativeTo: self)
+        } else {
+            groupView.showWithPoint(CGPoint(x: point.x + 40 + CGRectGetWidth(groupView.frame), y: point.y - viewHeight/2), relativeTo: self)
+        }
         
         menuActionIndexPaths = collectionView.selectionIndexPaths
     }

+ 299 - 97
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -282,8 +282,6 @@ import Cocoa
         self.removeKeyEventMonitor()
     }
     
-    
-    
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do view setup here.
@@ -346,8 +344,6 @@ import Cocoa
         pdfSplitBottomView.addSubview(splitPDFController!.view)
     }
     
-    
-    
     //MARK: - 工具栏
     func initToolbar() {
         toolbarBox.borderWidth = 0
@@ -467,6 +463,7 @@ import Cocoa
         infoSplitViewLeftConst.constant = 0
         toolbarBoxHeightConst.constant = 0
         
+        view.window?.makeFirstResponder(listView)
         
     }
     
@@ -482,12 +479,167 @@ import Cocoa
     //MARK: - PPT
     func togglePresentation(_ sender: Any?) {
         if self.canExitPresentation() {
-            self.exitFullScreen("")
-        } else if self.canEnterPresentation(){
-            self.enterPresentation()
+            exitFullScreen()
+        } else if self.canEnterPresentation() {
+            NotificationCenter.default.addObserver(self, selector: #selector(willEnterInteractionModeNotification), name: NSWindow.willEnterInteractionModeNotification, object: nil)
+            NotificationCenter.default.addObserver(self, selector: #selector(didEnterInteractionModeNotification), name: NSWindow.didEnterInteractionModeNotification, object: nil)
+            NotificationCenter.default.addObserver(self, selector: #selector(willShowFullScreenNotification), name: NSWindow.willShowFullScreenNotification, object: nil)
+            NotificationCenter.default.addObserver(self, selector: #selector(didShowFullScreenNotification), name: NSWindow.didShowFullScreenNotification, object: nil)
+           
+            view.window?.enterPresentation(provider: self)
         }
     }
     
+    func enterPresentationMode() {
+        let scrollView = listView.documentView().enclosingScrollView
+        savedNormalSetup.setValue(scrollView?.hasHorizontalScroller, forKey: KMMainModel.Key.kHasHorizontalScroller)
+        savedNormalSetup.setValue(scrollView?.hasVerticalScroller, forKey: KMMainModel.Key.kHasVerticalsCroller)
+        savedNormalSetup.setValue(scrollView?.autohidesScrollers, forKey: KMMainModel.Key.kAutoHidesScrollers)
+        
+        listView.backgroundColor = NSColor.clear
+        listView.setDisplay(.singlePage)
+        listView.autoScales = true
+        listView.displayBox = .cropBox
+        listView.displaysPageBreaks = false
+        scrollView?.autohidesScrollers = true
+        scrollView?.hasHorizontalScroller = false
+        scrollView?.hasVerticalScroller = false
+        
+        listView.setCurrentSelection(nil, animate: true)
+    }
+    
+    func exitPresentationMode() {
+        self.selectDisplay(display: KMPDFDisplayType(rawValue: KMPDFDisplayType.RawValue(self.listView.fetchDisplayViewMode().rawValue)) ?? .singlePage, viewSettingIsReload: false)
+        
+        NotificationCenter.default.removeObserver(self, name: NSWindow.willEnterInteractionModeNotification, object: nil)
+        NotificationCenter.default.removeObserver(self, name: NSWindow.didEnterInteractionModeNotification, object: nil)
+        NotificationCenter.default.removeObserver(self, name: NSWindow.willShowFullScreenNotification, object: nil)
+        NotificationCenter.default.removeObserver(self, name: NSWindow.willShowFullScreenNotification, object: nil)
+         
+    }
+    
+    func exitFullScreen() {
+        if self.canExitPresentation() == true {
+            let mainDocument = self.myDocument as? KMMainDocument
+            let browserWindowController = mainDocument?.browser?.windowController as? KMBrowserWindowController
+            browserWindowController?.exitFullscreen()
+            
+        }
+    }
+    
+    func exitFullscreenMode() {
+        if self.interactionMode == .presentation {
+            self.exitPresentationMode()
+        }
+        
+        self.applyPDFSettings(self.savedNormalSetup)
+        self.savedNormalSetup.removeAllObjects()
+        
+        listView.layoutDocumentView()
+        listView.requiresDisplay()
+        
+        if let backgroundColor = UserDefaults.standard.color(forKey: KMBackgroundColorKey) {
+            listView.backgroundColor = backgroundColor
+        }
+    }
+    
+    func applyPDFSettings(_ setup: NSDictionary) {
+        if let data = setup.object(forKey: KMMainModel.Key.kAutoScales) as? NSNumber {
+            self.listView.autoScales = data.boolValue
+        }
+        if self.listView.autoScales == false {
+            if let data = setup.object(forKey: KMMainModel.Key.kScaleFactor) as? NSNumber {
+                self.listView.scaleFactor = data.floatValue.cgFloat
+            }
+        }
+        
+        if let data = setup.object(forKey: KMMainModel.Key.kDisplayMode) as? NSNumber {
+            self.listView.setDisplay(CPDFDisplayViewMode(rawValue: data.intValue) ?? .singlePage)
+        }
+        
+        if let data = setup.object(forKey: KMMainModel.Key.kDisplaysAsBook) as? NSNumber {
+            self.listView.displaysAsBook = data.boolValue
+        }
+        
+        if let data = setup.object(forKey: KMMainModel.Key.kDisplaysPageBreaks) as? NSNumber {
+            self.listView.displaysPageBreaks = data.boolValue
+        }
+        
+        if let data = setup.object(forKey: KMMainModel.Key.kDisplayBox) as? NSNumber {
+            
+        }
+        
+        self.listView.layoutDocumentView()
+    }
+    
+    func currentPDFSettings() -> NSDictionary {
+        let setup = NSMutableDictionary()
+        setup[KMMainModel.Key.kDisplaysPageBreaks] = NSNumber(value: listView.displaysPageBreaks)
+        setup[KMMainModel.Key.kDisplaysAsBook] = NSNumber(value: listView.displaysAsBook)
+        setup[KMMainModel.Key.kDisplayBox] = NSNumber(value: listView.displayBox.rawValue)
+        setup[KMMainModel.Key.kScaleFactor] = NSNumber(value: listView.scaleFactor)
+        setup[KMMainModel.Key.kAutoScales] = NSNumber(value: listView.autoScales)
+        setup[KMMainModel.Key.kDisplayMode] = NSNumber(value: listView.fetchDisplayViewMode().rawValue)
+        
+        return setup
+    }
+    
+    func canEnterFullscreen() -> Bool {
+        if (mwcFlags.isSwitchingFullScreen != 0) {
+            return false
+        }
+        if useNativeFullScreen() {
+            return interactionMode == .normal || interactionMode == .presentation
+        } else {
+            return !self.listView.document.isLocked && (interactionMode == .normal || interactionMode == .presentation) && self.view.window?.tabbedWindows?.count ?? 0 < 2
+        }
+    }
+    
+    override func canEnterPresentation() -> Bool {
+        let can = super.canEnterPresentation()
+        if can == false {
+            return false
+        }
+        guard let doc = self.listView.document, doc.isLocked == false else {
+            return false
+        }
+        return can
+    }
+    
+    func fadeOutFullScreenWindow() {
+        guard let fullScreenWindow = self.view.window as? KMFullScreenWindow else {
+            NSSound.beep()
+            return
+        }
+        
+        let mainWindow = fullScreenWindow.interactionParent
+        let collectionBehavior = mainWindow?.collectionBehavior
+        
+        mainWindow?.alphaValue = 0
+        if let data = mainWindow?.responds(to: NSSelectorFromString("setAnimationBehavior:")), data {
+            mainWindow?.animationBehavior = .none
+        }
+        // trick to make sure the main window shows up in the same space as the fullscreen window
+        fullScreenWindow.addChildWindow(mainWindow!, ordered: .below)
+        fullScreenWindow.removeChildWindow(mainWindow!)
+        fullScreenWindow.level = .popUpMenu
+        // these can change due to the child window trick
+        mainWindow?.level = .normal
+        mainWindow?.alphaValue = 1.0
+        mainWindow?.collectionBehavior = collectionBehavior!
+        mainWindow?.display()
+        mainWindow?.makeFirstResponder(self.listView)
+        mainWindow?.recalculateKeyViewLoop()
+//        mainWindow?.delegate = self
+        mainWindow?.makeKey()
+        
+        if let data = mainWindow?.responds(to: NSSelectorFromString("setAnimationBehavior:")), data {
+            mainWindow?.animationBehavior = .default
+        }
+        NSApp.removeWindowsItem(fullScreenWindow)
+        fullScreenWindow.fadeOut()
+    }
+    
     //MARK: - PDF分屏视图
     func reloadPDFSplitInfo() {
         if listView.viewSplitMode == .disable {
@@ -770,7 +922,7 @@ extension KMMainViewController: KMNDisplayViewControllerDelegate {
     
     //PPT
     func displayViewControllerDidGotoSlideShow(_ controller: KMNDisplayViewController) {
-        
+        togglePresentation(nil)
     }
     
     //SplitView
@@ -791,6 +943,140 @@ extension KMMainViewController: KMNDisplayViewControllerDelegate {
     }
 }
 
+//MARK: - PPT
+extension KMMainViewController: KMInteractionProviderProtocol {
+    func providerContentView(fullScreenWindow: NSWindow, inset: CGFloat) -> NSView? {
+         if(interactionMode == .presentation) {
+            if listView.presentationDrawView == nil {
+                listView.createPresentationDraw()
+            }
+            
+            presentationTopViewController = KMPresentationTopViewController.init(nibName: "KMPresentationTopViewController", bundle: nil)
+            presentationTopViewController?.pdfView = listView
+            presentationTopViewController?.delegate = self
+            presentationTopViewController?.isSelectionPre = true
+            listView.isPresentationMode = true
+            presentationTopViewController?.view.frame = CGRect(x: 0, y: (fullScreenWindow.contentView?.bounds.height ?? 0) - 42, width: fullScreenWindow.contentView?.bounds.width ?? 0, height: 42)
+            if((presentationTopViewController) != nil) {
+                fullScreenWindow.contentView?.addSubview(presentationTopViewController!.view)
+            }
+        } else {
+            listView.frame = NSInsetRect(fullScreenWindow.contentView?.bounds ?? .zero, 0, 0)
+        }
+        
+        fullScreenWindow.contentView?.addSubview(listView)
+        if(interactionMode == .presentation) {
+            let frame = fullScreenWindow.frame
+            listView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height-42)
+            listView.autoresizingMask = [.width, .maxYMargin]
+        }
+        return view
+    }
+     
+    @objc func willEnterInteractionModeNotification(_ sender: Notification) {
+        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
+            return
+        }
+        let interactionMode = sender.userInfo?[NSWindow.UserInfo.interactionModeKey] as? KMInteractionMode
+        if interactionMode == .presentation {
+            let backgroundColor = NSColor.black
+            let level = UserDefaults.standard.bool(forKey: "SKUseNormalLevelForPresentationKey") ? NSWindow.Level.normal : NSWindow.Level.popUpMenu
+            
+            let wasInteractionMode = self.interactionMode
+            if wasInteractionMode == .normal {
+                self.savedNormalSetup.setDictionary(self.currentPDFSettings() as! [AnyHashable : Any])
+            }
+            
+            if wasInteractionMode == .legacyFullScreen {
+                self.enterPresentationMode()
+                
+                self.pdfSplitView.frame = CGRect(x: 0, y: 0, width: NSWidth(centerContentView.bounds), height: NSHeight(centerContentView.bounds)-1)
+                self.centerContentView.addSubview(pdfSplitView)
+                self.listView.frame = (self.view.window?.contentView?.bounds)!
+                self.view.window?.contentView?.addSubview(listView)
+                
+//                self.view.window?.backgroundColor = backgroundColor
+                self.view.window?.level = level
+                self.listView.layoutDocumentView()
+                self.listView.requiresDisplay()
+                
+                self.forceSubwindowsOnTop(false)
+                 
+            }
+        } else {
+            KMPrint("2")
+        }
+    }
+     
+    @objc func didEnterInteractionModeNotification(_ sender: Notification) {
+        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
+            return
+        }
+        if self.interactionMode == .presentation {
+            
+            self.listView.layoutDocumentView()
+            self.listView.requiresDisplay()
+        }
+    }
+    
+    @objc func willShowFullScreenNotification(_ sender: Notification) {
+        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
+            return
+        }
+        if self.interactionMode == .presentation {
+            let view = self.view.window?.firstResponder as? NSView
+            if let data = view?.isDescendant(of: self.pdfSplitView), data {
+                self.view.window?.makeFirstResponder(nil)
+            }
+        }
+    }
+    
+    @objc func didShowFullScreenNotification(_ sender: Notification) {
+        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
+            return
+        }
+        if self.interactionMode == .presentation {
+            self.enterPresentationMode()
+        }
+    }
+}
+
+// MARK: -KMPresentationTopViewControllerDelegate (幻灯片)
+extension KMMainViewController: KMPresentationTopViewControllerDelegate {
+    func presentationTopViewExit(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton) {
+        self.exitFullScreen()
+    }
+    
+    func presentationTopViewClear(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton) {
+        listView.presentationDrawView?.clear()
+    }
+    
+    func presentationTopViewUndo(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton) {
+        let presentationDrawView = listView.presentationDrawView
+        if presentationDrawView?.canUndo() == true {
+            presentationDrawView?.undo()
+        }
+    }
+    
+    func presentationTopViewType(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton, isSeletion: Bool) {
+        listView.isPresentationMode = isSeletion
+        if listView.isEnterPresentationDrawMode() == true {
+            listView.exitPresentationDrawMode()
+        }
+    }
+    
+    func presentationTopViewDrawColor(_ presentationTopViewController: KMPresentationTopViewController, withView: NSView,color:NSColor?) {
+        if color == nil{
+            listView.exitPresentationDrawMode()
+        } else {
+            if listView.isEnterPresentationDrawMode() == false {
+                listView.enterPresentationDrawMode()
+            }
+            listView.changePresentationDrawModelColor(color)
+        }
+    }
+}
+
 //MARK: - KMSplitPDFViewControllerDelegate SplitPDFView分屏视图
 extension KMMainViewController: KMSplitPDFViewControllerDelegate {
     func splitPDFViewControllerDidUpdateFilePath(_ controller: KMSplitPDFViewController) {
@@ -1050,7 +1336,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         
         if theEvent.keyCode == 53 {
             //ESC
-            self.exitFullScreen(Any.self)
+            self.exitFullScreen()
             
             if viewManager.isPDFReadMode {
                 self.exitPDFReadMode()
@@ -1768,46 +2054,6 @@ extension KMMainViewController: KMNThumbnailBaseViewDelegate {
 }
 
 
-// MARK: - KMPresentationTopViewControllerDelegate (幻灯片)
-extension KMMainViewController: KMPresentationTopViewControllerDelegate {
-    func presentationTopViewExit(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton) {
-        if  self.canExitPresentation() == true {
-            let mainDocument = self.myDocument as? KMMainDocument
-            let browserWindowController = mainDocument?.browser?.windowController as? KMBrowserWindowController
-            browserWindowController?.exitFullscreen()
-            
-        }
-    }
-    
-    func presentationTopViewClear(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton) {
-        listView.presentationDrawView?.clear()
-    }
-    
-    func presentationTopViewUndo(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton) {
-        let presentationDrawView = listView.presentationDrawView
-        if presentationDrawView?.canUndo() == true {
-            presentationDrawView?.undo()
-        }
-    }
-    
-    func presentationTopViewType(_ presentationTopViewController: KMPresentationTopViewController, withButton: NSButton, isSeletion: Bool) {
-        listView.isPresentationMode = isSeletion
-        if listView.isEnterPresentationDrawMode() == true {
-            listView.exitPresentationDrawMode()
-        }
-    }
-    
-    func presentationTopViewDrawColor(_ presentationTopViewController: KMPresentationTopViewController, withView: NSView,color:NSColor?) {
-        if color == nil{
-            listView.exitPresentationDrawMode()
-        } else {
-            if listView.isEnterPresentationDrawMode() == false {
-                listView.enterPresentationDrawMode()
-            }
-            listView.changePresentationDrawModelColor(color)
-        }
-    }
-}
 
 
 //MARK: -
@@ -1998,11 +2244,8 @@ extension KMMainViewController {
         
         NotificationCenter.default.addObserver(self, selector: #selector(handlePageChangedNotification), name: NSNotification.Name.CPDFViewPageChanged, object: self.listView)
         NotificationCenter.default.addObserver(self, selector: #selector(handleDisplayBoxChangedNotification), name: NSNotification.Name.CPDFViewDisplayBoxChanged, object: self.listView)
-        // 互动模式
-        NotificationCenter.default.addObserver(self, selector: #selector(willEnterInteractionModeNotification), name: NSWindow.willEnterInteractionModeNotification, object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(didEnterInteractionModeNotification), name: NSWindow.didEnterInteractionModeNotification, object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(willShowFullScreenNotification), name: NSWindow.willShowFullScreenNotification, object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(didShowFullScreenNotification), name: NSWindow.didShowFullScreenNotification, object: nil)
+       
+        
         NotificationCenter.default.addObserver(self, selector: #selector(didAddContentViewNotification), name: NSWindow.didAddContentViewNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(addAutoSaveEvent), name: AutoSaveManager.kTimeValueChangedNotificationName, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(didRemoveAnnotationNotification), name: NSNotification.Name.CPDFPageDidRemoveAnnotation, object: nil)
@@ -3429,11 +3672,7 @@ extension KMMainViewController {
         keyEventMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in
             if event.keyCode == 53 {
                 if let data = self?.interactionMode, data == .presentation { // 幻灯片模式下
-                    if let data = self?.canExitPresentation(), data {
-                        let mainDocument = self?.myDocument as? KMMainDocument
-                        let browserWindowController = mainDocument?.browser?.windowController as? KMBrowserWindowController
-                        browserWindowController?.exitFullscreen()
-                    }
+                    self?.exitFullScreen()
                     return nil
                 }
                 if self?.listView.toolMode == .editPDFToolMode {
@@ -3569,7 +3808,7 @@ extension KMMainViewController {
             NSSpellChecker.shared.closeSpellDocument(withTag: self.listView.spellingTag())
         }
         self.removeAutoSaveInfo()
-        KMAdsManager.defaultManager.dismissSheetModal(for: self.readContentView)
+
         self.myDocument = nil
         
     }
@@ -3763,43 +4002,6 @@ extension KMMainViewController {
         self.leftSideViewController.reloadThumbnailDataIfNeed()
     }
     
-    @objc func willEnterInteractionModeNotification(_ sender: Notification) {
-        guard let win = sender.object as? NSWindow, win.isEqual(to: self.view.window) else {
-            return
-        }
-        let interactionMode = sender.userInfo?[NSWindow.UserInfo.interactionModeKey] as? KMInteractionMode
-        if interactionMode == .presentation {
-            let backgroundColor = NSColor.black
-            let level = UserDefaults.standard.bool(forKey: "SKUseNormalLevelForPresentationKey") ? NSWindow.Level.normal : NSWindow.Level.popUpMenu
-            
-            let wasInteractionMode = self.interactionMode
-            if wasInteractionMode == .normal {
-                self.savedNormalSetup.setDictionary(self.currentPDFSettings() as! [AnyHashable : Any])
-            }
-            
-            if wasInteractionMode == .legacyFullScreen {
-                self.enterPresentationMode()
-                
-                self.pdfSplitView.frame = CGRect(x: 0, y: 0, width: NSWidth(centerContentView.bounds), height: NSHeight(centerContentView.bounds)-1)
-                self.centerContentView.addSubview(pdfSplitView)
-                self.listView.frame = (self.view.window?.contentView?.bounds)!
-                self.view.window?.contentView?.addSubview(listView)
-                
-                self.view.window?.backgroundColor = backgroundColor
-                self.view.window?.level = level
-                self.listView.layoutDocumentView()
-                self.listView.requiresDisplay()
-                
-                self.forceSubwindowsOnTop(false)
-                
-                self.hideLeftSideWindow()
-                self.hideRightSideWindow()
-                self.removeBlankingWindows()
-            }
-        } else {
-            KMPrint("2")
-        }
-    }
     
     
 }

+ 58 - 162
PDF Office/PDF Master/Class/Common/Category/NSWindowController+KMExtension.swift

@@ -1,71 +1,77 @@
 //
-//  NSWindowController+KMExtension.swift
+//  NSWindow+KMExtension.swift
 //  PDF Reader Pro
 //
-//  Created by tangchao on 2023/7/27.
+//  Created by tangchao on 2023/10/30.
 //
 
 import Foundation
 
-@objc protocol KMForceProtocol: NSObjectProtocol {
-    @objc optional func setForceOnTop(_ flag: Bool)
-}
-
-extension NSWindowController {
-    override func km_window() -> NSWindow? {
-        return self.window
+private var _KMWindowPopOverKey = "KMWindowPopOverKey"
+private var _KMWindowPopOverSourcesRectKey = "KMWindowPopOverSourcesRectKey"
+extension NSWindow {
+    var popover: NSPopover? {
+        get {
+            return objc_getAssociatedObject(self, &_KMWindowPopOverKey) as? NSPopover
+        }
+        set {
+            objc_setAssociatedObject(self, &_KMWindowPopOverKey, newValue, .OBJC_ASSOCIATION_RETAIN)
+        }
     }
     
-    func forceSubwindowsOnTop(_ flag: Bool) {
-        guard let doc = self.document as? NSDocument else {
-            NSSound.beep()
-            return
-        }
-        for wc in doc.windowControllers {
-            if wc.responds(to: #selector(setForceOnTop)) {
-                wc.setForceOnTop(flag)
+    var sourcesRect: NSRect {
+        get {
+            if let data = objc_getAssociatedObject(self, &_KMWindowPopOverSourcesRectKey) as? NSValue {
+                return data.rectValue
             }
+            return NSZeroRect
+        }
+        set {
+            objc_setAssociatedObject(self, &_KMWindowPopOverSourcesRectKey, NSValue(rect: newValue), .OBJC_ASSOCIATION_RETAIN)
         }
     }
-}
-
-extension NSWindowController: KMForceProtocol {
-    func setForceOnTop(_ flag: Bool) {
-        // no things.
+    
+    open override func mouseMoved(with event: NSEvent) {
+        super.mouseMoved(with: event)
+        
+        let point = event.locationInWindow
+        var need = true
+        if let data = event.window?.isKind(of: NSClassFromString("_NSPopoverWindow")!) {
+//            need = !data
+            if data {
+                need = false
+            } else {
+                need = true
+            }
+        } else {
+            need = true
+        }
+        if (need) {
+            if (self.sourcesRect.contains(point) == false) {
+                if self.popover != nil {
+                    NotificationCenter.default.post(name: Notification.Name("KMPopOverClosedByWindowNotification"), object: self.popover!)
+                    self.popover?.close()
+                    self.popover = nil
+                    self.sourcesRect = NSRect.null
+                }
+            }
+        }
     }
 }
 
 extension NSWindow {
-    override func km_window() -> NSWindow? {
-        return self
+    static func currentWindow() -> NSWindow {
+        var window = NSApp.mainWindow
+        if NSApp.mainWindow?.sheets.first != nil {
+            window = NSApp.mainWindow?.sheets.first
+        }
+        if window == nil {
+            window = NSApplication.shared.windows.first
+        }
+        return window ?? NSWindow()
     }
 }
 
-// MARK: - 互动模式
-
-@objc enum KMInteractionMode: Int {
-    case normal = 0 // 常规模式
-    case fullScreen
-    case presentation // 幻灯片模式
-    case legacyFullScreen
-}
-
-@objc protocol KMInteractionModeProtocol: NSObjectProtocol {
-    @objc optional var interactionMode: KMInteractionMode { get }
-    @objc optional var isSwitchingFullScreen: Bool { get }
-//    @objc optional var wantsPresentation: Bool { get }
-    
-    @objc optional func canEnterPresentation() -> Bool
-    @objc optional func canExitPresentation() -> Bool
-    
-    @objc optional func enterPresentation()
-    @objc optional func exitPresentation()
-}
-
-@objc protocol KMInteractionProviderProtocol: NSObjectProtocol {
-    @objc optional func providerContentView(fullScreenWindow: NSWindow, inset: CGFloat) -> NSView?
-}
-
 @objc extension NSWindow {
     public static let willEnterInteractionModeNotification: NSNotification.Name = .init("KMWillEnterInteractionModeNotificationName")
     public static let didEnterInteractionModeNotification: NSNotification.Name = .init("KMDidEnterInteractionModeNotificationName")
@@ -207,11 +213,11 @@ extension NSWindow {
         NotificationCenter.default.post(name: Self.didEnterInteractionModeNotification, object: self, userInfo: ["fullScreenWindow" : ""])
     }
     
-    func exitFullscreen() { 
+    func exitFullscreen() {
+        
     }
     
     // MARK: - fadeIn & fadeOut [淡入、淡出]
-    
     func fadeInFullScreenWindow(with backgroundColor: NSColor, level: Int) -> KMFullScreenWindow {
         let fullScreenWindow = KMFullScreenWindow(screen: (self.screen ?? NSScreen.main)!, bgColor: backgroundColor, level: NSWindow.Level.popUpMenu.rawValue, isMain: true)
         fullScreenWindow.interactionParent = self
@@ -220,9 +226,7 @@ extension NSWindow {
         fullScreenWindow.fadeInBlocking()
         self.windowController?.window = fullScreenWindow
         fullScreenWindow.makeKey()
-        
-//        NSApp.updatePresentationOptions(for: fullScreenWindow)
-        
+                
         let sel = NSSelectorFromString("setAnimationBehavior:")
         if self.responds(to: sel){
             self.animationBehavior = .none
@@ -233,7 +237,6 @@ extension NSWindow {
         }
         fullScreenWindow.level = NSWindow.Level(rawValue: level)
         fullScreenWindow.orderFront(nil)
-//        NSApp.addWindowsItem(fullScreenWindow, title: windowTitleForDocumentDisplayName(self.document?.displayName) ?? "", filename: false)
         
         return fullScreenWindow
     }
@@ -242,9 +245,7 @@ extension NSWindow {
         let fadeWindow = KMFullScreenWindow(screen: fullScreenWindow.screen!, bgColor: fullScreenWindow.backgroundColor, level: fullScreenWindow.level.rawValue, isMain: false)
 
         fadeWindow.order(.above, relativeTo: fullScreenWindow.windowNumber)
-//        view?.frame = NSInsetRect(fullScreenWindow.contentView?.bounds ?? .zero, inset, 0)
         if let _ = view {
-//            fullScreenWindow.contentView?.addSubview(v)
             NotificationCenter.default.post(name: Self.didAddContentViewNotification, object: self)
         }
         fullScreenWindow.makeFirstResponder(view)
@@ -254,108 +255,3 @@ extension NSWindow {
         fadeWindow.fadeOut()
     }
 }
-
-extension NSWindowController: KMInteractionModeProtocol {
-    var interactionMode: KMInteractionMode {
-        get {
-            if let win = self.window?.interactionParent {
-                return win.interactionMode
-            }
-            return self.window?.interactionMode ?? .normal
-        }
-//        set {
-//            self.window?.interactionMode = newValue
-//        }
-    }
-    
-    var isSwitchingFullScreen: Bool {
-        get {
-            if let win = self.window?.interactionParent {
-                return win.isSwitchingFullScreen
-            }
-            return self.window?.isSwitchingFullScreen ?? false
-        }
-    }
-    
-    func canEnterPresentation() -> Bool {
-        if let win = self.window?.interactionParent {
-            return win.canEnterPresentation()
-        }
-        return self.window?.canEnterPresentation() ?? false
-    }
-    
-    func canExitPresentation() -> Bool {
-        if let win = self.window?.interactionParent {
-            return win.canExitPresentation()
-        }
-        return self.window?.canExitPresentation() ?? false
-    }
-}
-
-@objc extension NSView: KMInteractionModeProtocol {
-    var interactionMode: KMInteractionMode {
-        get {
-            if let win = self.window?.interactionParent {
-                return win.interactionMode
-            }
-            return self.window?.interactionMode ?? .normal
-        }
-    }
-    
-    var isSwitchingFullScreen: Bool {
-        get {
-            if let win = self.window?.interactionParent {
-                return win.isSwitchingFullScreen
-            }
-            return self.window?.isSwitchingFullScreen ?? false
-        }
-    }
-    
-    func canEnterPresentation() -> Bool {
-        if let win = self.window?.interactionParent {
-            return win.canEnterPresentation()
-        }
-        return self.window?.canEnterPresentation() ?? false
-    }
-    
-    func canExitPresentation() -> Bool {
-        if let win = self.window?.interactionParent {
-            return win.canExitPresentation()
-        }
-        return self.window?.canExitPresentation() ?? false
-    }
-}
-
-@objc extension NSViewController: KMInteractionModeProtocol {
-    var interactionMode: KMInteractionMode {
-        get {
-            if let win = self.view.window?.interactionParent {
-                return win.interactionMode
-            }
-            return self.view.window?.interactionMode ?? .normal
-        }
-    }
-    
-    var isSwitchingFullScreen: Bool {
-        get {
-            if let win = self.view.window?.interactionParent {
-                return win.isSwitchingFullScreen
-            }
-            return self.view.window?.isSwitchingFullScreen ?? false
-        }
-    }
-    
-    func canEnterPresentation() -> Bool {
-        if let win = self.view.window?.interactionParent {
-            return win.canEnterPresentation()
-        }
-        return self.view.window?.canEnterPresentation() ?? false
-    }
-    
-    func canExitPresentation() -> Bool {
-        if let win = self.view.window?.interactionParent {
-            return win.canExitPresentation()
-        }
-        return self.view.window?.canExitPresentation() ?? false
-    }
-}

+ 32 - 0
PDF Office/PDF Master/KMClass/Tools/NSWindowController+Extension/NSWindowController+Extension.swift

@@ -18,3 +18,35 @@ extension NSWindowController {
     }
     
 }
+
+// MARK: - Sheet
+
+extension NSWindowController {
+    static var _sheetParentResponderKey = "KMSheetParentResponderKey"
+    unowned var sheetParentResponder: NSResponder? {
+        get {
+            return objc_getAssociatedObject(self, &Self._sheetParentResponderKey) as? NSResponder
+        }
+    }
+    
+    static var _sheetFlagKey = "KMSheetFlagKey"
+    var sheetFlag: Bool {
+        get {
+            return objc_getAssociatedObject(self, &Self._sheetFlagKey) as? Bool ?? false
+        }
+        set {
+            objc_setAssociatedObject(self, &Self._sheetFlagKey, newValue, .OBJC_ASSOCIATION_ASSIGN)
+        }
+    }
+    
+    // MARK: - Private Methods
+    func _setSheetParentResponder(_ newValue: NSResponder?) {
+        objc_setAssociatedObject(self, &Self._sheetParentResponderKey, newValue, .OBJC_ASSOCIATION_ASSIGN)
+    }
+}
+
+extension NSWindowController {
+    func handleRightMouseDown(theEvent: NSEvent) -> Bool {
+        return false
+    }
+}

+ 163 - 0
PDF Office/PDF Master/KMClass/Tools/NSWindowController+Extension/NSWindowController+KMExtension.swift

@@ -0,0 +1,163 @@
+//
+//  NSWindowController+KMExtension.swift
+//  PDF Reader Pro
+//
+//  Created by tangchao on 2023/7/27.
+//
+
+import Foundation
+
+@objc protocol KMForceProtocol: NSObjectProtocol {
+    @objc optional func setForceOnTop(_ flag: Bool)
+}
+
+extension NSWindowController {
+    override func km_window() -> NSWindow? {
+        return self.window
+    }
+    
+    func forceSubwindowsOnTop(_ flag: Bool) {
+        guard let doc = self.document as? NSDocument else {
+            NSSound.beep()
+            return
+        }
+        for wc in doc.windowControllers {
+            if wc.responds(to: #selector(setForceOnTop)) {
+                wc.setForceOnTop(flag)
+            }
+        }
+    }
+}
+
+extension NSWindowController: KMForceProtocol {
+    func setForceOnTop(_ flag: Bool) {
+        // no things.
+    }
+}
+
+// MARK: - 互动模式
+@objc enum KMInteractionMode: Int {
+    case normal = 0 // 常规模式
+    case fullScreen
+    case presentation // 幻灯片模式
+    case legacyFullScreen
+}
+
+@objc protocol KMInteractionModeProtocol: NSObjectProtocol {
+    @objc optional var interactionMode: KMInteractionMode { get }
+    @objc optional var isSwitchingFullScreen: Bool { get }
+    
+    @objc optional func canEnterPresentation() -> Bool
+    @objc optional func canExitPresentation() -> Bool
+    
+    @objc optional func enterPresentation()
+    @objc optional func exitPresentation()
+}
+
+@objc protocol KMInteractionProviderProtocol: NSObjectProtocol {
+    @objc optional func providerContentView(fullScreenWindow: NSWindow, inset: CGFloat) -> NSView?
+}
+
+
+
+extension NSWindowController: KMInteractionModeProtocol {
+    var interactionMode: KMInteractionMode {
+        get {
+            if let win = self.window?.interactionParent {
+                return win.interactionMode
+            }
+            return self.window?.interactionMode ?? .normal
+        }
+    }
+    
+    var isSwitchingFullScreen: Bool {
+        get {
+            if let win = self.window?.interactionParent {
+                return win.isSwitchingFullScreen
+            }
+            return self.window?.isSwitchingFullScreen ?? false
+        }
+    }
+    
+    func canEnterPresentation() -> Bool {
+        if let win = self.window?.interactionParent {
+            return win.canEnterPresentation()
+        }
+        return self.window?.canEnterPresentation() ?? false
+    }
+    
+    func canExitPresentation() -> Bool {
+        if let win = self.window?.interactionParent {
+            return win.canExitPresentation()
+        }
+        return self.window?.canExitPresentation() ?? false
+    }
+}
+
+@objc extension NSView: KMInteractionModeProtocol {
+    var interactionMode: KMInteractionMode {
+        get {
+            if let win = self.window?.interactionParent {
+                return win.interactionMode
+            }
+            return self.window?.interactionMode ?? .normal
+        }
+    }
+    
+    var isSwitchingFullScreen: Bool {
+        get {
+            if let win = self.window?.interactionParent {
+                return win.isSwitchingFullScreen
+            }
+            return self.window?.isSwitchingFullScreen ?? false
+        }
+    }
+    
+    func canEnterPresentation() -> Bool {
+        if let win = self.window?.interactionParent {
+            return win.canEnterPresentation()
+        }
+        return self.window?.canEnterPresentation() ?? false
+    }
+    
+    func canExitPresentation() -> Bool {
+        if let win = self.window?.interactionParent {
+            return win.canExitPresentation()
+        }
+        return self.window?.canExitPresentation() ?? false
+    }
+}
+
+@objc extension NSViewController: KMInteractionModeProtocol {
+    var interactionMode: KMInteractionMode {
+        get {
+            if let win = self.view.window?.interactionParent {
+                return win.interactionMode
+            }
+            return self.view.window?.interactionMode ?? .normal
+        }
+    }
+    
+    var isSwitchingFullScreen: Bool {
+        get {
+            if let win = self.view.window?.interactionParent {
+                return win.isSwitchingFullScreen
+            }
+            return self.view.window?.isSwitchingFullScreen ?? false
+        }
+    }
+    
+    func canEnterPresentation() -> Bool {
+        if let win = self.view.window?.interactionParent {
+            return win.canEnterPresentation()
+        }
+        return self.view.window?.canEnterPresentation() ?? false
+    }
+    
+    func canExitPresentation() -> Bool {
+        if let win = self.view.window?.interactionParent {
+            return win.canExitPresentation()
+        }
+        return self.view.window?.canExitPresentation() ?? false
+    }
+}

+ 18 - 18
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -3288,9 +3288,6 @@
 		BB1BFF812AEA139F003EB179 /* KMLongerButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF802AEA139F003EB179 /* KMLongerButton.swift */; };
 		BB1BFF822AEA139F003EB179 /* KMLongerButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF802AEA139F003EB179 /* KMLongerButton.swift */; };
 		BB1BFF832AEA139F003EB179 /* KMLongerButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF802AEA139F003EB179 /* KMLongerButton.swift */; };
-		BB1BFF862AEA30B1003EB179 /* NSWindow+PopOver.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF852AEA30B1003EB179 /* NSWindow+PopOver.swift */; };
-		BB1BFF872AEA30B1003EB179 /* NSWindow+PopOver.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF852AEA30B1003EB179 /* NSWindow+PopOver.swift */; };
-		BB1BFF882AEA30B1003EB179 /* NSWindow+PopOver.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF852AEA30B1003EB179 /* NSWindow+PopOver.swift */; };
 		BB1BFF8A2AEA4725003EB179 /* KMTableHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF892AEA4725003EB179 /* KMTableHeaderCell.swift */; };
 		BB1BFF8B2AEA4725003EB179 /* KMTableHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF892AEA4725003EB179 /* KMTableHeaderCell.swift */; };
 		BB1BFF8C2AEA4725003EB179 /* KMTableHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1BFF892AEA4725003EB179 /* KMTableHeaderCell.swift */; };
@@ -5361,9 +5358,9 @@
 		BBEDC22B2B98407000970C54 /* CPDFAction+KMExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEDC22A2B98407000970C54 /* CPDFAction+KMExtension.swift */; };
 		BBEDC22C2B98407000970C54 /* CPDFAction+KMExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEDC22A2B98407000970C54 /* CPDFAction+KMExtension.swift */; };
 		BBEDC22D2B98407000970C54 /* CPDFAction+KMExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEDC22A2B98407000970C54 /* CPDFAction+KMExtension.swift */; };
-		BBEF0F9A2B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift */; };
-		BBEF0F9B2B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift */; };
-		BBEF0F9C2B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift */; };
+		BBEF0F9A2B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift */; };
+		BBEF0F9B2B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift */; };
+		BBEF0F9C2B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift */; };
 		BBEFD0182AF9BD24003FABD8 /* KMDataVersionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEFD0172AF9BD24003FABD8 /* KMDataVersionManager.swift */; };
 		BBEFD0192AF9BD24003FABD8 /* KMDataVersionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEFD0172AF9BD24003FABD8 /* KMDataVersionManager.swift */; };
 		BBEFD01A2AF9BD24003FABD8 /* KMDataVersionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEFD0172AF9BD24003FABD8 /* KMDataVersionManager.swift */; };
@@ -7210,7 +7207,6 @@
 		BB1BFF782AEA0B8E003EB179 /* KMBatchOperateRightViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchOperateRightViewController.swift; sourceTree = "<group>"; };
 		BB1BFF7C2AEA0BE8003EB179 /* KMBatchOperateRightViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMBatchOperateRightViewController.xib; sourceTree = "<group>"; };
 		BB1BFF802AEA139F003EB179 /* KMLongerButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMLongerButton.swift; sourceTree = "<group>"; };
-		BB1BFF852AEA30B1003EB179 /* NSWindow+PopOver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSWindow+PopOver.swift"; sourceTree = "<group>"; };
 		BB1BFF892AEA4725003EB179 /* KMTableHeaderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMTableHeaderCell.swift; sourceTree = "<group>"; };
 		BB1BFF8D2AEA547B003EB179 /* NSButton+CustomAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSButton+CustomAppearance.swift"; sourceTree = "<group>"; };
 		BB1BFF912AEA6352003EB179 /* KMImageToPDFMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMImageToPDFMethod.swift; sourceTree = "<group>"; };
@@ -8037,7 +8033,7 @@
 		BBED0C2B2BBD569300511FAE /* KMAnnotationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMAnnotationModel.swift; sourceTree = "<group>"; };
 		BBEDC2262B98205200970C54 /* Bundle+KMExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+KMExtension.swift"; sourceTree = "<group>"; };
 		BBEDC22A2B98407000970C54 /* CPDFAction+KMExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFAction+KMExtension.swift"; sourceTree = "<group>"; };
-		BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KMBrowserWindowController+Actions.swift"; sourceTree = "<group>"; };
+		BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KMBrowserWindowController+PPTMode.swift"; sourceTree = "<group>"; };
 		BBEFD0172AF9BD24003FABD8 /* KMDataVersionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMDataVersionManager.swift; sourceTree = "<group>"; };
 		BBEFD01B2AF9E5AA003FABD8 /* KMBatchOperateAddHeaderFooterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchOperateAddHeaderFooterViewController.swift; sourceTree = "<group>"; };
 		BBEFD01F2AF9E5BC003FABD8 /* KMBatchOperateAddHeaderFooterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMBatchOperateAddHeaderFooterViewController.xib; sourceTree = "<group>"; };
@@ -9144,8 +9140,8 @@
 				9F8539BD2943085A00DF644E /* KMBrowser.swift */,
 				BB7E59F52BBA427C0021E63D /* KMBrowserWindow.swift */,
 				9F8539C929430BF300DF644E /* KMBrowserWindowController.swift */,
-				BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift */,
 				9F8539CA29430BF300DF644E /* KMBrowserWindowController.xib */,
+				BBEF0F992B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift */,
 				9F8539C529430AC400DF644E /* KMToolbarRightView.swift */,
 				9F8539D12943121100DF644E /* KMSegmentedBox.swift */,
 				9F8539DD29470A0700DF644E /* KMTabStripView.swift */,
@@ -11938,14 +11934,12 @@
 				BBB7B48C2A0384E100B58A5A /* NSCollectionViewItem+KMExtension.swift */,
 				BBD54ED32A1CBD720012A230 /* NSView+KMExtension.swift */,
 				BBBF68832A3C3AF10058E14E /* NSDocumentController+KMExtension.swift */,
-				BBCE570F2A72712200508EFC /* NSWindowController+KMExtension.swift */,
 				BBCE57132A72713A00508EFC /* NSViewController+KMExtension.swift */,
 				BBCE57172A72723600508EFC /* NSResponder+KMExtension.swift */,
 				BB3A81B42AC2C0F4006FC66C /* NSObject+KMExtension.swift */,
 				BB74DA762AC41182006EDFE7 /* NSFont+KMExtension.swift */,
 				BB74DA7A2AC41DE9006EDFE7 /* NSString+KMExtension.swift */,
 				BB60138F2AD3AFF000A76FB2 /* NSPopover+KMExtension.swift */,
-				BBA388122AEF9A42004FE93F /* NSWindow+KMExtension.swift */,
 				BB90E4ED2AF3546500B04B9F /* NSUserDefaultsController+KMExtension.swift */,
 				BB03D6932B021124008C9976 /* NSSegmentedControl+KMExtension.swift */,
 				9FE0BBEA2B0F242C00CD1CAC /* NSUserDefaults_KMExtension.swift */,
@@ -12330,7 +12324,6 @@
 		BB1BFF842AEA2F2F003EB179 /* Catogary */ = {
 			isa = PBXGroup;
 			children = (
-				BB1BFF852AEA30B1003EB179 /* NSWindow+PopOver.swift */,
 				BB1BFF8D2AEA547B003EB179 /* NSButton+CustomAppearance.swift */,
 				BBC4F9F52AEB69940098A1A8 /* NSArray+Extension.swift */,
 			);
@@ -12411,6 +12404,14 @@
 			path = Model;
 			sourceTree = "<group>";
 		};
+		BB274CBA2CD37D1300DF5D8D /* NSWindow+KMExtension */ = {
+			isa = PBXGroup;
+			children = (
+				BBA388122AEF9A42004FE93F /* NSWindow+KMExtension.swift */,
+			);
+			path = "NSWindow+KMExtension";
+			sourceTree = "<group>";
+		};
 		BB276A562B038CF500AB5578 /* OCRNew */ = {
 			isa = PBXGroup;
 			children = (
@@ -14059,6 +14060,7 @@
 			isa = PBXGroup;
 			children = (
 				BBA633372CC09DE10040B7F6 /* NSWindowController+Extension.swift */,
+				BBCE570F2A72712200508EFC /* NSWindowController+KMExtension.swift */,
 			);
 			path = "NSWindowController+Extension";
 			sourceTree = "<group>";
@@ -15283,6 +15285,7 @@
 				F3A0F8522CC8F56400E7373F /* Tool */,
 				BBA633352CC09DA30040B7F6 /* NSWindowController+Extension */,
 				F3D395642CBD2BE7000C6729 /* CustomAlertView */,
+				BB274CBA2CD37D1300DF5D8D /* NSWindow+KMExtension */,
 			);
 			path = Tools;
 			sourceTree = "<group>";
@@ -17571,7 +17574,6 @@
 				BB146FC6299DC0D100784A6A /* GTMSessionFetcherService.m in Sources */,
 				BB89722E294B08DE0045787C /* KMWatermarkViewController.swift in Sources */,
 				89E9B406295D268E00AEFA61 /* KMEditImagePropertyViewController.swift in Sources */,
-				BB1BFF862AEA30B1003EB179 /* NSWindow+PopOver.swift in Sources */,
 				899700F628F4051B009AF911 /* KMAnnotationViewController.swift in Sources */,
 				F359916929261F0D000D25DE /* CPDFListView+Tool.m in Sources */,
 				9F3D819329A33A290087B5AD /* KMDesignDropdown.swift in Sources */,
@@ -17667,7 +17669,7 @@
 				89D2D2FB294C806000BFF5FE /* KMPDFThumbnailItem.swift in Sources */,
 				F3D395672CBD2C6D000C6729 /* KMNCustomAlertView.swift in Sources */,
 				BB9599CB2B3184230062D346 /* KMRedactSelectPagesWindowController.swift in Sources */,
-				BBEF0F9A2B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift in Sources */,
+				BBEF0F9A2B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift in Sources */,
 				9FF371BB2C69A6BB005F9CC5 /* KMMeasureSideVC.swift in Sources */,
 				BBCB9EA62CCDF65000563AC8 /* KMNDisplayViewController.swift in Sources */,
 				BBB9B313299A5D6D004F3235 /* DropboxModel.m in Sources */,
@@ -19013,7 +19015,6 @@
 				9FDCD80F2B6C904900E22166 /* KMFormListMenuPopWindowController.swift in Sources */,
 				BB31981B2AC567B600107371 /* CPDFSelection+PDFListView.swift in Sources */,
 				65AD988A2CB615F000927779 /* KMNoteFilterStateViewModel.swift in Sources */,
-				BB1BFF872AEA30B1003EB179 /* NSWindow+PopOver.swift in Sources */,
 				9FDD0F65294AB645000C4DAD /* KMMainViewController.swift in Sources */,
 				9FCFEC692AC2EAD500EAD2CB /* CPDFListViewColorMenuItemView.swift in Sources */,
 				ADAFDA262AE8DE1B00F084BC /* KMAdvertisementModel.swift in Sources */,
@@ -19939,7 +19940,7 @@
 				BBA922332B4E97540061057A /* KMPurchaseLimitWindowController.swift in Sources */,
 				BBC8A76E2B05EDDF00FA9377 /* KMThumbnail.swift in Sources */,
 				BB4EEF4129764FCC003A3537 /* KMWatermarkColorView.swift in Sources */,
-				BBEF0F9B2B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift in Sources */,
+				BBEF0F9B2B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift in Sources */,
 				AD1D48102AFB1907007AC1F0 /* KMCompressView.swift in Sources */,
 				BB146FCA299DC0D100784A6A /* GTMSessionFetcher.m in Sources */,
 				BBC70EB52AEA847500AC1585 /* KMToolbarCustomViewController.swift in Sources */,
@@ -20419,7 +20420,7 @@
 				BB6719FF2AD2CE1B003D44D5 /* CPDFSquareAnnotation+PDFListView.swift in Sources */,
 				BB71853F2C2B0A7C00C1156B /* KMEditPDFToolbarView.swift in Sources */,
 				BBEDC22D2B98407000970C54 /* CPDFAction+KMExtension.swift in Sources */,
-				BBEF0F9C2B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift in Sources */,
+				BBEF0F9C2B84A4C200A3E102 /* KMBrowserWindowController+PPTMode.swift in Sources */,
 				BB8B99FF2B355E7600A066EC /* KMLeftSideViewController+Action.swift in Sources */,
 				BB146FBF299DC0D100784A6A /* GTMGatherInputStream.m in Sources */,
 				BB8116012992682F0008F536 /* KMSecureLimitAlertView.swift in Sources */,
@@ -21218,7 +21219,6 @@
 				BB5EC3642C2BDC9D0090EF27 /* KMTextAlignmentController.swift in Sources */,
 				9FF94F1B29A770B500B1EF69 /* KMFillSignShapePanel.swift in Sources */,
 				BBA5429E29F13A140041BAD0 /* KMMemorandumPattern.swift in Sources */,
-				BB1BFF882AEA30B1003EB179 /* NSWindow+PopOver.swift in Sources */,
 				BB9EA1512B1ECD0400EAFD9B /* KMBatchOperateImageToPDFViewController.swift in Sources */,
 				9FD0D2B52AD5265A00DA3FF8 /* CPDFListAnnotationNoteWindowController.swift in Sources */,
 				F359916B29261F0E000D25DE /* CPDFListView+Tool.m in Sources */,

+ 34 - 98
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -14,10 +14,42 @@
             filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "3126"
-            endingLineNumber = "3126"
+            startingLineNumber = "3013"
+            endingLineNumber = "3013"
             landmarkName = "toolbarViewController(_:zoomModel:)"
             landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "CBD5F2A0-D33B-4635-AABA-000A5C35975E - c115801dd0277292"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMMainViewController.updateBackAndForwardButtonState() -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "3013"
+                  endingLineNumber = "3013"
+                  offsetFromSymbolStart = "452">
+               </Location>
+               <Location
+                  uuid = "CBD5F2A0-D33B-4635-AABA-000A5C35975E - b2a76df92711443f"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reader_Pro.KMMainViewController.toolbarViewController(_: PDF_Reader_Pro.KMToolbarViewController, zoomModel: Swift.Int) -&gt; ()"
+                  moduleName = "PDF Reader Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "3013"
+                  endingLineNumber = "3013"
+                  offsetFromSymbolStart = "180">
+               </Location>
+            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -2083,54 +2115,6 @@
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "EA66C38B-D2A9-4701-9F11-166981AF40A6"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/ChromiumTabs/KMBrowserWindowController+Actions.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "41"
-            endingLineNumber = "41"
-            landmarkName = "canEnterPresentation()"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "EA66C38B-D2A9-4701-9F11-166981AF40A6 - 2c70aba55274e821"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMBrowserWindowController.canEnterPresentation() -&gt; Swift.Bool"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/ChromiumTabs/KMBrowserWindowController+Actions.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "41"
-                  endingLineNumber = "41"
-                  offsetFromSymbolStart = "60">
-               </Location>
-               <Location
-                  uuid = "EA66C38B-D2A9-4701-9F11-166981AF40A6 - 2c70aba55274e821"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMBrowserWindowController.canEnterPresentation() -&gt; Swift.Bool"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/ChromiumTabs/KMBrowserWindowController+Actions.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "41"
-                  endingLineNumber = "41"
-                  offsetFromSymbolStart = "68">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -2286,54 +2270,6 @@
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "2DDDB646-C17B-4DC1-BB14-BC7FD969162C"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/ChromiumTabs/KMBrowserWindowController+Actions.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "72"
-            endingLineNumber = "72"
-            landmarkName = "exitFullscreen()"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "2DDDB646-C17B-4DC1-BB14-BC7FD969162C - c12ef80efc01a605"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMBrowserWindowController.exitFullscreen() -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/ChromiumTabs/KMBrowserWindowController+Actions.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "72"
-                  endingLineNumber = "72"
-                  offsetFromSymbolStart = "80">
-               </Location>
-               <Location
-                  uuid = "2DDDB646-C17B-4DC1-BB14-BC7FD969162C - c12ef80efc01a605"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Reader_Pro.KMBrowserWindowController.exitFullscreen() -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/ChromiumTabs/KMBrowserWindowController+Actions.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "72"
-                  endingLineNumber = "72"
-                  offsetFromSymbolStart = "132">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent