Add global keyboard shortcut to open history window from anywhere
This commit is contained in:
parent
0b6c9bccc1
commit
61a0e82a6d
@ -9,6 +9,7 @@ extension KeyboardShortcuts.Name {
|
|||||||
static let pasteLastTranscription = Self("pasteLastTranscription")
|
static let pasteLastTranscription = Self("pasteLastTranscription")
|
||||||
static let pasteLastEnhancement = Self("pasteLastEnhancement")
|
static let pasteLastEnhancement = Self("pasteLastEnhancement")
|
||||||
static let retryLastTranscription = Self("retryLastTranscription")
|
static let retryLastTranscription = Self("retryLastTranscription")
|
||||||
|
static let openHistoryWindow = Self("openHistoryWindow")
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@ -147,7 +148,17 @@ class HotkeyManager: ObservableObject {
|
|||||||
LastTranscriptionService.retryLastTranscription(from: self.whisperState.modelContext, whisperState: self.whisperState)
|
LastTranscriptionService.retryLastTranscription(from: self.whisperState.modelContext, whisperState: self.whisperState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyboardShortcuts.onKeyUp(for: .openHistoryWindow) { [weak self] in
|
||||||
|
guard let self = self else { return }
|
||||||
|
Task { @MainActor in
|
||||||
|
HistoryWindowController.shared.showHistoryWindow(
|
||||||
|
modelContainer: self.whisperState.modelContext.container,
|
||||||
|
whisperState: self.whisperState
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
try? await Task.sleep(nanoseconds: 100_000_000)
|
try? await Task.sleep(nanoseconds: 100_000_000)
|
||||||
self.setupHotkeyMonitoring()
|
self.setupHotkeyMonitoring()
|
||||||
|
|||||||
47
VoiceInk/Views/History/HistoryShortcutTipView.swift
Normal file
47
VoiceInk/Views/History/HistoryShortcutTipView.swift
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import SwiftUI
|
||||||
|
import KeyboardShortcuts
|
||||||
|
|
||||||
|
struct HistoryShortcutTipView: View {
|
||||||
|
var body: some View {
|
||||||
|
VStack(alignment: .leading, spacing: 12) {
|
||||||
|
HStack(spacing: 12) {
|
||||||
|
Image(systemName: "command.circle")
|
||||||
|
.font(.system(size: 20))
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
.frame(width: 24, height: 24)
|
||||||
|
|
||||||
|
VStack(alignment: .leading, spacing: 2) {
|
||||||
|
Text("Quick Access")
|
||||||
|
.font(.headline)
|
||||||
|
Text("Open history from anywhere with a global shortcut")
|
||||||
|
.font(.subheadline)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
|
||||||
|
HStack(spacing: 12) {
|
||||||
|
Text("Open History Window")
|
||||||
|
.font(.system(size: 13, weight: .medium))
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
|
||||||
|
KeyboardShortcuts.Recorder(for: .openHistoryWindow)
|
||||||
|
.controlSize(.small)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(16)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.background(
|
||||||
|
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||||
|
.fill(Color(NSColor.controlBackgroundColor).opacity(0.5))
|
||||||
|
)
|
||||||
|
.overlay(
|
||||||
|
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||||
|
.strokeBorder(Color(NSColor.separatorColor).opacity(0.3), lineWidth: 1)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -223,16 +223,31 @@ struct TranscriptionHistoryView: View {
|
|||||||
TranscriptionDetailView(transcription: transcription)
|
TranscriptionDetailView(transcription: transcription)
|
||||||
.id(transcription.id)
|
.id(transcription.id)
|
||||||
} else {
|
} else {
|
||||||
VStack(spacing: 12) {
|
ScrollView {
|
||||||
Image(systemName: "doc.text")
|
VStack(spacing: 32) {
|
||||||
.font(.system(size: 50))
|
Spacer()
|
||||||
.foregroundColor(.secondary)
|
.frame(minHeight: 40)
|
||||||
Text("No Selection")
|
|
||||||
.font(.system(size: 18, weight: .medium))
|
VStack(spacing: 12) {
|
||||||
.foregroundColor(.secondary)
|
Image(systemName: "doc.text")
|
||||||
Text("Select a transcription to view details")
|
.font(.system(size: 50))
|
||||||
.font(.system(size: 14))
|
.foregroundColor(.secondary)
|
||||||
.foregroundColor(.secondary)
|
Text("No Selection")
|
||||||
|
.font(.system(size: 18, weight: .medium))
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
Text("Select a transcription to view details")
|
||||||
|
.font(.system(size: 14))
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryShortcutTipView()
|
||||||
|
.padding(.horizontal, 24)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
.frame(minHeight: 40)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.frame(minHeight: 600)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.background(Color(NSColor.controlBackgroundColor))
|
.background(Color(NSColor.controlBackgroundColor))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user