Skip to content

OneShotモードをホットキー実行として復活 - #670

Open
Freeesia wants to merge 12 commits into
masterfrom
codex/restore-oneshot-mode
Open

OneShotモードをホットキー実行として復活#670
Freeesia wants to merge 12 commits into
masterfrom
codex/restore-oneshot-mode

Conversation

@Freeesia

@Freeesia Freeesia commented Aug 11, 2026

Copy link
Copy Markdown
Owner

概要

以前存在したOneShotモードを、Overlay表示とCapture表示の表示切り替え時にOCR・翻訳する機能として復活します。

背景

OCR表示をテキスト追跡方式へ移行した際にOneShot設定が削除されていました。
OneShotでは前回フレームの位置や追跡状態を引き継がず、ホットキーで表示へ切り替えたときに最初に届いた画像だけを独立して処理します。

変更内容

  • IsOneShotMode 設定と設定画面、日英リソースを復活
  • Capture表示にもOverlay表示と同じホットキー登録とHold/Toggleの表示切り替えを追加
  • ホットキーでは従来どおりWindow側の表示状態を変更
  • 表示状態をOneWayToSourceでViewModelのOverlayVisibleへ通知
  • OneShotではWindow側の初期状態を非表示とし、表示へ切り替わったときにキャプチャーを開始
  • 専用のRequestOneShot()を持たず、既存の表示切り替え処理へ統合
  • 最初のフレーム通知でキャプチャーを停止し、そのフレームだけを処理
  • 停止後に届いたフレームは、初回処理済みの判定だけで破棄
  • OCRトラッカーを迂回し、OCR結果をすべて新規矩形として扱う
  • 通常モードと同じフィルター・翻訳経路を使い、未翻訳矩形から翻訳結果へ更新

影響

通常モードの周期OCRとテキスト追跡は従来どおりです。
Capture表示でもOverlayShortcutによる表示切り替えが利用できます。
OneShot有効時は、表示へ切り替えるたびに新しいキャプチャーセッションを開始します。

検証

  • dotnet build WindowTranslator.Tests\WindowTranslator.Tests.csproj --no-restore --configuration Debug --verbosity minimal -m:1 --disable-build-servers -p:UseSharedCompilation=false
    • 成功(既存の LanguageOptions.cs 警告1件のみ)
  • dotnet test WindowTranslator.Tests\WindowTranslator.Tests.csproj --no-build --no-restore --configuration Debug --verbosity minimal -m:1 --disable-build-servers
    • 98件成功、失敗0件

Comment thread WindowTranslator/Modules/Main/CaptureMainWindow.xaml.cs
Comment thread WindowTranslator/Modules/Main/MainViewModelBase.cs Outdated
Comment thread WindowTranslator/Modules/Main/MainViewModelBase.cs Outdated
Comment thread WindowTranslator/Modules/Main/MainViewModelBase.cs Outdated
Comment thread WindowTranslator/Modules/Main/MainViewModelBase.cs Outdated
Comment thread WindowTranslator/Modules/Ocr/OcrObservationSelector.cs Outdated
Comment thread WindowTranslator/AssemblyInfo.cs Outdated
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.timer.Start();
if (this.isOneShotMode)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ホットキーの登録はOneShotかどうかに関わらず必要では?本当にオーバーレイと実装揃ってる?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご指摘のとおり、Capture表示のホットキー登録はOneShot固有の変更として入れるべきではありませんでした。今回の変更範囲とは関係ないため、CaptureMainWindowの差分をすべて戻し、OneShotはOverlay表示の既存ホットキー経路だけで起動する形に修正しました。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

再確認し、ご指摘どおりCapture表示にもOneShotに関係なくホットキー登録が必要と判断しました。Overlay表示と同じHold/Toggleの表示切り替えを追加し、両Windowとも表示状態の変更だけをViewModelへ伝える形に揃えました。RequestOneShot()は削除し、OneShotの開始は既存のOnOverlayVisibleChangedへ統合しています。

@Freeesia
Freeesia marked this pull request as ready for review August 25, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant