feat: add AppSettings

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 15:32:30 +02:00
co-authored by Claude Sonnet 5.5
parent 6f491accf1
commit fbc90cbd12
2 changed files with 83 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import Combine
import Foundation
/// User preferences, persisted in UserDefaults as soon as a value changes.
public final class AppSettings: ObservableObject {
public static let defaultModelVariant = "large-v3-v20240930_turbo"
enum Key {
static let hotkey = "hotkeyID"
static let model = "modelVariant"
static let keepHistory = "keepHistory"
static let usePriming = "usePriming"
static let useCorrection = "useCorrection"
}
private let defaults: UserDefaults
/// `HotkeyBinding.id` of the key that has to be held.
@Published public var hotkeyID: String {
didSet { defaults.set(hotkeyID, forKey: Key.hotkey) }
}
@Published public var modelVariant: String {
didSet { defaults.set(modelVariant, forKey: Key.model) }
}
@Published public var keepHistory: Bool {
didSet { defaults.set(keepHistory, forKey: Key.keepHistory) }
}
/// Give the speech engine the dictionary words as context.
@Published public var usePriming: Bool {
didSet { defaults.set(usePriming, forKey: Key.usePriming) }
}
/// Apply the dictionary corrections after transcription.
@Published public var useCorrection: Bool {
didSet { defaults.set(useCorrection, forKey: Key.useCorrection) }
}
public init(defaults: UserDefaults = .standard) {
self.defaults = defaults
hotkeyID = defaults.string(forKey: Key.hotkey) ?? "fn"
modelVariant = defaults.string(forKey: Key.model) ?? Self.defaultModelVariant
keepHistory = defaults.object(forKey: Key.keepHistory) as? Bool ?? true
usePriming = defaults.object(forKey: Key.usePriming) as? Bool ?? true
useCorrection = defaults.object(forKey: Key.useCorrection) as? Bool ?? true
}
}