// // KMPreferenceCommon.swift // PDF Reader Pro // // Created by tangchao on 2024/1/16. // import Foundation public let KMUserNameKey = "SKUserName" public let KMReopenLastOpenFilesKey = "SKReopenLastOpenFilesKey" public let KMOpenDocumentInTabKey = "KMOpenDocumentInTab" public let KMInitialWindowSizeOptionKey = "SKInitialWindowSizeOptionKey" public let KMOpenContentsPaneOnlyForTOCKey = "SKOpenContentsPaneOnlyForTOCKey" public let KMRememberSnapshotsKey = "SKRememberSnapshotsKey" public let KMDefaultPDFDisplaySettingsKey = "SKDefaultPDFDisplaySettingsKey" public let KMDefaultFullScreenPDFDisplaySettingsKey = "SKDefaultFullScreenPDFDisplaySettings" public let KMAutoSaveSkimNotesKey = "SKAutoSaveSkimNotesKey" public let KMSnapshotsOnTopKey = "SKSnapshotsOnTopKey" public let KMSavePasswordOptionKey = "SKSavePasswordOptionKey" func KMPreferenceKeyToCKey(pKey: KMPreferenceKey) -> String? { // freeText if pKey == KMPreference.freeTextNoteLineWidthKey { return CFreeTextNoteLineWidthKey } else if pKey == KMPreference.freeTextNoteLineStyleKey { return CFreeTextNoteLineStyleKey } else if pKey == KMPreference.freeTextNoteDashPatternKey { return CFreeTextNoteDashPatternKey } // Line else if pKey == KMPreference.lineNoteLineWidthKey { return CLineNoteLineWidthKey } else if pKey == KMPreference.lineNoteLineStyleKey { return CLineNoteLineStyleKey } else if pKey == KMPreference.lineNoteDashPatternKey { return CLineNoteDashPatternKey } else if pKey == KMPreference.lineNoteStartLineStyleKey { return CLineNoteStartLineStyleKey } else if pKey == KMPreference.lineNoteEndLineStyleKey { return CLineNoteEndLineStyleKey } // freehand else if pKey == KMPreference.inkNoteLineWidthKey { return CInkNoteLineWidthKey } else if pKey == KMPreference.inkNoteLineStyleKey { return CInkNoteLineStyleKey } else if pKey == KMPreference.inkNoteDashPatternKey { return CInkNoteDashPatternKey } // circle else if pKey == KMPreference.circleNoteLineWidthKey { return CCircleNoteLineWidthKey } else if pKey == KMPreference.circleNoteLineStyleKey { return CCircleNoteLineStyleKey } else if pKey == KMPreference.circleNoteDashPatternKey { return CCircleNoteDashPatternKey } // rect else if pKey == KMPreference.squareNoteLineWidthKey { return CSquareNoteLineWidthKey } else if pKey == KMPreference.squareNoteLineStyleKey { return CSquareNoteLineStyleKey } else if pKey == KMPreference.squareNoteDashPatternKey { return CSquareNoteDashPatternKey } return nil } // MARK: - NSUserDefault key 与 偏好设置 key 相互转换 func KMPreferenceKeyToUDKey(pKey: KMPreferenceKey) -> String? { // general if pKey == KMPreference.generalAuthorNameKey { return KMUserNameKey } else if pKey == KMPreference.openLastUnclosedDocumentWhenAppStartKey { return KMReopenLastOpenFilesKey } else if pKey == KMPreference.openDocumentTypeKey { return KMOpenDocumentInTabKey } else if pKey == KMPreference.openFileTypeKey { return KMInitialWindowSizeOptionKey } else if pKey == KMPreference.showLeftSideBarKey { return KMOpenContentsPaneOnlyForTOCKey } else if pKey == KMPreference.rememberSnapshotKey { return KMRememberSnapshotsKey } else if pKey == KMPreference.autoSaveNoteBackupKey { return KMAutoSaveSkimNotesKey } else if pKey == KMPreference.keepSnapshotWindowToTopKey { return KMSnapshotsOnTopKey } else if pKey == KMPreference.savePasswordTypeKey { return KMSavePasswordOptionKey } return nil } func KMPreferenceKeyFromUDKey(udKey: String) -> KMPreferenceKey? { // general if udKey == KMUserNameKey { return KMPreference.generalAuthorNameKey } else if udKey == KMReopenLastOpenFilesKey { return KMPreference.openLastUnclosedDocumentWhenAppStartKey } else if udKey == KMOpenDocumentInTabKey { return KMPreference.openDocumentTypeKey } else if udKey == KMInitialWindowSizeOptionKey { return KMPreference.openFileTypeKey } else if udKey == KMOpenContentsPaneOnlyForTOCKey { return KMPreference.showLeftSideBarKey } else if udKey == KMRememberSnapshotsKey { return KMPreference.rememberSnapshotKey } else if udKey == KMAutoSaveSkimNotesKey { return KMPreference.autoSaveNoteBackupKey } else if udKey == KMSnapshotsOnTopKey { return KMPreference.keepSnapshotWindowToTopKey } else if udKey == KMSavePasswordOptionKey { return KMPreference.savePasswordTypeKey } return nil }