Procházet zdrojové kódy

【页面分割】属性面板控制器梳理代码

tangchao před 1 rokem
rodič
revize
8dde18bc8f

+ 45 - 42
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/PageDisplay/KMPageDisplayPropertiesViewController.swift

@@ -52,7 +52,7 @@ class KMPageDisplayPropertiesButton: NSButton {
     
     @IBOutlet weak var pdfView: CPDFListView!
     var readerModeBlock: ReaderModeCallBack?
-    @IBOutlet weak var mainController: KMMainViewController!
+    @IBOutlet weak var mainController: KMMainViewController?
     
     @IBOutlet private var pageLayoutLabel: NSTextField!
     @IBOutlet private var singlePageButton: KMPageDisplayPropertiesButton!
@@ -151,7 +151,7 @@ class KMPageDisplayPropertiesButton: NSButton {
         horizontalScreenButton.image = NSImage(named: KMImageNameUXIconPropertybarViewSplitscreenhorNor)
         horizontalScreenButton.wantsLayer = true
 
-        if let documentPath = self.mainController.secondaryPdfView.document?.documentURL?.path {
+        if let documentPath = self.mainController?.secondaryPdfView.document?.documentURL?.path {
             replaceView.isHidden = false
         } else {
             replaceView.isHidden = true
@@ -188,7 +188,7 @@ class KMPageDisplayPropertiesButton: NSButton {
             if downEntered {
                 self.counterclockwiseRotationBox.fillColor = KMAppearance.Status.selColor()
                 self.counterclockwiseRotationImageView.image = NSImage(named: KMImageNameUXIconPropertybarRotateCounterclockwisePre)
-                self.mainController.menuItemAction_rotateLeft((Any).self)
+                self.mainController?.menuItemAction_rotateLeft((Any).self)
             } else {
                 self.counterclockwiseRotationBox.fillColor = KMAppearance.Layout.l1Color()
                 self.counterclockwiseRotationImageView.image = NSImage(named: KMImageNameUXIconPropertybarRotateCounterclockwiseNor)
@@ -207,7 +207,7 @@ class KMPageDisplayPropertiesButton: NSButton {
             if downEntered {
                 self.clockwiseRotationBox.fillColor = KMAppearance.Status.selColor()
                 self.clockwiseRotationImageView.image = NSImage(named: KMImageNameUXIconPropertybarRotateClockwisePre)
-                self.mainController.menuItemAction_rotateRight((Any).self)
+                self.mainController?.menuItemAction_rotateRight((Any).self)
             } else {
                 self.clockwiseRotationBox.fillColor = KMAppearance.Layout.l1Color()
                 self.clockwiseRotationImageView.image = NSImage(named: KMImageNameUXIconPropertybarRotateClockwiseNor)
@@ -296,7 +296,7 @@ class KMPageDisplayPropertiesButton: NSButton {
     }
     
     private func reloadReplaceView() {
-        if let documentPath = mainController.secondaryPdfView.document?.documentURL?.path {
+        if let documentPath = mainController?.secondaryPdfView.document?.documentURL?.path {
             replaceFileButton.title = NSLocalizedString("Replace File", comment: "")
             replaceFileButton.toolTip = NSLocalizedString("Replace File", comment: "")
             replaceFileNameLabel.attributedStringValue = replaceFileName(withFilePath: (documentPath as NSString).lastPathComponent)
@@ -346,10 +346,10 @@ class KMPageDisplayPropertiesButton: NSButton {
             pageBreaksButton.state = .off
         }
         
-        if !(mainController.secondaryPdfView.window != nil) {
+        if !(mainController?.secondaryPdfView.window != nil) {
             setSplitViewType(.singleScreen)
         } else {
-            if mainController.pdfSplitView.isVertical {
+            if let data = mainController?.pdfSplitView.isVertical, data {
                 setSplitViewType(.verticalScreen)
             } else {
                 setSplitViewType(.horizontalScreen)
@@ -475,16 +475,16 @@ class KMPageDisplayPropertiesButton: NSButton {
         switch sender.tag {
         case 0:
             setDisplayMode(.singlePage)
-            mainController.selectDisplay(display: isContinuPage ? .singlePageContinuous : .singlePage, viewSettingIsReload: false)
+            self.mainController?.selectDisplay(display: isContinuPage ? .singlePageContinuous : .singlePage, viewSettingIsReload: false)
         case 1:
             setDisplayMode(.twoPages)
-            mainController.selectDisplay(display: isContinuPage ? .twoUpContinuous : .twoUp, viewSettingIsReload: false)
+            self.mainController?.selectDisplay(display: isContinuPage ? .twoUpContinuous : .twoUp, viewSettingIsReload: false)
         case 2:
             setDisplayMode(.coverPage)
-            mainController.selectDisplay(display: isContinuPage ? .bookContinuous : .bookMode, viewSettingIsReload: false)
+            self.mainController?.selectDisplay(display: isContinuPage ? .bookContinuous : .bookMode, viewSettingIsReload: false)
         case 3:
 //            readerModeBlock?(isReaderMode)
-            mainController.selectDisplay(display: isContinuPage ? .readContinuous : .readModel, viewSettingIsReload: false)
+            self.mainController?.selectDisplay(display: isContinuPage ? .readContinuous : .readModel, viewSettingIsReload: false)
         default:
             break
         }
@@ -495,15 +495,15 @@ class KMPageDisplayPropertiesButton: NSButton {
 
         if isContinuPage {
             if displayMode == KMDisplayModeType.singlePage {
-                mainController.selectDisplay(display: .singlePageContinuous, viewSettingIsReload: false)
+                self.mainController?.selectDisplay(display: .singlePageContinuous, viewSettingIsReload: false)
             } else {
-                mainController.selectDisplay(display: .twoUpContinuous, viewSettingIsReload: false)
+                self.mainController?.selectDisplay(display: .twoUpContinuous, viewSettingIsReload: false)
             }
         } else {
             if displayMode == KMDisplayModeType.singlePage {
-                mainController.selectDisplay(display: .singlePage, viewSettingIsReload: false)
+                self.mainController?.selectDisplay(display: .singlePage, viewSettingIsReload: false)
             } else {
-                mainController.selectDisplay(display: .twoUp, viewSettingIsReload: false)
+                self.mainController?.selectDisplay(display: .twoUp, viewSettingIsReload: false)
             }
         }
     }
@@ -514,7 +514,9 @@ class KMPageDisplayPropertiesButton: NSButton {
     }
     
     @IBAction private func splitViewButtonAction(_ sender: KMPageDisplayPropertiesButton) {
-//        if sender.tag > 0 && !IAPProductsManager.defaultManager().isAvailableAllFunction {
+//        [[FMTrackEventManager manager] trackEvent:@"SubTbr_PageDisplay" withProperties:@{@"SubTbr_Btn":@"Btn_SubTbr_PageDisplay_ViewSetting_SplitView"}];
+        
+//        if sender.tag > 0 && IAPProductsManager.default().isAvailableAllFunction() == false {
 //            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
 //            return
 //        }
@@ -528,13 +530,13 @@ class KMPageDisplayPropertiesButton: NSButton {
         case 1:
             setSplitViewType(.verticalScreen)
             menuItem.tag = 1
-            if let documentPath = mainController.secondaryPdfView.document?.documentURL?.path, !documentPath.isEmpty {
+            if let documentPath = self.mainController?.secondaryPdfView.document?.documentURL?.path, !documentPath.isEmpty {
                 replaceView.isHidden = false
             }
         case 2:
             setSplitViewType(.horizontalScreen)
             menuItem.tag = 0
-            if let documentPath = mainController.secondaryPdfView.document?.documentURL?.path, !documentPath.isEmpty {
+            if let documentPath = self.mainController?.secondaryPdfView.document?.documentURL?.path, !documentPath.isEmpty {
                 replaceView.isHidden = false
             }
         default:
@@ -543,6 +545,7 @@ class KMPageDisplayPropertiesButton: NSButton {
         
 //        mainController.toggleSplitPDF(menuItem)
         
+        
         if !replaceView.isHidden {
             reloadReplaceView()
             replaceFileButton.setTitleColor(KMAppearance.Layout.w0Color())
@@ -552,8 +555,8 @@ class KMPageDisplayPropertiesButton: NSButton {
     }
     
     @IBAction private func replaceFileButtonAction(_ sender: Any) {
-        if let document = mainController.secondaryPdfView.document {
-            mainController.changePDFDocument(isChange: false) { [weak self] filePath in
+        if let document = self.mainController?.secondaryPdfView.document {
+            self.mainController?.changePDFDocument(isChange: false) { [weak self] filePath in
                 self!.replaceFileNameLabel.attributedStringValue = self!.replaceFileName(withFilePath: (filePath as NSString).lastPathComponent)
                 self!.replaceFileNameLabel.isHidden = false
                 if self!.replaceFileButton.title == NSLocalizedString("Select File", comment: "") {
@@ -563,7 +566,7 @@ class KMPageDisplayPropertiesButton: NSButton {
                 }
             }
         } else {
-            mainController.changePDFDocument(isChange: true) { [weak self] filePath in
+            self.mainController?.changePDFDocument(isChange: true) { [weak self] filePath in
                 self!.replaceFileNameLabel.attributedStringValue = self!.replaceFileName(withFilePath: (filePath as NSString).lastPathComponent)
                 self!.replaceFileNameLabel.isHidden = false
                 if self!.replaceFileButton.title == NSLocalizedString("Select File", comment: "") {
@@ -623,11 +626,11 @@ extension KMPageDisplayPropertiesViewController: NSCollectionViewDelegate, NSCol
                 UserDefaults.standard.synchronize()
             }
             
-//            if !IAPProductsManager.defaultManager.isAvailableAllFunction {
-//                item.vipImageView.isHidden = indexPath.item == 0 ? true : false
-//            } else {
-//                item.vipImageView.isHidden = true
-//            }
+            if IAPProductsManager.default().isAvailableAllFunction() == false {
+                item.vipImageView.isHidden = indexPath.item == 0 ? true : false
+            } else {
+                item.vipImageView.isHidden = true
+            }
             
             return item
         } else {
@@ -656,11 +659,11 @@ extension KMPageDisplayPropertiesViewController: NSCollectionViewDelegate, NSCol
                     UserDefaults.standard.synchronize()
                 }
                 
-//                if !IAPProductsManager.defaultManager.isAvailableAllFunction {
-//                    item.vipImageView.isHidden = false
-//                } else {
-//                    item.vipImageView.isHidden = true
-//                }
+                if IAPProductsManager.default().isAvailableAllFunction() == false {
+                    item.vipImageView.isHidden = false
+                } else {
+                    item.vipImageView.isHidden = true
+                }
                 
                 return item
             } else {
@@ -681,11 +684,11 @@ extension KMPageDisplayPropertiesViewController: NSCollectionViewDelegate, NSCol
                     UserDefaults.standard.synchronize()
                 }
                 
-//                if !IAPProductsManager.defaultManager.isAvailableAllFunction {
-//                    item.vipImageView.isHidden = indexPath.item == 0 ? true : false
-//                } else {
-//                    item.vipImageView.isHidden = true
-//                }
+                if IAPProductsManager.default().isAvailableAllFunction() == false {
+                    item.vipImageView.isHidden = indexPath.item == 0 ? true : false
+                } else {
+                    item.vipImageView.isHidden = true
+                }
                 
                 return item
             }
@@ -704,12 +707,12 @@ extension KMPageDisplayPropertiesViewController: NSCollectionViewDelegate, NSCol
     func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
         let indexPathArr = Array(indexPaths)
         for indexPath in indexPathArr {
-//            if !IAPProductsManager.defaultManager.isAvailableAllFunction {
-//                if indexPath.item > 0 {
-//                    KMPurchaseCompareWindowController.sharedInstance.showWindow(nil)
-//                    return
-//                }
-//            }
+            if IAPProductsManager.default().isAvailableAllFunction() == false {
+                if indexPath.item > 0 {
+                    KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+                    return
+                }
+            }
             pdfView.setPageBackgroundColorWith(themesArray[indexPath.item], viewMode: KMPDFViewMode(rawValue: UInt(indexPath.item))!)
             reloadData()
         }

+ 6 - 1
PDF Office/PDF Master/Class/README.md

@@ -30,6 +30,11 @@
 ## 批量
 * KMBatchOperateWindowController
 
+## 属性面板
+
+- 【页面设置】
+* KMPageDisplayPropertiesViewController
+
 ## xxx
 
 [sign in](https://www.baidu.com) the [dashboard](https://www.baidu.com). to [sign up](https://www.baidu.com) 
@@ -42,7 +47,7 @@
 
 
 
-## xxx
+
 
 ## xxx