Skip to content

Commit

Permalink
perf: OCR shortcut key copy
Browse files Browse the repository at this point in the history
  • Loading branch information
ZGGSONG committed Mar 4, 2024
1 parent 8a7c473 commit b84e2e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions STranslate/ViewModels/OCRViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ private void QRCode(BitmapSource bs)
[RelayCommand]
private void Translate(System.Collections.Generic.List<object> obj)
{
string content = (obj.FirstOrDefault() as string) ?? "";
Window? ocrView = (obj.LastOrDefault() as Window);
var content = obj.FirstOrDefault() as string ?? "";
var ocrView = obj.LastOrDefault() as Window;

//OCR结果翻译关闭界面
if (Singleton<ConfigHelper>.Instance.CurrentConfig?.CloseUIOcrRetTranslate ?? false)
Expand All @@ -352,6 +352,15 @@ private void Translate(System.Collections.Generic.List<object> obj)
Singleton<InputViewModel>.Instance.TranslateCommand.Execute(null);
}

[RelayCommand]
private void HotkeyCopy()
{
if (string.IsNullOrEmpty(GetContent)) return;

Clipboard.SetDataObject(GetContent, true);
ToastHelper.Show("复制成功", WindowType.OCR);
}

#region ContextMenu

[RelayCommand]
Expand Down
3 changes: 2 additions & 1 deletion STranslate/Views/OCRView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
Command="{Binding StickyCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
Modifiers="Ctrl+Shift" />

<!-- // 快捷键复制 // -->
<KeyBinding Command="{Binding HotkeyCopyCommand}" Gesture="Ctrl+1" />
<!-- // 重置字体大小 // -->
<KeyBinding Command="{Binding ResetFontsizeCommand}" Gesture="Ctrl+OemTilde" />
</Window.InputBindings>
Expand Down

0 comments on commit b84e2e5

Please sign in to comment.