X-Git-Url: https://git.r.bdr.sh/rbdr/captura/blobdiff_plain/e42019cd38b59e757f6036b132614a471d4cf6fe..47eb1128eb930279d0fcf2e836d78372ac7ef5c3:/Captura/Data/CapturaSettings.swift?ds=inline diff --git a/Captura/Data/CapturaSettings.swift b/Captura/Data/CapturaSettings.swift index 578d17c..bfaa1ce 100644 --- a/Captura/Data/CapturaSettings.swift +++ b/Captura/Data/CapturaSettings.swift @@ -1,3 +1,19 @@ +/* + Copyright (C) 2024 Rubén Beltrán del Río + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see https://captura.tranquil.systems. + */ import Foundation struct CapturaSettings { @@ -13,7 +29,7 @@ struct CapturaSettings { UserDefaults.standard.setValue(newValue, forKey: "frameRate") } } - + static var outputFormats: OutputFormatSetting { get { OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "outputFormats")) ?? .all @@ -22,27 +38,27 @@ struct CapturaSettings { UserDefaults.standard.setValue(newValue.rawValue, forKey: "outputFormats") } } - + static var shouldSaveMp4: Bool { outputFormats.shouldSaveMp4() || (shouldUseBackend && shouldUploadMp4) } - + static var shouldSaveGif: Bool { outputFormats.shouldSaveGif() || (shouldUseBackend && shouldUploadGif) } - + static var shouldUploadGif: Bool { backendFormat.shouldSaveGif() } - + static var shouldUploadMp4: Bool { backendFormat.shouldSaveMp4() } - + static var shouldUseBackend: Bool { backend != nil } - + static var backend: URL? { get { if let url = UserDefaults.standard.string(forKey: "backendUrl") { @@ -54,16 +70,17 @@ struct CapturaSettings { UserDefaults.standard.setValue(newValue?.absoluteString, forKey: "backendUrl") } } - + static var backendFormat: OutputFormatSetting { get { - OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .gifOnly + OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) + ?? .gifOnly } set { UserDefaults.standard.setValue(newValue.rawValue, forKey: "backendFormat") } } - + static var shouldKeepLocalFiles: Bool { get { if UserDefaults.standard.object(forKey: "keepFiles") == nil { @@ -76,7 +93,7 @@ struct CapturaSettings { UserDefaults.standard.set(newValue, forKey: "keepFiles") } } - + static var shouldAllowURLAutomation: Bool { get { UserDefaults.standard.bool(forKey: "allowURLAutomation") @@ -85,7 +102,7 @@ struct CapturaSettings { UserDefaults.standard.setValue(newValue, forKey: "allowURLAutomation") } } - + static func apply(_ config: ConfigureAction) { if let fps = config.fps { frameRate = fps