Browse Source

偏好设置-通用模块补充交互

tangchao 1 year ago
parent
commit
d918e67e34

+ 8 - 0
PDF Office/PDF Office.xcodeproj/project.pbxproj

@@ -2438,6 +2438,9 @@
 		BBA8B7B3293635D80097D183 /* KMPasswordInputWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBA8B7B2293635D80097D183 /* KMPasswordInputWindow.xib */; };
 		BBA8B7B4293635D80097D183 /* KMPasswordInputWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBA8B7B2293635D80097D183 /* KMPasswordInputWindow.xib */; };
 		BBA8B7B5293635D80097D183 /* KMPasswordInputWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBA8B7B2293635D80097D183 /* KMPasswordInputWindow.xib */; };
+		BBA93D2D29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA93D2C29BEBAA60044E0DD /* KMPreferenceEnum.swift */; };
+		BBA93D2E29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA93D2C29BEBAA60044E0DD /* KMPreferenceEnum.swift */; };
+		BBA93D2F29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBA93D2C29BEBAA60044E0DD /* KMPreferenceEnum.swift */; };
 		BBAFC83C2985194800D0648E /* KMPDFEditAppendWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = BBAFC8392985194800D0648E /* KMPDFEditAppendWindow.m */; };
 		BBAFC83D2985194800D0648E /* KMPDFEditAppendWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = BBAFC8392985194800D0648E /* KMPDFEditAppendWindow.m */; };
 		BBAFC83E2985194800D0648E /* KMPDFEditAppendWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = BBAFC8392985194800D0648E /* KMPDFEditAppendWindow.m */; };
@@ -4074,6 +4077,7 @@
 		BBA8B7A92935DC120097D183 /* KMRemovePasswordResultTipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMRemovePasswordResultTipView.swift; sourceTree = "<group>"; };
 		BBA8B7AE293600D70097D183 /* KMPasswordInputWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPasswordInputWindow.swift; sourceTree = "<group>"; };
 		BBA8B7B2293635D80097D183 /* KMPasswordInputWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMPasswordInputWindow.xib; sourceTree = "<group>"; };
+		BBA93D2C29BEBAA60044E0DD /* KMPreferenceEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPreferenceEnum.swift; sourceTree = "<group>"; };
 		BBAFC8392985194800D0648E /* KMPDFEditAppendWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMPDFEditAppendWindow.m; sourceTree = "<group>"; };
 		BBAFC83A2985194800D0648E /* KMPDFEditAppendWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMPDFEditAppendWindow.h; sourceTree = "<group>"; };
 		BBAFC83B2985194800D0648E /* KMPDFEditAppendWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMPDFEditAppendWindow.xib; sourceTree = "<group>"; };
@@ -6479,6 +6483,7 @@
 			isa = PBXGroup;
 			children = (
 				BB00301C298CB799002DD1A0 /* KMPreferenceManager.swift */,
+				BBA93D2C29BEBAA60044E0DD /* KMPreferenceEnum.swift */,
 			);
 			path = Tools;
 			sourceTree = "<group>";
@@ -9794,6 +9799,7 @@
 				89752D9F2936EC50003FF08E /* KMToolbar.m in Sources */,
 				BB147011299DC0D100784A6A /* OIDError.m in Sources */,
 				89752DEA293875FC003FF08E /* KMMainToolbarController.swift in Sources */,
+				BBA93D2D29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */,
 				BB89DD7E2953F863007C3FFA /* KMWatermarkFileOutsideView.swift in Sources */,
 				AD9527C6295295110039D2BC /* KMPrintPrinterModel.swift in Sources */,
 				BB146FE4299DC0D100784A6A /* GTLRURITemplate.m in Sources */,
@@ -10512,6 +10518,7 @@
 				89752DEB293875FC003FF08E /* KMMainToolbarController.swift in Sources */,
 				BB147012299DC0D100784A6A /* OIDError.m in Sources */,
 				9F1FE50E29407B2B00E952CA /* KMUploadFilePanel.swift in Sources */,
+				BBA93D2E29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */,
 				F34BF94A295310AB002C25A2 /* NSUserDefaults+PDFListView.m in Sources */,
 				89752DA02936EC50003FF08E /* KMToolbar.m in Sources */,
 				BB146FE5299DC0D100784A6A /* GTLRURITemplate.m in Sources */,
@@ -10824,6 +10831,7 @@
 				AD0FA4F229A8580D00EDEB50 /* KMComparativeTableView.swift in Sources */,
 				BB49ED10293F462E00C82CA2 /* KMConvertImageWindowController.swift in Sources */,
 				BBF38A60294F42FF0086D025 /* KMWatermarkAdjectiveStepper.swift in Sources */,
+				BBA93D2F29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */,
 				89E4E76329656A88002DBA6F /* KMAnnotationStampViewController.m in Sources */,
 				BB89726B294DB41D0045787C /* KMWatermarkAdjectivePositionView.swift in Sources */,
 				BBA19F4929AE27DB001A285A /* KMAnnotationTableRowView.swift in Sources */,

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


+ 18 - 18
PDF Office/PDF Office.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -142,8 +142,8 @@
             filePath = "PDF Office/Class/ChromiumTabs/KMBrowser.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "136"
-            endingLineNumber = "136"
+            startingLineNumber = "132"
+            endingLineNumber = "132"
             landmarkName = "saveSuccess(_:)"
             landmarkType = "7">
          </BreakpointContent>
@@ -212,22 +212,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "FD6BAEEF-416C-49DE-9E17-CD44B8324855"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Office/Class/ChromiumTabs/KMBrowser.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "21"
-            endingLineNumber = "21"
-            landmarkName = "createNewBrowser()"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -324,5 +308,21 @@
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "F1FD7E7D-EB88-451B-9090-D45D1D74B91C"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Office/Class/ChromiumTabs/src/Browser Window/CTBrowser.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "429"
+            endingLineNumber = "429"
+            landmarkName = "-canCloseContentsAt:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 6 - 10
PDF Office/PDF Office/Class/ChromiumTabs/KMBrowser.swift

@@ -37,7 +37,7 @@ import Cocoa
             isCloseAllTabViewItem = false
         } else {
             let currentDocument = tabStripModel.tabContents(at: Int32(numberOfTabViewItem-1)) as! KMMainDocument
-            let string = UserDefaults.standard.object(forKey: "isAutoSaveWhenClosingDocument") as? String
+            let isPrompt = KMPreferenceManager.shared.closeFileIsPrompt()
             if currentDocument.isNewCreated {
                 let exist = FileManager.default.fileExists(atPath: currentDocument.fileURL!.path)
                 if exist {
@@ -46,9 +46,9 @@ import Cocoa
                 currentCloseDocument = currentDocument
                 currentDocument.runModalSavePanel(for: .saveAsOperation, delegate: self, didSave: #selector(saveSuccess(_:)), contextInfo: nil)
             } else {
-                if currentDocument.isDocumentEdited && string == "0" {
+                if currentDocument.isDocumentEdited && isPrompt {
                     currentDocument.canClose(withDelegate: self, shouldClose: #selector(document(_:shouldClose:contextInfo:)), contextInfo: nil)
-                } else if currentDocument.isDocumentEdited && string == "1" {
+                } else if currentDocument.isDocumentEdited {
                     currentDocument.save(nil)
                     currentDocument.close()
                     if self.isCloseAllTabViewItem {
@@ -68,11 +68,7 @@ import Cocoa
     }
     
     func canCloseContentsAt(_ index: Int) -> Bool {
-        let string = UserDefaults.standard.object(forKey: "isAutoSaveWhenClosingDocument") as? String
-        var autoSave: Bool = false
-        if (string != nil && string == "1") {
-            autoSave = true
-        }
+        let isPrompt = KMPreferenceManager.shared.closeFileIsPrompt()
         let currentDocument = tabContents(at: Int32(index)) as! KMMainDocument
         var canClose = false
         if currentDocument.isNewCreated {
@@ -91,12 +87,12 @@ import Cocoa
                 canClose = true
             }
         }else {
-            if currentDocument.isDocumentEdited && autoSave == false {
+            if currentDocument.isDocumentEdited && isPrompt {
                 if currentDocument.isKind(of: KMMainDocument.self) {
                     currentDocument.closedByUserGestureFlag = true
                 }
                 currentDocument.canClose(withDelegate: self, shouldClose: #selector(document(_:shouldClose:contextInfo:)), contextInfo: nil)
-            } else if currentDocument.isDocumentEdited && string == "1" {
+            } else if currentDocument.isDocumentEdited {
                 currentDocument.save(nil)
                 currentDocument.close()
                 canClose = true

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

@@ -48,7 +48,6 @@ class KMLeftSideViewController: NSViewController, KMThumbnailViewControllerDeleg
     
     lazy var panelSetViewController : KMPDFViewPanelSetViewController = {
         let panelSetViewController = KMPDFViewPanelSetViewController()
-        panelSetViewController.mainVC = self.mainVC
         return panelSetViewController
     }()
     

+ 4 - 4
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/ViewPanel/KMPDFViewPanelSetViewController.swift

@@ -32,7 +32,7 @@ class KMPDFViewPanelSetViewController: NSViewController {
     @IBOutlet weak var singlePageImageView: NSImageView!
     @IBOutlet weak var twoPageImageView: NSImageView!
     
-    var mainVC: KMMainViewController?
+//    var mainVC: KMMainViewController?
     
     var listView : CPDFListView?
     
@@ -162,15 +162,15 @@ class KMPDFViewPanelSetViewController: NSViewController {
     }
     
     @IBAction func singlePageAction(_ sender: Any) {
-        mainVC?.singlePageScreen(isSinglePage: true, doublePagesScreen: false)
+//        mainVC?.singlePageScreen(isSinglePage: true, doublePagesScreen: false)
     }
     
     @IBAction func verticalSplitAction(_ sender: Any) {
-        mainVC?.singlePageScreen(isSinglePage: false, doublePagesScreen: false)
+//        mainVC?.singlePageScreen(isSinglePage: false, doublePagesScreen: false)
     }
     
     @IBAction func horizontalSplitAction(_ sender: Any) {
-        mainVC!.singlePageScreen(isSinglePage: false, doublePagesScreen: true)
+//        mainVC!.singlePageScreen(isSinglePage: false, doublePagesScreen: true)
     }
     
     

+ 3 - 3
PDF Office/PDF Office/Class/Preference/Controller/KMPreferenceGeneralController.swift

@@ -164,7 +164,7 @@ class KMPreferenceGeneralController: NSViewController {
         
         self.saveFileStepper.value = Double(KMPreferenceManager.shared.autoSavePerNumberMinute)
         
-        if (KMPreferenceManager.shared.closeFilePromptType == 0) {
+        if (KMPreferenceManager.shared.closeFilePromptType == .promp) {
             self.selectCloseFileRadio(self.closeFilePopupPromptRadio)
         } else {
             self.selectCloseFileRadio(self.closeFileNoPromptRadio)
@@ -199,11 +199,11 @@ class KMPreferenceGeneralController: NSViewController {
         if (sender.isEqual(to: self.closeFilePopupPromptRadio)) {
             self.selectCloseFileRadio(sender)
             
-            KMPreferenceManager.shared.closeFilePromptType = 0
+            KMPreferenceManager.shared.closeFilePromptType = .promp
         } else if (sender.isEqual(to: self.closeFileNoPromptRadio)) {
             self.selectCloseFileRadio(sender)
             
-            KMPreferenceManager.shared.closeFilePromptType = 1
+            KMPreferenceManager.shared.closeFilePromptType = .noPromp
         } else if (sender.isEqual(to: self.openImageFileAutoRadio)) {
             self.selectOpenImageFileRadio(sender)
             

+ 13 - 0
PDF Office/PDF Office/Class/Preference/Tools/KMPreferenceEnum.swift

@@ -0,0 +1,13 @@
+//
+//  KMPreferenceEnum.swift
+//  PDF Office
+//
+//  Created by tangchao on 2023/3/13.
+//
+
+import Foundation
+
+enum KMPreferenceCloseFilePromptType: Int {
+    case promp = 0
+    case noPromp = 1
+}

+ 19 - 3
PDF Office/PDF Office/Class/Preference/Tools/KMPreferenceManager.swift

@@ -459,12 +459,19 @@ extension KMPreferenceManager {
         }
     }
     
-    var closeFilePromptType: Int {
+    var closeFilePromptType: KMPreferenceCloseFilePromptType {
         get {
-            return self.getData(forKey: KMCloseFilePromptTypeKey) as! Int
+            let type: Int? = self.getData(forKey: KMCloseFilePromptTypeKey) as? Int
+            if (type != nil && type! == 1) { // 无提示,直接保存
+                return .noPromp
+            }
+            
+            return .promp
         }
         set {
-            let _ = self.setData(data: newValue, forKey: KMCloseFilePromptTypeKey)
+            if (newValue == .promp || newValue == .noPromp) {
+                let _ = self.setData(data: newValue.rawValue, forKey: KMCloseFilePromptTypeKey)
+            }
         }
     }
     
@@ -749,3 +756,12 @@ extension KMPreferenceManager {
         }
     }
 }
+
+// MARK: -
+// MARK: Qiuck
+
+extension KMPreferenceManager {
+    internal func closeFileIsPrompt() -> Bool {
+        return self.closeFilePromptType == .promp
+    }
+}