45 lines
1.2 KiB
Swift
45 lines
1.2 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
final class AppDelegate: NSObject, NSApplicationDelegate {
|
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
|
NSApp.setActivationPolicy(.accessory)
|
|
}
|
|
}
|
|
|
|
@main
|
|
struct TransuiApp: App {
|
|
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
|
@StateObject private var model = AppModel()
|
|
|
|
var body: some Scene {
|
|
MenuBarExtra {
|
|
Button(model.isRecording ? "Stop and transcribe" : "Start recording") {
|
|
model.toggleRecording()
|
|
}
|
|
.keyboardShortcut("r")
|
|
.disabled(model.state == .transcribing)
|
|
|
|
if model.isRecording {
|
|
Button("Cancel recording", role: .destructive) {
|
|
model.cancelRecording()
|
|
}
|
|
}
|
|
|
|
Divider()
|
|
SettingsLink { Text("Settings…") }
|
|
Divider()
|
|
Button("Quit Transui") { NSApp.terminate(nil) }
|
|
.keyboardShortcut("q")
|
|
} label: {
|
|
Image(systemName: model.isRecording ? "waveform.circle.fill" : "waveform")
|
|
.accessibilityLabel(model.isRecording ? "Transui recording" : "Transui")
|
|
}
|
|
|
|
Settings {
|
|
SettingsView(model: model)
|
|
}
|
|
.windowResizability(.contentSize)
|
|
}
|
|
}
|