From 6a7e20d0fda8425819bf10e527b47d5ee09f842e Mon Sep 17 00:00:00 2001 From: Alin Lupascu Date: Mon, 8 Jul 2024 11:09:43 -0600 Subject: [PATCH] v1.6 --- Viz.xcodeproj/project.pbxproj | 10 +- Viz/MainView.swift | 269 +++++++++++++++++----------------- Viz/VizApp.swift | 2 +- 3 files changed, 140 insertions(+), 141 deletions(-) diff --git a/Viz.xcodeproj/project.pbxproj b/Viz.xcodeproj/project.pbxproj index c4fb7b0..721781a 100644 --- a/Viz.xcodeproj/project.pbxproj +++ b/Viz.xcodeproj/project.pbxproj @@ -20,7 +20,6 @@ C73944B92BC4499700EE7EBF /* AboutCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C73944B82BC4499700EE7EBF /* AboutCommand.swift */; }; C73944BD2BC449C800EE7EBF /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C73944BB2BC449C800EE7EBF /* AboutView.swift */; }; C73944BE2BC449C800EE7EBF /* AboutWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C73944BC2BC449C800EE7EBF /* AboutWindow.swift */; }; - C766D28A2C34D0F100F51BB9 /* Builds in Resources */ = {isa = PBXBuildFile; fileRef = C766D2892C34D0F100F51BB9 /* Builds */; }; C76920112BC5EB5E00D23CEC /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C76920102BC5EB5E00D23CEC /* MainView.swift */; }; C783473E2C0E1B1400F4EE76 /* Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783473D2C0E1B1400F4EE76 /* Styles.swift */; }; C7E780DE2BC700060053B311 /* KeyboardShortcuts in Frameworks */ = {isa = PBXBuildFile; productRef = C7E780DD2BC700060053B311 /* KeyboardShortcuts */; }; @@ -181,7 +180,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C766D28A2C34D0F100F51BB9 /* Builds in Resources */, C7174CAF2BC0C14900DBEF75 /* printscreen.mp3 in Resources */, C7174C982BC06EE600DBEF75 /* Assets.xcassets in Resources */, ); @@ -342,7 +340,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; @@ -360,7 +358,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 1.6; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Viz; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -379,7 +377,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = ""; @@ -397,7 +395,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 1.6; PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Viz; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Viz/MainView.swift b/Viz/MainView.swift index 7d4997a..509e205 100644 --- a/Viz/MainView.swift +++ b/Viz/MainView.swift @@ -19,177 +19,178 @@ struct ContentView: View { @Environment(\.dismiss) private var dismiss var body: some View { - VisualEffectView(material: .hudWindow, blendingMode: .behindWindow) - .overlay{ - VStack(alignment: .center, spacing: 15) { +// VisualEffectView(material: .hudWindow, blendingMode: .behindWindow) +// .overlay{ +// +// +// } + VStack(alignment: .center, spacing: 15) { - Spacer() + Spacer() - HStack(spacing: 0) { + HStack(spacing: 0) { - Spacer() + Spacer() - Text("V I Z") - .font(.system(size: 18, design: .rounded)) - .bold() - .foregroundStyle( - LinearGradient( - colors: [.red, .purple, .blue], - startPoint: .leading, - endPoint: .trailing - ) - ) - .shadow(color: .black, radius: 2, x: 0, y: 0) + Text("V I Z") + .font(.system(size: 18, design: .rounded)) + .bold() + .foregroundStyle( + LinearGradient( + colors: [.red, .purple, .blue], + startPoint: .leading, + endPoint: .trailing + ) + ) + .shadow(color: .black, radius: 2, x: 0, y: 0) - Spacer() - } + Spacer() + } - HStack(spacing: 15) { - VStack { - Button("Text") { - CaptureService.shared.captureText() - dismiss() - } - .help("Capture section of screen to extract text from") - .keyboardShortcut("1", modifiers: [.command, .shift]) - .buttonStyle(RoundedRectangleButtonStyle(image: "text.viewfinder", size: 30)) + HStack(spacing: 15) { + VStack { + Button("Text") { + CaptureService.shared.captureText() + dismiss() + } + .help("Capture section of screen to extract text from") + .keyboardShortcut("1", modifiers: [.command, .shift]) + .buttonStyle(RoundedRectangleButtonStyle(image: "text.viewfinder", size: 30)) - KeyboardShortcuts.Recorder(for: .captureText) - } + KeyboardShortcuts.Recorder(for: .captureText) + } - VStack(alignment: .center) { - Button("QR/Barcode") { - CaptureService.shared.captureBarcodes() - dismiss() - } - .help("Capture QR Code or Barcode to extract text from") - .keyboardShortcut("2", modifiers: [.command, .shift]) - .buttonStyle(RoundedRectangleButtonStyle(image: "qrcode.viewfinder", size: 30)) + VStack(alignment: .center) { + Button("QR/Barcode") { + CaptureService.shared.captureBarcodes() + dismiss() + } + .help("Capture QR Code or Barcode to extract text from") + .keyboardShortcut("2", modifiers: [.command, .shift]) + .buttonStyle(RoundedRectangleButtonStyle(image: "qrcode.viewfinder", size: 30)) - KeyboardShortcuts.Recorder(for: .captureBarcode) - } + KeyboardShortcuts.Recorder(for: .captureBarcode) + } - } + } - Button("Clear Clipboard") { - clearClipboard() - dismiss() + Button("Clear Clipboard") { + clearClipboard() + dismiss() + } + .help("Clear clipboard contents and stored captures") + .buttonStyle(RoundedRectangleButtonStyle(image: "delete.left", size: 30)) + + if processing { + GroupBox(label: { + HStack(alignment: .center, spacing: 5) { + Text("Post-Processing") + InfoButton(text: "Execute any shell commands after capture is completed. You may also use the [ocr] token in the commands. Example:\nsay [ocr]; echo [ocr] >> saved.txt") + Spacer() } - .help("Clear clipboard contents and stored captures") - .buttonStyle(RoundedRectangleButtonStyle(image: "delete.left", size: 30)) - - if processing { - GroupBox(label: { - HStack(alignment: .center, spacing: 5) { - Text("Post-Processing") - InfoButton(text: "Execute any shell commands after capture is completed. You may also use the [ocr] token in the commands. Example:\nsay [ocr]; echo [ocr] >> saved.txt") - Spacer() - } - }().font(.title2)) { - HStack(alignment: .center, spacing: 10) { - TextEditor(text: $postCommands) - .frame(height: 50) - .focusable(false) - .font(.title3) - .overlay { - if postCommands.isEmpty { - VStack { - HStack { - Text("Example: say [ocr]; echo [ocr] >> file.txt").opacity(0.5) - Spacer() - } - .padding(.leading, 8) - .padding(.top, 2) - Spacer() - } - .frame(height: 50) + }().font(.title2)) { + HStack(alignment: .center, spacing: 10) { + TextEditor(text: $postCommands) + .frame(height: 50) + .focusable(false) + .font(.title3) + .overlay { + if postCommands.isEmpty { + VStack { + HStack { + Text("Example: say [ocr]; echo [ocr] >> file.txt").opacity(0.5) + Spacer() } + .padding(.leading, 8) + .padding(.top, 2) + Spacer() } - - + .frame(height: 50) + } } - .padding(6) - .padding(.vertical, 4) - .frame(maxWidth: .infinity, alignment: .leading) - } - .frame(maxWidth: .infinity, maxHeight: .infinity) + } + .padding(6) + .padding(.vertical, 4) + .frame(maxWidth: .infinity, alignment: .leading) + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + } - GroupBox(label: Text("Settings").font(.title2)) { - VStack(alignment: .leading, spacing: 10) { - Toggle("Append consecutive captures", isOn: $appendRecognizedText) - .toggleStyle(SpacedToggle()) - .help("When enabled, consecutive captures will be appended to the clipboard") - Toggle("Keep line breaks in captures", isOn: $keepLineBreaks) - .toggleStyle(SpacedToggle()) - .help("When enabled, new lines will be added in scanned text") - Toggle("Auto-hide capture window (3s)", isOn: $closePreview) - .toggleStyle(SpacedToggle()) - .help("When enabled, captured content preview will close after 3 seconds") - Toggle("Post-processing", isOn: $processing) - .toggleStyle(SpacedToggle()) - .help("When enabled, you can execute shell functions after capture") - Toggle("Launch at login", isOn: Binding( - get: { appState.isLaunchAtLoginEnabled }, - set: { newValue in - updateOnMain { - appState.isLaunchAtLoginEnabled = newValue - updateLaunchAtLoginStatus(newValue: newValue) - } - } - )) - .toggleStyle(SpacedToggle()) + GroupBox(label: Text("Settings").font(.title2)) { + VStack(alignment: .leading, spacing: 10) { + Toggle("Append consecutive captures", isOn: $appendRecognizedText) + .toggleStyle(SpacedToggle()) + .help("When enabled, consecutive captures will be appended to the clipboard") + Toggle("Keep line breaks in captures", isOn: $keepLineBreaks) + .toggleStyle(SpacedToggle()) + .help("When enabled, new lines will be added in scanned text") + Toggle("Auto-hide capture window (3s)", isOn: $closePreview) + .toggleStyle(SpacedToggle()) + .help("When enabled, captured content preview will close after 3 seconds") + Toggle("Post-processing", isOn: $processing) + .toggleStyle(SpacedToggle()) + .help("When enabled, you can execute shell functions after capture") + Toggle("Launch at login", isOn: Binding( + get: { appState.isLaunchAtLoginEnabled }, + set: { newValue in + updateOnMain { + appState.isLaunchAtLoginEnabled = newValue + updateLaunchAtLoginStatus(newValue: newValue) + } } - .padding(6) - .padding(.vertical, 4) - .frame(maxWidth: .infinity, alignment: .leading) - - } - .frame(maxWidth: .infinity, maxHeight: .infinity) + )) + .toggleStyle(SpacedToggle()) + } + .padding(6) + .padding(.vertical, 4) + .frame(maxWidth: .infinity, alignment: .leading) - HStack() { - - Button { - AboutWindow.show() - dismiss() - } label: { - Text("About") - } - .buttonStyle(RoundedRectangleButtonStyle(image: "info.circle", size: 15)) + } + .frame(maxWidth: .infinity, maxHeight: .infinity) - Button { - loadGithubReleases(appState: appState, manual: true) - dismiss() - } label: { - Text("Update") - } - .buttonStyle(RoundedRectangleButtonStyle(image: "arrow.down.circle", size: 15)) + HStack() { - Button("Quit") { - NSApp.terminate(nil) - } - .buttonStyle(RoundedRectangleButtonStyle(image: "x.circle", size: 15)) + Button { + AboutWindow.show() + dismiss() + } label: { + Text("About") + } + .buttonStyle(RoundedRectangleButtonStyle(image: "info.circle", size: 15)) - } + Button { + loadGithubReleases(appState: appState, manual: true) + dismiss() + } label: { + Text("Update") + } + .buttonStyle(RoundedRectangleButtonStyle(image: "arrow.down.circle", size: 15)) - Spacer() + Button("Quit") { + NSApp.terminate(nil) } - .padding() - .background(Color("bg")) + .buttonStyle(RoundedRectangleButtonStyle(image: "x.circle", size: 15)) } - .frame(width: 330, height: processing ? 710 : 590) + + Spacer() + + } + .padding() + .background(Color("bg")) + .frame(width: 330, height: processing ? 710 : 590) } } diff --git a/Viz/VizApp.swift b/Viz/VizApp.swift index 93de2b4..4e39d6e 100644 --- a/Viz/VizApp.swift +++ b/Viz/VizApp.swift @@ -16,7 +16,7 @@ struct VizApp: App { var body: some Scene { MenuBarExtra("Viz", systemImage: "eye", content: { ContentView() -// .environment(\.colorScheme, .dark) + .environment(\.colorScheme, .dark) .preferredColorScheme(.dark) .onAppear { #if !DEBUG