]> git.r.bdr.sh - rbdr/captura/blame - Captura/Presentation/Settings/AdvancedSettings.swift
Add AppleScript support
[rbdr/captura] / Captura / Presentation / Settings / AdvancedSettings.swift
CommitLineData
a4e80427 1import SwiftUI
377442f2 2import CloudStorage
a4e80427
RBR
3
4struct AdvancedSettings: View {
5
377442f2
RBR
6 @CloudStorage("backendUrl") var backendUrl: String = ""
7 @CloudStorage("backendFormat") var backendFormat: OutputFormatSetting = .gifOnly
8 @CloudStorage("keepFiles") var keepFiles = true
9 @CloudStorage("allowURLAutomation") var allowURLAutomation = false
ba17de89 10 @State var showConfirmation = false
a4e80427 11
377442f2
RBR
12 private var anyState: String { "\(backendUrl), \(backendFormat), \(keepFiles), \(allowURLAutomation)" }
13
c9b9e1d6
RBR
14 var parsedBackendUrl: URL? {
15 URL(string: backendUrl)
16 }
17
a4e80427
RBR
18 var body: some View {
19 Form {
c9b9e1d6 20 VStack (alignment: .center) {
ba17de89
RBR
21 Section {
22 VStack (alignment: .center) {
23 LabeledContent("Backend URL") {
24 TextField("", text: $backendUrl).font(.body)
25 }.font(.headline)
26 .help("The Backend URL to use. If this is empty, no backend will be used and the options below won't have an effect.")
377442f2 27 Picker(selection: $backendFormat, label: Text("Backend Format").font(.headline)) {
ba17de89
RBR
28 Text("GIF")
29 .tag(OutputFormatSetting.gifOnly)
30 .padding(.horizontal, 4.0)
31 .padding(.vertical, 2.0)
32 Text("MP4")
33 .tag(OutputFormatSetting.mp4Only)
34 .padding(.horizontal, 4.0)
35 .padding(.vertical, 2.0)
36 }
37 .pickerStyle(.radioGroup)
38 .disabled(parsedBackendUrl == nil)
39 .help("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.")
40 Toggle("Keep Local Files", isOn: $keepFiles)
41 .font(.headline)
42 .disabled(parsedBackendUrl == nil)
43 .padding(.vertical, 8.0)
44 .help("If this is off, locally generated recordings will be deleted immediately after a successful upload.")
45 HStack {
46 Text("These settings can break things! Please make sure you understand how to use them before enabling.")
47 .lineLimit(3...10)
48 Link(destination: URL(string: "https://captura.tranquil.systems")!) {
49 Image(systemName: "info.circle")
50 }.buttonStyle(.borderless)
51 }
52 }
c9b9e1d6 53 }
ba17de89
RBR
54 Divider().padding(.vertical, 8.0)
55 Section {
56 Toggle("Allow URL Based Automation", isOn: $allowURLAutomation)
57 .font(.headline)
58 .padding(.vertical, 8.0)
59 .help("If this is on, the app can be controlled remotely using the captura: URL scheme.")
60 .confirmationDialog("This may be dangerous and can allow websites to remotely record your computer.", isPresented: $showConfirmation, actions: {
61 Button("I Understand The Risk", role: .destructive) {
62 showConfirmation = false
63 }
64 Button("Cancel", role: .cancel) {
65 showConfirmation = false
66 allowURLAutomation = false
67 }
68 })
69 .onChange(of: allowURLAutomation, perform: { newValue in
70 if newValue {
71 showConfirmation = true
72 }
73 })
a4e80427 74 }
c9b9e1d6 75 Spacer()
a4e80427
RBR
76 }
77 }
377442f2
RBR
78 .onChange(of: anyState) { _ in
79 NotificationCenter.default.post(name: .reloadConfiguration, object: nil, userInfo: nil)
80 }
a4e80427
RBR
81 }
82}
83
84#Preview {
85 OutputSettings()
86}