Browse Source

页面-去掉付费功能入口

tangchao 2 years ago
parent
commit
216f2cddd5

+ 1 - 0
.gitignore

@@ -2,4 +2,5 @@ build/*
 .DS_Store
 
 xcuserdata
+xcuserstate
 project.xcworkspace

BIN
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 33 - 33
PDF Office/PDF Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -881,12 +881,12 @@ extension KMPDFEditViewController: KMNewToolbarDelegate {
         return [KMToolbarPageEditPageRangeItemIdentifier,
                 KMToolbarPageEditLeftRotateItemIdentifier,
                 KMToolbarPageEditRightRotateItemIdentifier,
-                KMToolbarDividerItemIdentifier,
-                KMToolbarPageEditInsetItemIdentifier,
-                KMToolbarPageEditExtractItemIdentifier,
-                KMToolbarPageEditReplaceItemIdentifier,
-                KMToolbarPageEditSplitItemIdentifier,
-                KMToolbarPageEditReverseItemIdentifier,
+//                KMToolbarDividerItemIdentifier,
+//                KMToolbarPageEditInsetItemIdentifier,
+//                KMToolbarPageEditExtractItemIdentifier,
+//                KMToolbarPageEditReplaceItemIdentifier,
+//                KMToolbarPageEditSplitItemIdentifier,
+//                KMToolbarPageEditReverseItemIdentifier,
                 KMToolbarDividerItemIdentifier,
                 KMToolbarPageEditDeleteItemIdentifier]
     }
@@ -1139,47 +1139,47 @@ extension KMPDFEditViewController : NSMenuDelegate,NSMenuItemValidation {
         let row = self.thumbnailView.collectionView.selectionIndexes
         var item = NSMenuItem()
         
-        if (row.count == 1) {
-            item = menu.addItem(withTitle: NSLocalizedString("Insert", comment: ""), action: nil, target: self)
-            item.representedObject = row
-            
-            var subMenu = NSMenu()
-            var subitem = NSMenuItem()
-            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert File", comment: ""), action: #selector(insertPageItemAction), target: self, tag:0)
-            subitem.representedObject = row
-            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert blank page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:1)
-            subitem.representedObject = row
-            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:2)
-            subitem.representedObject = row
-            item.submenu = subMenu
-        }
+//        if (row.count == 1) {
+//            item = menu.addItem(withTitle: NSLocalizedString("Insert", comment: ""), action: nil, target: self)
+//            item.representedObject = row
+//
+//            var subMenu = NSMenu()
+//            var subitem = NSMenuItem()
+//            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert File", comment: ""), action: #selector(insertPageItemAction), target: self, tag:0)
+//            subitem.representedObject = row
+//            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert blank page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:1)
+//            subitem.representedObject = row
+//            subitem = subMenu.addItem(withTitle: NSLocalizedString("Insert page", comment: ""), action: #selector(insertPageItemAction), target: self, tag:2)
+//            subitem.representedObject = row
+//            item.submenu = subMenu
+//        }
   
         
-        item = menu.addItem(withTitle: NSLocalizedString("Extract", comment: ""), action: #selector(extractPageItemAction), target: self)
-        item.representedObject = row
+//        item = menu.addItem(withTitle: NSLocalizedString("Extract", comment: ""), action: #selector(extractPageItemAction), target: self)
+//        item.representedObject = row
         
-        if (row.count == 1) {
-            item = menu.addItem(withTitle: NSLocalizedString("Replace Page", comment: ""), action: #selector(replacePageItemAction), target: self)
-            item.representedObject = row
-        }
+//        if (row.count == 1) {
+//            item = menu.addItem(withTitle: NSLocalizedString("Replace Page", comment: ""), action: #selector(replacePageItemAction), target: self)
+//            item.representedObject = row
+//        }
 
         item = menu.addItem(withTitle: NSLocalizedString("Delete Page", comment: ""), action: #selector(deletePageItemAction), target: self)
         item.representedObject = row
 
         menu.addItem(NSMenuItem.separator())
         
-        item = menu.addItem(withTitle: NSLocalizedString("90 Rotate", comment: ""), action: #selector(rotatePageItemAction), target: self)
+        item = menu.addItem(withTitle: NSLocalizedString("Clockwise rotation", comment: ""), action: #selector(rotatePageItemAction), target: self)
         item.representedObject = row
-        item = menu.addItem(withTitle: NSLocalizedString("-90 Rotate", comment: ""), action: #selector(leftRotatePageItemAction), target: self)
+        item = menu.addItem(withTitle: NSLocalizedString("Counterclockwise rotation", comment: ""), action: #selector(leftRotatePageItemAction), target: self)
         item.representedObject = row
         
         menu.addItem(NSMenuItem.separator())
         
-        item = menu.addItem(withTitle: NSLocalizedString("copy", comment: ""), action: #selector(copyItemAction), target: self)
+        item = menu.addItem(withTitle: NSLocalizedString("Copy", comment: ""), action: #selector(copyItemAction), target: self)
         item.representedObject = row
-        item = menu.addItem(withTitle: NSLocalizedString("cut", comment: ""), action: #selector(cutItemAction), target: self)
+        item = menu.addItem(withTitle: NSLocalizedString("Cut", comment: ""), action: #selector(cutItemAction), target: self)
         item.representedObject = row
-        item = menu.addItem(withTitle: NSLocalizedString("paste", comment: ""), action: #selector(pastePageItemAction), target: self)
+        item = menu.addItem(withTitle: NSLocalizedString("Paste", comment: ""), action: #selector(pastePageItemAction), target: self)
         item.representedObject = row
         
         menu.addItem(NSMenuItem.separator())
@@ -1188,14 +1188,14 @@ extension KMPDFEditViewController : NSMenuDelegate,NSMenuItemValidation {
             item = menu.addItem(withTitle: NSLocalizedString("hidden page size", comment: ""), action: #selector(showPageSizeItemAction), target: self)
             item.representedObject = row
         } else {
-            item = menu.addItem(withTitle: NSLocalizedString("show page size", comment: ""), action: #selector(showPageSizeItemAction), target: self)
+            item = menu.addItem(withTitle: NSLocalizedString("Display page size", comment: ""), action: #selector(showPageSizeItemAction), target: self)
             item.representedObject = row
         }
 
         
         menu.addItem(NSMenuItem.separator())
         
-        item = menu.addItem(withTitle: NSLocalizedString("print", comment: ""), action: #selector(printItemAction), target: self)
+        item = menu.addItem(withTitle: NSLocalizedString("Print", comment: ""), action: #selector(printItemAction), target: self)
         item.representedObject = row
         
         item = menu.addItem(withTitle: NSLocalizedString("Share", comment: ""), action: nil, target: self)

+ 0 - 2
PDF Office/PDF Office/Class/PDFTools/PageEdit/View/KMPageEditThumbnailView.swift

@@ -15,8 +15,6 @@ class KMPageEditThumbnailView: KMPDFThumbnailView {
     var doubleClickItem: KMPageEditThumbnailViewDoubleClickItem!
     private var selectedIndexPaths = Set<IndexPath>()
     
-    private var dragedIndexPaths: [IndexPath] = []
-    
     private let defaultItemSize = NSMakeSize(208, 294)
     var itemSize: NSSize = NSMakeSize(208, 294)
     private var defaultThumbnailSzie: NSSize!

+ 16 - 10
PDF Office/PDF Office/Class/PDFTools/Secure/Window/KMPasswordInputWindow.swift

@@ -291,7 +291,7 @@ class KMPasswordInputWindow: NSWindow {
             }
         } else {
             if document.permissionsStatus == CPDFDocumentPermissions.none {
-                let reuslt = document.unlock(withPassword: secureTextFiled.password())
+                document.unlock(withPassword: secureTextFiled.password())
                 KMPasswordInputWindow.permissionsStatus = document.permissionsStatus
                 if document.permissionsStatus == .owner { /// 密码正确
                     guard let callback = KMPasswordInputWindow.myItemClick else {
@@ -483,6 +483,7 @@ extension NSOpenPanel {
                 return
             }
             
+            /// 已加锁(开启密码)
             KMPasswordInputWindow.openWindow(window: window, url: panel.url!) { result, password in
                 if (result == .cancel) {
                     callback(panel.url, .cancel, nil)
@@ -494,19 +495,24 @@ extension NSOpenPanel {
                     return
                 }
                 
-                if (KMPasswordInputWindow.permissionsStatus == .none) {
+                /// 用户输入的是权限密码
+                if (KMPasswordInputWindow.permissionsStatus == .owner) {
                     callback(panel.url, .success ,password)
                     return
                 }
                 
-                KMPasswordInputWindow.openWindow(window: window, type: .owner, url: panel.url!) { result, password in
-                    if (result == .cancel) {
-                        callback(panel.url, .cancel , nil)
-                        return
-                    }
-                    
-                    callback(panel.url, .success , password)
-                }
+                /// 用户输入的是开启密码 (无法判断是否还有权限未解密)
+                
+                /// 还有权限密码未解锁
+//                KMPasswordInputWindow.openWindow(window: window, type: .owner, url: panel.url!) { result, password in
+//                    if (result == .cancel) {
+//                        callback(panel.url, .cancel , nil)
+//                        return
+//                    }
+//
+//                    callback(panel.url, .success , password)
+//                }
+                callback(panel.url, .success ,password)
             }
         }
     }

+ 1 - 2
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMPDFThumbnailView.swift

@@ -97,8 +97,7 @@ extension KMPDFThumbnailView : NSCollectionViewDataSource {
     }
     
     func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
-        if self.document.isLocked ||
-            self.document.isEncrypted {
+        if self.document.isLocked {
             return 0
         }
         return Int(self.document.pageCount)

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

@@ -1692,7 +1692,8 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 return
             }
             
-            if (self.listView.document.permissionsStatus == .owner) {
+            /// 删除安全性设置
+            if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
                 KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [weak self]  result, password in
                     if (result == .cancel) {
                         return
@@ -1712,7 +1713,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 }
                 return
             }
-            /// 删除安全性设置
+            
             let alert = NSAlert()
             alert.messageText = NSLocalizedString("Are you sure you want to remove the security settings for”” documents?", comment: "")
             alert.addButton(withTitle: NSLocalizedString("Delete", comment: ""))

+ 2 - 2
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -137,7 +137,7 @@ import Cocoa
     override func viewWillAppear() {
         super.viewWillAppear()
         
-        if (self.listView.document.permissionsStatus == .owner) {
+        if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
             self.showSecureLimitTip()
         }
     }
@@ -404,12 +404,12 @@ import Cocoa
             
             if (self!.listView.document.isEncrypted) {
                 KMPasswordInputWindow.openWindow(window: (self?.view.window)!, type: .owner, url: self!.listView.document.documentURL) { result, password in
-                    self?.hiddenSecureLimitTip()
                     
                     if result == .cancel { /// 关闭
                         return
                     }
                     /// 解密成功
+                    self?.hiddenSecureLimitTip()
                     self!.listView.document.unlock(withPassword: password)
                 }
                 return