소스 검색

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

tangchao 10 달 전
부모
커밋
3c89a7de4b

+ 0 - 39
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -102,9 +102,6 @@ import Cocoa
     var didTrialExpiredLoad: Bool = false
     var repeatTrialAlertLoad: Bool = false
     
-    //春季活动
-    var recommondPopWindowVC: KMRecommondPopWindow?
-    
     @IBOutlet weak var rightBottonHeight: NSLayoutConstraint!
     
     var currentController: NSWindowController?
@@ -231,15 +228,6 @@ import Cocoa
                         KMAdsInfoManager.shareInstance.adsInfoArrM = arrM
                     }
                 }
-                
-                if ((KMAdvertisementManager.manager.info.popWindowContent) != nil) {
-                    if KMAdvertisementManager.manager.info.popWindowContent!.content!.count > 0 {
-                        let info = KMAdvertisementManager.manager.info.popWindowContent!.content?.first
-                        if KMAdvertisementManager.checkAdvertisementValid(info!) {
-                            self.loadRecommondPopWindow()
-                        }
-                    }
-                }
             }
         }
     }
@@ -1031,30 +1019,3 @@ extension KMHomeViewController {
         self.updateAITipViewShowState()
     }
 }
-
-extension KMHomeViewController {
-    // MARK: - Recommond活动
-    func loadRecommondPopWindow() {
-        if recommondPopWindowVC == nil {
-            recommondPopWindowVC = KMRecommondPopWindow()
-        }
-        
-        if let info = KMAdvertisementManager.manager.info.popWindowContent?.content?.first {
-            recommondPopWindowVC?.recommondInfo = info
-            
-            guard let windowFrame = self.view.window?.frame, let popWindowFrame = recommondPopWindowVC?.window?.frame else {
-                return
-            }
-            
-            let x = windowFrame.minX + (windowFrame.size.width - popWindowFrame.size.width) / 2.0
-            let y = windowFrame.minY + (windowFrame.size.height - popWindowFrame.size.height) / 2.0
-            recommondPopWindowVC?.window?.setFrame(NSRect(x: x, y: y, width: popWindowFrame.size.width, height: popWindowFrame.size.height), display: true)
-            
-            recommondPopWindowVC?.window?.orderFront((Any).self)
-//            recommondPopWindowVC?.window?.becomeMain()
-            
-            UserDefaults.standard.set("Show", forKey: info.version ?? "")
-            UserDefaults.standard.synchronize()
-        }
-    }
-}

+ 1 - 1
PDF Office/PDF Master/Class/KMAdvertisement/Manager/KMAdvertisementManager.swift

@@ -373,7 +373,7 @@ extension KMAdvertisementManager {
             return false
         }
         
-        if info.subscriptionType == "1" {
+        if info.subscriptionType == "3" {
             if !IAPProductsManager.default().isAvailableAllFunction() {
                 return false
             }

+ 3 - 0
PDF Office/PDF Master/Class/KMAdvertisement/View/View/KMAdvertisementShowView.xib

@@ -32,6 +32,9 @@
                                 <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                 <font key="font" metaFont="system"/>
                             </buttonCell>
+                            <connections>
+                                <action selector="contentButtonAction:" target="-2" id="05B-1b-7ai"/>
+                            </connections>
                         </button>
                         <button translatesAutoresizingMaskIntoConstraints="NO" id="Iay-VK-ICj">
                             <rect key="frame" x="178" y="90" width="30" height="30"/>

+ 54 - 28
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -7,6 +7,7 @@
 
 import Cocoa
 import PDFKit
+var sizeController: KMPDFPrintManageWindowController?
 
 typealias KMPrintWindowControllerPrintTypeChange = (_ controller: KMPrintWindowController, _ type: KMPrintModelType) -> Void
 
@@ -137,8 +138,10 @@ class KMPrintWindowController: KMBaseWindowController, NetServiceBrowserDelegate
         self.bottomView.type = printType
         self.settingView.type = printType
     }
-    
-    //MARK: 打开文件
+}
+
+//MARK: 打开文件
+extension KMPrintWindowController {
     /**
      @abstract 选取文件跳转打印界面
      @param window 文档地址
@@ -197,37 +200,54 @@ class KMPrintWindowController: KMBaseWindowController, NetServiceBrowserDelegate
             guard let  pdfDocument = PDFDocument(url: inputDocument!.documentURL) else { return }
         }
         
-        let printWindowController: KMPrintWindowController = KMPrintWindowController.init(windowNibName: "KMPrintWindowController")
-
-        printWindowController.printType = printType
+        guard let  pdfDocument = PDFDocument(url: inputDocument!.documentURL) else { return }
         switch printType {
         case .size:
-            printWindowController.window?.contentMinSize = CGSize(width: 600, height: 500)
-            printWindowController.window?.contentMaxSize = CGSize(width: 600, height: 500)
-            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 600, height: 500), display: true)
-        case .poster:
-            printWindowController.window?.contentMinSize = CGSize(width: 800, height: 500)
-            printWindowController.window?.contentMaxSize = CGSize(width: 800, height: 500)
-            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 800, height: 500), display: true)
-        case .multipage:
-            printWindowController.window?.contentMinSize = CGSize(width: 800, height: 700)
-            printWindowController.window?.contentMaxSize = CGSize(width: 800, height: 700)
-            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 800, height: 700), display: true)
-        case .pamphlet:
-            printWindowController.window?.contentMinSize = CGSize(width: 800, height: 600)
-            printWindowController.window?.contentMaxSize = CGSize(width: 800, height: 600)
-            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 800, height: 600), display: true)
+            sizeController = KMPDFPrintManageWindowController.init(pdfDocument: pdfDocument, currentPage: pdfDocument.page(at: 0)) { document in
+                KMPrintWindowController.openPrintView(document: document)
+            }
+            NSWindow.currentWindow().beginSheet(sizeController!.window!)
+//        case .poster:
+//
+//        case .multipage:
+//
+//        case .pamphlet:
+
         default:
             break
         }
         
-        NSWindow.currentWindow().beginSheet(printWindowController.window!)
-        if inputDocument != nil {
-            printWindowController.inputDocument = inputDocument
-        }
-        
-        printWindowController.inputType = inputType
-        printWindowController.inputPageRange = inputPageRange
+//        let printWindowController: KMPrintWindowController = KMPrintWindowController.init(windowNibName: "KMPrintWindowController")
+//
+//        printWindowController.printType = printType
+//        switch printType {
+//        case .size:
+//            printWindowController.window?.contentMinSize = CGSize(width: 600, height: 500)
+//            printWindowController.window?.contentMaxSize = CGSize(width: 600, height: 500)
+//            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 600, height: 500), display: true)
+//        case .poster:
+//            printWindowController.window?.contentMinSize = CGSize(width: 800, height: 500)
+//            printWindowController.window?.contentMaxSize = CGSize(width: 800, height: 500)
+//            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 800, height: 500), display: true)
+//        case .multipage:
+//            printWindowController.window?.contentMinSize = CGSize(width: 800, height: 700)
+//            printWindowController.window?.contentMaxSize = CGSize(width: 800, height: 700)
+//            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 800, height: 700), display: true)
+//        case .pamphlet:
+//            printWindowController.window?.contentMinSize = CGSize(width: 800, height: 600)
+//            printWindowController.window?.contentMaxSize = CGSize(width: 800, height: 600)
+//            printWindowController.window?.setFrame(NSRect(x: 0, y: 0, width: 800, height: 600), display: true)
+//        default:
+//            break
+//        }
+//
+//        NSWindow.currentWindow().beginSheet(printWindowController.window!)
+//        if inputDocument != nil {
+//            printWindowController.inputDocument = inputDocument
+//        }
+//
+//        printWindowController.inputType = inputType
+//        printWindowController.inputPageRange = inputPageRange
     }
     
     static func showPrintWindowControll(inputData: URL?, inputDocument: AnyObject?, inputType: DataNavigationViewButtonActionType = .Print, inputPageRange: KMPrintPageRange) {
@@ -349,7 +369,13 @@ class KMPrintWindowController: KMBaseWindowController, NetServiceBrowserDelegate
             printOperation.runModal(for: NSApplication.shared.mainWindow!, delegate: self, didRun: nil, contextInfo: nil)
         }
     }
-
+    
+    static func openPrinter(document: PDFDocument) {
+        let printInfo = NSPrintInfo.shared
+        let printOperation: NSPrintOperation = document.printOperation(for: printInfo, scalingMode: .pageScaleNone, autoRotate: true)!
+        printOperation.showsPrintPanel = true //是否弹出打印机设置界面
+        printOperation.run()
+    }
 }
 
 //MARK: - Print

+ 2 - 1
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/Booklet/KMPDFBookletWindowController.m

@@ -630,7 +630,8 @@ static CGFloat KMPDFBookletGenerate_PDFViewMAXHeight = 404.0;
 {
     if (self.window.isSheet) {
 //        [self dismissSheet:nil];
-        [[NSApp mainWindow] endSheet:self.window];
+//        [[NSApp mainWindow] endSheet:self.window];
+        [self.window.sheetParent endSheet:self.window];
     } else {
         [super close];
     }

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/Multiple/KMPDFMultiplePrintWindowController.m

@@ -209,7 +209,7 @@
 {
     if (self.window.isSheet) {
 //        [self dismissSheet:nil];
-        [[NSApp mainWindow] endSheet:self.window];
+        [self.window.sheetParent endSheet:self.window];
     } else {
         [super close];
     }

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/Poster/KMPDFPosterPrintWindowController.m

@@ -223,7 +223,7 @@
 
 - (void)close {
     if (self.window.isSheet) {
-        [[NSApp mainWindow] endSheet:self.window];
+        [self.window.sheetParent endSheet:self.window];
 //        [self dismissSheet:nil];
     } else {
         [super close];

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/PrintHelper/PrintManage/KMPDFPrintManageWindowController.m

@@ -641,7 +641,7 @@ typedef NS_ENUM(NSUInteger, kPageSelectStyle) {
 
 - (void)close{
     if (self.window.isSheet) {
-        [[NSApp mainWindow] endSheet:self.window];
+        [self.window.sheetParent endSheet:self.window];
 //        [self dismissSheet:nil];
     } else {
         [super close];

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

@@ -97,6 +97,9 @@ let LOCKED_KEY  = "locked"
     //密码弹窗
     var passwordWindow: KMPasswordInputWindow?
     
+    //春季活动
+    var recommondPopWindowVC: KMRecommondPopWindow?
+    
     private var _needSave = false
     var needSave: Bool {
         set {
@@ -277,6 +280,17 @@ let LOCKED_KEY  = "locked"
     
     override func viewDidAppear() {
         super.viewDidAppear()
+        
+        //春季活动
+        if ((KMAdvertisementManager.manager.info.popWindowContent) != nil) {
+            if KMAdvertisementManager.manager.info.popWindowContent!.content!.count > 0 {
+                let info = KMAdvertisementManager.manager.info.popWindowContent!.content?.first
+                if KMAdvertisementManager.checkAdvertisementValid(info!) {
+                    self.loadRecommondPopWindow()
+                }
+            }
+        }
+        
         //刷新前一页后一页按钮
         self.updateNextAndPreViousButtonState()
         
@@ -3443,3 +3457,30 @@ extension KMMainViewController {
         return setup
     }
 }
+
+extension KMMainViewController {
+    // MARK: - Recommond活动
+    func loadRecommondPopWindow() {
+        if recommondPopWindowVC == nil {
+            recommondPopWindowVC = KMRecommondPopWindow()
+        }
+        
+        if let info = KMAdvertisementManager.manager.info.popWindowContent?.content?.first {
+            recommondPopWindowVC?.recommondInfo = info
+            
+            guard let windowFrame = self.view.window?.frame, let popWindowFrame = recommondPopWindowVC?.window?.frame else {
+                return
+            }
+            
+            let x = windowFrame.minX + (windowFrame.size.width - popWindowFrame.size.width) / 2.0
+            let y = windowFrame.minY + (windowFrame.size.height - popWindowFrame.size.height) / 2.0
+            recommondPopWindowVC?.window?.setFrame(NSRect(x: x, y: y, width: popWindowFrame.size.width, height: popWindowFrame.size.height), display: true)
+            
+            recommondPopWindowVC?.window?.orderFront((Any).self)
+            recommondPopWindowVC?.window?.becomeMain()
+            
+            UserDefaults.standard.set("Show", forKey: info.version ?? "")
+            UserDefaults.standard.synchronize()
+        }
+    }
+}

+ 2 - 2
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseCompareDMGWindowController.m

@@ -462,7 +462,7 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     
     if (KMAdvertisementManager.manager.info.discountContent.content.count > 0) {
         KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountContent.content.firstObject;
-        if ([info.show isEqual:@"true"] ) {
+        if ([info.show isEqual:@"1"] ) {
             self.discountTipImage.hidden = NO;
             
             NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
@@ -652,7 +652,7 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     dispatch_async(dispatch_get_main_queue(), ^{
         if (KMAdvertisementManager.manager.info.discountContent.content.count > 0) {
             KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountContent.content.firstObject;
-            if ([info.show isEqual:@"true"] ) {
+            if ([info.show isEqual:@"1"] ) {
                 self.discountTipImage.hidden = NO;
                 self.discountTipImage.image = info.image;
             }

+ 4 - 0
PDF Office/PDF Master/PDF_Reader_Pro DMG-Bridging-Header.h

@@ -121,3 +121,7 @@
 #import "KMRecommondPopWindow.h"
 
 #import "KMTableAnnotation.h"
+
+
+//打印
+#import "KMPDFPrintManageWindowController.h"

+ 4 - 0
PDF Office/PDF Master/PDF_Reader_Pro Edition-Bridging-Header.h

@@ -118,3 +118,7 @@
 #import "KMRecommondPopWindow.h"
 
 #import "KMTableAnnotation.h"
+
+
+//打印
+#import "KMPDFPrintManageWindowController.h"

+ 2 - 0
PDF Office/PDF Master/PDF_Reader_Pro-Bridging-Header.h

@@ -119,3 +119,5 @@
 
 #import "KMTableAnnotation.h"
 
+//打印
+#import "KMPDFPrintManageWindowController.h"