Added support for retry functionality
This commit is contained in:
parent
5d94daf51f
commit
95e57bf3f7
@ -7,6 +7,7 @@ extension KeyboardShortcuts.Name {
|
||||
static let toggleMiniRecorder = Self("toggleMiniRecorder")
|
||||
static let toggleMiniRecorder2 = Self("toggleMiniRecorder2")
|
||||
static let pasteLastTranscription = Self("pasteLastTranscription")
|
||||
static let retryLastTranscription = Self("retryLastTranscription")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@ -140,18 +141,24 @@ class HotkeyManager: ObservableObject {
|
||||
|
||||
self.whisperState = whisperState
|
||||
self.miniRecorderShortcutManager = MiniRecorderShortcutManager(whisperState: whisperState)
|
||||
|
||||
if KeyboardShortcuts.getShortcut(for: .pasteLastTranscription) == nil {
|
||||
let defaultPasteShortcut = KeyboardShortcuts.Shortcut(.v, modifiers: [.command, .option])
|
||||
KeyboardShortcuts.setShortcut(defaultPasteShortcut, for: .pasteLastTranscription)
|
||||
}
|
||||
|
||||
|
||||
KeyboardShortcuts.onKeyUp(for: .pasteLastTranscription) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
Task { @MainActor in
|
||||
LastTranscriptionService.pasteLastTranscription(from: self.whisperState.modelContext)
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardShortcuts.onKeyUp(for: .retryLastTranscription) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
Task { @MainActor in
|
||||
LastTranscriptionService.retryLastTranscription(from: self.whisperState.modelContext, whisperState: self.whisperState)
|
||||
}
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
try? await Task.sleep(nanoseconds: 100_000_000)
|
||||
|
||||
@ -7,6 +7,7 @@ import LaunchAtLogin
|
||||
struct GeneralSettings: Codable {
|
||||
let toggleMiniRecorderShortcut: KeyboardShortcuts.Shortcut?
|
||||
let toggleMiniRecorderShortcut2: KeyboardShortcuts.Shortcut?
|
||||
let retryLastTranscriptionShortcut: KeyboardShortcuts.Shortcut?
|
||||
let selectedHotkey1RawValue: String?
|
||||
let selectedHotkey2RawValue: String?
|
||||
let launchAtLoginEnabled: Bool?
|
||||
@ -86,6 +87,7 @@ class ImportExportService {
|
||||
let generalSettingsToExport = GeneralSettings(
|
||||
toggleMiniRecorderShortcut: KeyboardShortcuts.getShortcut(for: .toggleMiniRecorder),
|
||||
toggleMiniRecorderShortcut2: KeyboardShortcuts.getShortcut(for: .toggleMiniRecorder2),
|
||||
retryLastTranscriptionShortcut: KeyboardShortcuts.getShortcut(for: .retryLastTranscription),
|
||||
selectedHotkey1RawValue: hotkeyManager.selectedHotkey1.rawValue,
|
||||
selectedHotkey2RawValue: hotkeyManager.selectedHotkey2.rawValue,
|
||||
launchAtLoginEnabled: LaunchAtLogin.isEnabled,
|
||||
@ -218,6 +220,9 @@ class ImportExportService {
|
||||
if let shortcut2 = general.toggleMiniRecorderShortcut2 {
|
||||
KeyboardShortcuts.setShortcut(shortcut2, for: .toggleMiniRecorder2)
|
||||
}
|
||||
if let retryShortcut = general.retryLastTranscriptionShortcut {
|
||||
KeyboardShortcuts.setShortcut(retryShortcut, for: .retryLastTranscription)
|
||||
}
|
||||
if let hotkeyRaw = general.selectedHotkey1RawValue,
|
||||
let hotkey = HotkeyManager.HotkeyOption(rawValue: hotkeyRaw) {
|
||||
hotkeyManager.selectedHotkey1 = hotkey
|
||||
|
||||
@ -130,6 +130,25 @@ struct SettingsView: View {
|
||||
|
||||
Divider()
|
||||
|
||||
// Retry Last Transcription
|
||||
HStack(spacing: 12) {
|
||||
Text("Retry Last Transcription")
|
||||
.font(.system(size: 13, weight: .medium))
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
KeyboardShortcuts.Recorder(for: .retryLastTranscription)
|
||||
.controlSize(.small)
|
||||
|
||||
InfoTip(
|
||||
title: "Retry Last Transcription",
|
||||
message: "Re-transcribe the last recorded audio using the current model and copy the result."
|
||||
)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
// Middle-Click Toggle
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
HStack(spacing: 8) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user