123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- //
- // 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
- }
|