Add launch-at-login, multi-window results, and copy-image; auto-detect Developer ID
Users can now launch Kapture at login, keep multiple screenshot windows open
at once, and copy a screenshot to the clipboard. Builds sign with a Developer
ID identity when present, falling back to the ad-hoc self-signed key, so
Screen Recording permission survives rebuilds.
💘 Generated with Crush
Assisted-by: Crush:deepseek-v4-flash-0731
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
import CoreGraphics
|
||||
import ServiceManagement
|
||||
|
||||
@main
|
||||
struct KaptureApp: App {
|
||||
@@ -47,6 +48,19 @@ struct MenuView: View {
|
||||
|
||||
Divider()
|
||||
|
||||
Button(LoginItem.isEnabled ? "Disable Launch at Login" : "Launch at Login") {
|
||||
if !LoginItem.toggle() {
|
||||
let alert = NSAlert()
|
||||
alert.messageText = "Could not update Launch at Login"
|
||||
alert.informativeText = "Launch at Login requires a signed app bundle in /Applications. It is not available when running via `swift run`."
|
||||
alert.alertStyle = .warning
|
||||
alert.addButton(withTitle: "OK")
|
||||
alert.runModal()
|
||||
}
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
Button("Quit Kapture") { NSApp.terminate(nil) }
|
||||
.keyboardShortcut("q")
|
||||
}
|
||||
@@ -60,6 +74,26 @@ enum PermissionManager {
|
||||
}
|
||||
}
|
||||
|
||||
enum LoginItem {
|
||||
static var isEnabled: Bool {
|
||||
SMAppService.mainApp.status == .enabled
|
||||
}
|
||||
|
||||
static func toggle() -> Bool {
|
||||
let service = SMAppService.mainApp
|
||||
do {
|
||||
if service.status == .enabled {
|
||||
try service.unregister()
|
||||
} else {
|
||||
try service.register()
|
||||
}
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runOCRSelfTest() {
|
||||
let text = "Kapture OCR test 1234, hello world"
|
||||
let size = NSSize(width: 1600, height: 220)
|
||||
|
||||
Reference in New Issue
Block a user