Browse Source

综合-左边栏补充有大纲时显示大纲的设置

tangchao 1 year ago
parent
commit
5af72e0d88

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


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

@@ -128,7 +128,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "534"
             endingLineNumber = "534"
-            landmarkName = "editOutlineUI(editVC:)"
+            landmarkName = "outlineView(_:numberOfChildrenOfItem:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
@@ -306,6 +306,38 @@
             endingLineNumber = "174"
             landmarkName = "KMPDFViewCurrentPageDidChangedNotification(notification:)"
             landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "462F9B18-B9C4-4AFB-AEAA-DD66109150F8 - ee9cc519f47a1056"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Office.KMThumbnailViewController.KMPDFViewCurrentPageDidChangedNotification(notification: __C.NSNotification) -&gt; ()"
+                  moduleName = "PDF Office"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Office/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMThumbnailViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "174"
+                  endingLineNumber = "174"
+                  offsetFromSymbolStart = "90">
+               </Location>
+               <Location
+                  uuid = "462F9B18-B9C4-4AFB-AEAA-DD66109150F8 - ee9cc519f47a1056"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Office.KMThumbnailViewController.KMPDFViewCurrentPageDidChangedNotification(notification: __C.NSNotification) -&gt; ()"
+                  moduleName = "PDF Office"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Office/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMThumbnailViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "174"
+                  endingLineNumber = "174"
+                  offsetFromSymbolStart = "151">
+               </Location>
+            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy

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

@@ -256,6 +256,18 @@ import Cocoa
         if (KMPreferenceManager.shared.leftSideNeedCloseWhenOpenFile()) {
             return
         }
+        if (KMPreferenceManager.shared.leftSideDisplayType == .showOutlineIfHas) {
+            let outlineRoot = self.listView.document.outlineRoot()
+            let hasOutline = (outlineRoot != nil && outlineRoot!.numberOfChildren > 0)
+            if (hasOutline == false) {
+                return
+            }
+            
+            DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
+                self.leftSideViewController.refreshMethodType(methodType: .Outline)
+            }
+            return
+        }
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
             let selectedIndex = UserDefaults.standard.integer(forKey: "KMBOTASelectedIndexKey")
             let thumai = KMLeftMethodMode()

+ 12 - 15
PDF Office/PDF Office/Class/Preference/Controller/KMPreferenceDisplayController.swift

@@ -115,14 +115,14 @@ class KMPreferenceDisplayController: NSViewController {
             comboBox?.delegate = self
         }
         
-        for radio in [self.putAwayRadio, self.rememberLastSelectionRadio,
+        for radio in [self.putAwayRadio, self.rememberLastSelectionRadio, self.showOutlineCheck,
                       self.autoExpandRadio, self.manualExpandRadio,
                       self.autoDisplayRadio, self.alwaysShowRadio, self.neverShowRadio] {
             radio?.target = self
             radio?.action = #selector(radioAction)
         }
         
-        for check in [self.showOutlineCheck, self.hightlightedFormsLabel,self.highlightedLinksCheck] {
+        for check in [self.hightlightedFormsLabel,self.highlightedLinksCheck] {
             check?.target = self
             check?.action = #selector(checkAction)
         }
@@ -197,18 +197,15 @@ class KMPreferenceDisplayController: NSViewController {
             self.zoomScaleComboBox.stringValue = self.viewZoomScaleTypes[value2.rawValue]
         }
         
-        if (KMPreferenceManager.shared.leftSideDisplayType == .closeWhenOpenFile) {
+        let leftSideDisplayType = KMPreferenceManager.shared.leftSideDisplayType
+        if (leftSideDisplayType == .closeWhenOpenFile) {
             self.selectLeftSideRadio(self.putAwayRadio)
-        } else {
+        } else if (leftSideDisplayType == .openAppSaveLastSelect) {
             self.selectLeftSideRadio(self.rememberLastSelectionRadio)
+        } else if (leftSideDisplayType == .showOutlineIfHas) {
+            self.selectLeftSideRadio(self.showOutlineCheck)
         }
         
-//        if (KMPreferenceManager.shared.showOutlineList) {
-//            self.showOutlineCheck.state = .on
-//        } else {
-//            self.showOutlineCheck.state = .off
-//        }
-        
         if (KMPreferenceManager.shared.propertyPanelExpandType == .auto) {
             self.selectDisplayRadio(self.autoExpandRadio)
         } else {
@@ -251,6 +248,10 @@ class KMPreferenceDisplayController: NSViewController {
             self.selectLeftSideRadio(sender)
             
             KMPreferenceManager.shared.leftSideDisplayType = .openAppSaveLastSelect
+        } else if (self.showOutlineCheck.isEqual(sender)) {
+            self.selectLeftSideRadio(sender)
+            
+            KMPreferenceManager.shared.leftSideDisplayType = .showOutlineIfHas
         } else if (self.autoExpandRadio.isEqual(sender)) {
             self.selectDisplayRadio(sender)
             
@@ -275,11 +276,7 @@ class KMPreferenceDisplayController: NSViewController {
     }
     
     @objc private func checkAction(sender: NSButton) {
-        if (self.showOutlineCheck.isEqual(sender)) {
-            self.selectLeftSideRadio(sender)
-            
-            KMPreferenceManager.shared.showOutlineList = sender.state == .on
-        } else if (self.hightlightedFormsLabel.isEqual(sender)) {
+        if (self.hightlightedFormsLabel.isEqual(sender)) {
             KMPreferenceManager.shared.highlightForms = sender.state == .on
         } else if (self.highlightedLinksCheck.isEqual(sender)) {
             let _ = KMPreferenceManager.shared.setData(data: sender.state == .on, forKey: KMHighlightLinksKey)

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

@@ -29,6 +29,8 @@ enum KMPreferenceViewSetting: String {
 enum KMPreferenceLeftSideDisplayType: Int {
     case closeWhenOpenFile = 0 // 打开文件时收起
     case openAppSaveLastSelect // 打开App记住上次选择
+    
+    case showOutlineIfHas // 显示大纲列表,如果有
 }
 
 enum KMPreferencePropertyPanelExpandType: Int {

+ 11 - 9
PDF Office/PDF Office/Class/Preference/Tools/KMPreferenceManager.swift

@@ -613,24 +613,26 @@ extension KMPreferenceManager {
                 return .closeWhenOpenFile
             } else if (type! == 1) {
                 return .openAppSaveLastSelect
+            } else if (type! == 2) {
+                return .showOutlineIfHas
             }
             return .closeWhenOpenFile
         }
         set {
-            if (newValue == .closeWhenOpenFile || newValue == .openAppSaveLastSelect) {
+            if (newValue == .closeWhenOpenFile || newValue == .openAppSaveLastSelect || newValue == .showOutlineIfHas) {
                 let _ = self.setData(data: newValue.rawValue, forKey: KMLeftSideDisplayTypeKey)
             }
         }
     }
     
-    var showOutlineList: Bool {
-        get {
-            return self.getData(forKey: KMShowOutlineListKey) as! Bool
-        }
-        set {
-            let _ = self.setData(data: newValue, forKey: KMShowOutlineListKey)
-        }
-    }
+//    var showOutlineList: Bool {
+//        get {
+//            return self.getData(forKey: KMShowOutlineListKey) as! Bool
+//        }
+//        set {
+//            let _ = self.setData(data: newValue, forKey: KMShowOutlineListKey)
+//        }
+//    }
     
 //    var leftSideExpandType: Int {
 //        get {