KMPreferenceCommon.swift 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // KMPreferenceCommon.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2024/1/16.
  6. //
  7. import Foundation
  8. // general
  9. public let KMUserNameKey = "SKUserName"
  10. public let KMReopenLastOpenFilesKey = "SKReopenLastOpenFiles"
  11. public let KMOpenDocumentInTabKey = "KMOpenDocumentInTab"
  12. public let KMInitialWindowSizeOptionKey = "SKInitialWindowSizeOption"
  13. public let KMOpenContentsPaneOnlyForTOCKey = "SKOpenContentsPaneOnlyForTOC"
  14. public let KMRememberSnapshotsKey = "SKRememberSnapshots"
  15. public let KMDefaultPDFDisplaySettingsKey = "SKDefaultPDFDisplaySettings"
  16. public let KMDefaultFullScreenPDFDisplaySettingsKey = "SKDefaultFullScreenPDFDisplaySettings"
  17. public let KMAutoSaveSkimNotesKey = "SKAutoSaveSkimNotes"
  18. public let KMSnapshotsOnTopKey = "SKSnapshotsOnTop"
  19. public let KMSavePasswordOptionKey = "SKSavePasswordOption"
  20. // display
  21. public let KMThumbnailSizeKey = "SKThumbnailSize"
  22. public let KMSnapshotThumbnailSizeKey = "SKSnapshotThumbnailSize"
  23. public let KMTableFontSizeKey = "SKTableFontSize"
  24. public let KMGreekingThresholdKey = "SKGreekingThreshold"
  25. public let KMShouldAntiAliasKey = "SKShouldAntiAlias"
  26. public let KMBackgroundColorKey = "SKBackgroundColor"
  27. public let KMFullScreenBackgroundColorKey = "SKFullScreenBackgroundColor"
  28. public let KMReadingBarColorKey = "SKReadingBarColor"
  29. public let KMReadingBarInvertKey = "SKReadingBarInvert"
  30. func KMPreferenceKeyToCKey(pKey: KMPreferenceKey) -> String? {
  31. return nil
  32. }
  33. // MARK: - NSUserDefault key 与 偏好设置 key 相互转换
  34. func KMPreferenceKeyToUDKey(pKey: KMPreferenceKey) -> String? {
  35. // general
  36. if pKey == KMPreference.generalAuthorNameKey {
  37. return KMUserNameKey
  38. } else if pKey == KMPreference.openLastUnclosedDocumentWhenAppStartKey {
  39. return KMReopenLastOpenFilesKey
  40. } else if pKey == KMPreference.openDocumentTypeKey {
  41. return KMOpenDocumentInTabKey
  42. } else if pKey == KMPreference.openFileTypeKey {
  43. return KMInitialWindowSizeOptionKey
  44. } else if pKey == KMPreference.showLeftSideBarKey {
  45. return KMOpenContentsPaneOnlyForTOCKey
  46. } else if pKey == KMPreference.rememberSnapshotKey {
  47. return KMRememberSnapshotsKey
  48. } else if pKey == KMPreference.autoSaveNoteBackupKey {
  49. return KMAutoSaveSkimNotesKey
  50. } else if pKey == KMPreference.keepSnapshotWindowToTopKey {
  51. return KMSnapshotsOnTopKey
  52. } else if pKey == KMPreference.savePasswordTypeKey {
  53. return KMSavePasswordOptionKey
  54. }
  55. // display
  56. else if pKey == KMPreference.thumbPageSizeKey {
  57. return KMThumbnailSizeKey
  58. } else if pKey == KMPreference.thumbSnapshotSizeKey {
  59. return KMSnapshotThumbnailSizeKey
  60. } else if pKey == KMPreference.outlineFontSizeKey {
  61. return KMTableFontSizeKey
  62. } else if pKey == KMPreference.greekThresholdKey {
  63. return KMGreekingThresholdKey
  64. } else if pKey == KMPreference.antiAliasTextKey {
  65. return KMShouldAntiAliasKey
  66. } else if pKey == KMPreference.displayBackgroundNormalColorKey {
  67. return KMBackgroundColorKey
  68. } else if pKey == KMPreference.displayBackgroundFullScreenColorKey {
  69. return KMFullScreenBackgroundColorKey
  70. } else if pKey == KMPreference.readBarColorKey {
  71. return KMReadingBarColorKey
  72. } else if pKey == KMPreference.invertBarKey {
  73. return KMReadingBarInvertKey
  74. }
  75. return nil
  76. }
  77. func KMPreferenceKeyFromUDKey(udKey: String) -> KMPreferenceKey? {
  78. // general
  79. if udKey == KMUserNameKey {
  80. return KMPreference.generalAuthorNameKey
  81. } else if udKey == KMReopenLastOpenFilesKey {
  82. return KMPreference.openLastUnclosedDocumentWhenAppStartKey
  83. } else if udKey == KMOpenDocumentInTabKey {
  84. return KMPreference.openDocumentTypeKey
  85. } else if udKey == KMInitialWindowSizeOptionKey {
  86. return KMPreference.openFileTypeKey
  87. } else if udKey == KMOpenContentsPaneOnlyForTOCKey {
  88. return KMPreference.showLeftSideBarKey
  89. } else if udKey == KMRememberSnapshotsKey {
  90. return KMPreference.rememberSnapshotKey
  91. } else if udKey == KMAutoSaveSkimNotesKey {
  92. return KMPreference.autoSaveNoteBackupKey
  93. } else if udKey == KMSnapshotsOnTopKey {
  94. return KMPreference.keepSnapshotWindowToTopKey
  95. } else if udKey == KMSavePasswordOptionKey {
  96. return KMPreference.savePasswordTypeKey
  97. }
  98. // display
  99. else if udKey == KMThumbnailSizeKey {
  100. return KMPreference.thumbPageSizeKey
  101. } else if udKey == KMSnapshotThumbnailSizeKey {
  102. return KMPreference.thumbSnapshotSizeKey
  103. } else if udKey == KMTableFontSizeKey {
  104. return KMPreference.outlineFontSizeKey
  105. } else if udKey == KMGreekingThresholdKey {
  106. return KMPreference.greekThresholdKey
  107. } else if udKey == KMShouldAntiAliasKey {
  108. return KMPreference.antiAliasTextKey
  109. } else if udKey == KMBackgroundColorKey {
  110. return KMPreference.displayBackgroundNormalColorKey
  111. } else if udKey == KMFullScreenBackgroundColorKey {
  112. return KMPreference.displayBackgroundFullScreenColorKey
  113. } else if udKey == KMReadingBarColorKey {
  114. return KMPreference.readBarColorKey
  115. } else if udKey == KMReadingBarInvertKey {
  116. return KMPreference.invertBarKey
  117. }
  118. return nil
  119. }