Browse Source

【2025】【菜单栏】菜单栏逻辑完善

niehaoyu 1 month ago
parent
commit
195898a18c

+ 13 - 56
PDF Office/PDF Master/AppDelegate+MenuAction.swift

@@ -313,9 +313,13 @@ extension AppDelegate {
             } else if action == NSSelectorFromString("menuItemAction_addPassword:") {
                 
             } else if action == NSSelectorFromString("menuItemAction_removePassword:") {
-                
+                if mainVC.listView.document.isLocked || mainVC.listView.document.password.count > 0 {
+                    return true
+                } else {
+                    return false
+                }
             } else if action == NSSelectorFromString("menuItemAction_unlockFunction:") {
-                
+                return mainVC.listView.document.isEncrypted
             } else if action == NSSelectorFromString("menuItemAction_searchPDF:") {
                 
             } else if action == NSSelectorFromString("menuItemAction_performFindPanelAction:") {
@@ -549,18 +553,11 @@ extension AppDelegate {
         guard let selector = sel else {
             return false
         }
-        let selectors = [NSSelectorFromString("menuItemAction_undo:"),
-                         NSSelectorFromString("menuItemAction_redo:"),
-                         NSSelectorFromString("menuItemAction_Copy:"),
-                         NSSelectorFromString("menuItemAction_Cut:"),
-                         NSSelectorFromString("menuItemAction_Paste:"),
-                         NSSelectorFromString("menuItemAction_PasteAndMatch:"),
-                         NSSelectorFromString("menuItemAction_Delete:"),
-                         NSSelectorFromString("menuItemAction_SelectAll:"),
-                         NSSelectorFromString("menuItemAction_ShowFont:"),
-                         NSSelectorFromString("menuItemAction_FontAction:"),
-                         NSSelectorFromString("menuItemAction_CustomFont:"),
-                         NSSelectorFromString("menuItemAction_FontAlign:")]
+        let selectors = [ NSSelectorFromString("menuItemAction_PasteAndMatch:"),
+                          NSSelectorFromString("menuItemAction_ShowFont:"),
+                          NSSelectorFromString("menuItemAction_FontAction:"),
+                          NSSelectorFromString("menuItemAction_CustomFont:"),
+                          NSSelectorFromString("menuItemAction_FontAlign:")]
         if selectors.contains(selector) {
             return true
         }
@@ -570,21 +567,7 @@ extension AppDelegate {
     func validateEditMenuItem(_ menuItem: NSMenuItem) -> Bool {
         let action = menuItem.action
         if let mainVC = self.mainViewController() {
-            if action == NSSelectorFromString("menuItemAction_undo:") {
-                
-            } else if action == NSSelectorFromString("menuItemAction_redo:") {
-                
-            } else if action == NSSelectorFromString("menuItemAction_Copy:") {
-                
-            } else if action == NSSelectorFromString("menuItemAction_Cut:") {
-                
-            } else if action == NSSelectorFromString("menuItemAction_Paste:") {
-                
-            } else if action == NSSelectorFromString("menuItemAction_PasteAndMatch:") {
-                
-            } else if action == NSSelectorFromString("menuItemAction_Delete:") {
-                
-            } else if action == NSSelectorFromString("menuItemAction_SelectAll:") {
+            if action == NSSelectorFromString("menuItemAction_PasteAndMatch:") {
                 
             } else if action == NSSelectorFromString("menuItemAction_ShowFont:") {
                 
@@ -601,38 +584,12 @@ extension AppDelegate {
     }
     
     //MARK: -IBAction
-    @IBAction func menuItemAction_undo(_ sender: NSMenuItem) {
-        
-    }
-    
-    @IBAction func menuItemAction_redo(_ sender: NSMenuItem) {
-        
-    }
-    
-    @IBAction func menuItemAction_Copy(_ sender: NSMenuItem) {
-        
-    }
     
-    @IBAction func menuItemAction_Cut(_ sender: NSMenuItem) {
-        
-    }
-    
-    @IBAction func menuItemAction_Paste(_ sender: NSMenuItem) {
-        
-    }
     
     @IBAction func menuItemAction_PasteAndMatch(_ sender: NSMenuItem) {
         
     }
-    
-    @IBAction func menuItemAction_Delete(_ sender: NSMenuItem) {
-        
-    }
-    
-    @IBAction func menuItemAction_SelectAll(_ sender: NSMenuItem) {
-        
-    }
-    
+ 
     @IBAction func menuItemAction_ShowFont(_ sender: NSMenuItem) {
         NSFontManager.shared.orderFrontFontPanel(nil)
     }

+ 4 - 3
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -1093,14 +1093,15 @@ struct KMNMWCFlags {
     
     func exitPDFReadMode() {
         viewManager.isPDFReadMode = false
+        
+        
         if viewManager.showDisplayView == false {
             viewManager.showDisplayView = true
             pdfToolbarController?.reloadLeftIconView()
             
+            updatePDFDisplaySettingView()
         }
         
-        updatePDFDisplaySettingView()
-        
         refreshToolbarViewHeightInfo()
         
         reloadPDFPageNumberToolbar()
@@ -1701,7 +1702,7 @@ struct KMNMWCFlags {
     //MARK: - Unlock Document
     func unlockPDFDocument() {
         KMBaseWindowController.checkPassword(url: self.document!.documentURL!, type: .owner, password: self.document?.password ?? "") { [unowned self] success, resultPassword in
-             
+            self.listView.document.unlock(withPassword: resultPassword)
         }
     }
    

+ 1 - 2
PDF Office/PDF Master/KMClass/Tools/Category/NSWindowController+Extension/NSWindowController+Extension.swift

@@ -76,9 +76,8 @@ extension NSWindowController {
         
         // 加密文件,尝试解锁
         if password.isEmpty == false {
-            let preStatus = document.permissionsStatus
             document.unlock(withPassword: password)
-            if document.permissionsStatus.rawValue > preStatus.rawValue { // 解密成功
+            if document.permissionsStatus == .owner { // 解密成功
                 completion(true, password)
                 return
             }