2 Copyright (C) 2024 Rubén Beltrán del Río
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://captura.tranquil.systems.
19 struct AdvancedSettings: View {
21 @AppStorage("backendUrl") var backendUrl: String = ""
22 @AppStorage("backendFormat") var backendFormat: OutputFormatSetting = .gifOnly
23 @AppStorage("keepFiles") var keepFiles = true
24 @AppStorage("allowURLAutomation") var allowURLAutomation = false
25 @State var showConfirmation = false
27 private var anyState: String {
28 "\(backendUrl), \(backendFormat), \(keepFiles), \(allowURLAutomation)"
31 var parsedBackendUrl: URL? {
32 URL(string: backendUrl)
37 VStack(alignment: .center) {
39 VStack(alignment: .center) {
40 LabeledContent("Backend URL") {
41 TextField("", text: $backendUrl).font(.body)
44 "The Backend URL to use. If this is empty, no backend will be used and the options below won't have an effect."
46 Picker(selection: $backendFormat, label: Text("Backend Format").font(.headline)) {
48 .tag(OutputFormatSetting.gifOnly)
49 .padding(.horizontal, 4.0)
50 .padding(.vertical, 2.0)
52 .tag(OutputFormatSetting.mp4Only)
53 .padding(.horizontal, 4.0)
54 .padding(.vertical, 2.0)
56 .pickerStyle(.radioGroup)
57 .disabled(parsedBackendUrl == nil)
59 "The format picked here will be generated regardless of what option you pick in the output settings. It doesn't prevent files from being rendered."
61 Toggle("Keep Local Files", isOn: $keepFiles)
63 .disabled(parsedBackendUrl == nil)
64 .padding(.vertical, 8.0)
66 "If this is off, locally generated recordings will be deleted immediately after a successful upload."
70 "These settings can break things! Please make sure you understand how to use them before enabling."
73 Link(destination: URL(string: "https://captura.tranquil.systems")!) {
74 Image(systemName: "info.circle")
75 }.buttonStyle(.borderless)
79 Divider().padding(.vertical, 8.0)
81 Toggle("Allow URL Based Automation", isOn: $allowURLAutomation)
83 .padding(.vertical, 8.0)
85 "If this is on, the app can be controlled remotely using the captura: URL scheme."
88 "This may be dangerous and can allow websites to remotely record your computer.",
89 isPresented: $showConfirmation,
91 Button("I Understand The Risk", role: .destructive) {
92 showConfirmation = false
94 Button("Cancel", role: .cancel) {
95 showConfirmation = false
96 allowURLAutomation = false
101 of: allowURLAutomation,
102 perform: { newValue in
104 showConfirmation = true
111 .onChange(of: anyState) { _ in
112 NotificationCenter.default.post(name: .reloadConfiguration, object: nil, userInfo: nil)