Major improvements and bug fixes for v1.1.0
Features: - Add auto-enable on startup based on config - Add enabled state persistence in config.json - Add limitations notice in GUI menu - Simplify logging to single file (uskey.log) - Change "Open Logs Folder" to "Open Config Folder" Bug Fixes: - Fix GUI status display mismatch on startup - Fix first toggle click not working issue - Revert password field changes that caused key blocking UI Changes: - Add ⚠️ emoji to "About Limitations" menu item - Remove button action to fix menu refresh 🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -54,10 +54,12 @@ struct MappingConfig: Codable {
|
||||
struct Config: Codable {
|
||||
let log: LogConfig
|
||||
let mapping: MappingConfig
|
||||
let enabled: Bool
|
||||
|
||||
init(log: LogConfig = LogConfig(), mapping: MappingConfig = MappingConfig()) {
|
||||
init(log: LogConfig = LogConfig(), mapping: MappingConfig = MappingConfig(), enabled: Bool = true) {
|
||||
self.log = log
|
||||
self.mapping = mapping
|
||||
self.enabled = enabled
|
||||
}
|
||||
|
||||
static func load(from path: String) throws -> Config {
|
||||
@@ -67,13 +69,21 @@ struct Config: Codable {
|
||||
return try decoder.decode(Config.self, from: data)
|
||||
}
|
||||
|
||||
static func save(_ config: Config, to path: String) throws {
|
||||
let encoder = JSONEncoder()
|
||||
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
|
||||
let data = try encoder.encode(config)
|
||||
try data.write(to: URL(fileURLWithPath: path))
|
||||
}
|
||||
|
||||
static func createDefault(at path: String) throws {
|
||||
let defaultConfig = Config(
|
||||
log: LogConfig(level: .info),
|
||||
mapping: MappingConfig(mappings: [
|
||||
"backslash2backspace": KeyMapping(from: 42, to: 51),
|
||||
"backspace2backslash": KeyMapping(from: 51, to: 42)
|
||||
])
|
||||
]),
|
||||
enabled: true
|
||||
)
|
||||
|
||||
let encoder = JSONEncoder()
|
||||
@@ -90,4 +100,4 @@ struct Config: Codable {
|
||||
|
||||
return configDir.appendingPathComponent("config.json").path
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user