]> git.r.bdr.sh - rbdr/captura/blobdiff - Captura/Data/CapturaSettings.swift
Add license and contributing
[rbdr/captura] / Captura / Data / CapturaSettings.swift
index 2d0e70b63bfe80babfecbcbd67fba88a938eba72..c8af096b40e37f96367921e7271a4fe965989bc9 100644 (file)
@@ -1,25 +1,41 @@
+/*
+ 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 {
   static var frameRate: Int {
     get {
 import Foundation
 
 struct CapturaSettings {
   static var frameRate: Int {
     get {
-      if NSUbiquitousKeyValueStore.default.object(forKey: "frameRate") == nil {
+      if UserDefaults.standard.object(forKey: "frameRate") == nil {
         return 10
       } else {
         return 10
       } else {
-        return min(10, max(4, Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "frameRate"))))
+        return min(10, max(4, UserDefaults.standard.integer(forKey: "frameRate")))
       }
     }
     set {
       }
     }
     set {
-      NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "frameRate")
+      UserDefaults.standard.setValue(newValue, forKey: "frameRate")
     }
   }
   
   static var outputFormats: OutputFormatSetting {
     get {
     }
   }
   
   static var outputFormats: OutputFormatSetting {
     get {
-      OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "outputFormats"))) ?? .all
+      OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "outputFormats")) ?? .all
     }
     set {
     }
     set {
-      NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "outputFormats")
+      UserDefaults.standard.setValue(newValue.rawValue, forKey: "outputFormats")
     }
   }
   
     }
   }
   
@@ -45,44 +61,44 @@ struct CapturaSettings {
   
   static var backend: URL? {
     get {
   
   static var backend: URL? {
     get {
-      if let url = NSUbiquitousKeyValueStore.default.string(forKey: "backendUrl") {
+      if let url = UserDefaults.standard.string(forKey: "backendUrl") {
         return URL(string: url)
       }
       return nil
     }
     set {
         return URL(string: url)
       }
       return nil
     }
     set {
-      NSUbiquitousKeyValueStore.default.setValue(newValue?.absoluteString, forKey: "backendUrl")
+      UserDefaults.standard.setValue(newValue?.absoluteString, forKey: "backendUrl")
     }
   }
   
   static var backendFormat: OutputFormatSetting {
     get {
     }
   }
   
   static var backendFormat: OutputFormatSetting {
     get {
-      OutputFormatSetting(rawValue: Int(NSUbiquitousKeyValueStore.default.longLong(forKey: "backendFormat"))) ?? .gifOnly
+      OutputFormatSetting(rawValue: UserDefaults.standard.integer(forKey: "backendFormat")) ?? .gifOnly
     }
     set {
     }
     set {
-      NSUbiquitousKeyValueStore.default.setValue(newValue.rawValue, forKey: "backendFormat")
+      UserDefaults.standard.setValue(newValue.rawValue, forKey: "backendFormat")
     }
   }
   
   static var shouldKeepLocalFiles: Bool {
     get {
     }
   }
   
   static var shouldKeepLocalFiles: Bool {
     get {
-      if NSUbiquitousKeyValueStore.default.object(forKey: "keepFiles") == nil {
+      if UserDefaults.standard.object(forKey: "keepFiles") == nil {
         return true
       } else {
         return true
       } else {
-        return NSUbiquitousKeyValueStore.default.bool(forKey: "keepFiles")
+        return UserDefaults.standard.bool(forKey: "keepFiles")
       }
     }
     set {
       }
     }
     set {
-      NSUbiquitousKeyValueStore.default.set(newValue, forKey: "keepFiles")
+      UserDefaults.standard.set(newValue, forKey: "keepFiles")
     }
   }
   
   static var shouldAllowURLAutomation: Bool {
     get {
     }
   }
   
   static var shouldAllowURLAutomation: Bool {
     get {
-      NSUbiquitousKeyValueStore.default.bool(forKey: "allowURLAutomation")
+      UserDefaults.standard.bool(forKey: "allowURLAutomation")
     }
     set {
     }
     set {
-      NSUbiquitousKeyValueStore.default.setValue(newValue, forKey: "allowURLAutomation")
+      UserDefaults.standard.setValue(newValue, forKey: "allowURLAutomation")
     }
   }
   
     }
   }