Files
sst/Sources/Sst/AppCommands.swift

40 lines
1.3 KiB
Swift

import SwiftUI
struct AppCommands: Commands {
@ObservedObject var model: AppModel
@Environment(\.openWindow) private var openWindow
var body: some Commands {
CommandGroup(after: .pasteboard) {
Divider()
Button(Strings.clearHistory) {
openWindow(id: "main")
model.confirmingClearHistory = true
}
}
CommandMenu(Strings.recordingMenu) {
Button(model.isRecording ? Strings.stopRecording : Strings.startRecording) {
model.toggleWindowRecording()
}
.keyboardShortcut("r", modifiers: [.command, .option])
Divider()
Button(Strings.transcripts) { show(.transcripts) }
.keyboardShortcut("1", modifiers: .command)
Button(Strings.dictionary) { show(.dictionary) }
.keyboardShortcut("2", modifiers: .command)
Button(Strings.note) { show(.note) }
.keyboardShortcut("3", modifiers: .command)
Button(Strings.search) {
show(model.section)
model.focusSearch()
}
.keyboardShortcut("f", modifiers: .command)
}
}
private func show(_ section: AppModel.Section) {
openWindow(id: "main")
model.show(section)
}
}