Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Feb 17, 2024
1 parent a5ceb9d commit 445faf7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions JL.Windows/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ private void HandlePostCopy(string text)
if (ConfigManager.Precaching && DictUtils.DictsReady
&& !DictUtils.UpdatingJmdict && !DictUtils.UpdatingJmnedict && !DictUtils.UpdatingKanjidic
&& FreqUtils.FreqsReady
&& MainTextBox.Text.Length < Utils.CacheSize)
&& text.Length < Utils.CacheSize)
{
s_precacheCancellationTokenSource.Cancel();
s_precacheCancellationTokenSource.Dispose();
s_precacheCancellationTokenSource = new CancellationTokenSource();

_ = Dispatcher.InvokeAsync(async () => await Precache(MainTextBox.Text, s_precacheCancellationTokenSource.Token).ConfigureAwait(false), DispatcherPriority.Background);
_ = Dispatcher.InvokeAsync(async () => await Precache(text, s_precacheCancellationTokenSource.Token).ConfigureAwait(false), DispatcherPriority.Background);
}
}

Expand Down Expand Up @@ -800,11 +800,18 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e)

if (SpeechSynthesisUtils.InstalledVoiceWithHighestPriority is not null)
{
string selectedText = MainTextBox.SelectionLength > 0
? MainTextBox.SelectedText
: MainTextBox.Text;
string selectedText = WindowState is not WindowState.Minimized
? MainTextBox.SelectionLength > 0
? MainTextBox.SelectedText
: MainTextBox.Text
: s_lastTextCopiedWhileMinimized is not null
? s_lastTextCopiedWhileMinimized
: MainTextBox.Text;

await SpeechSynthesisUtils.TextToSpeech(SpeechSynthesisUtils.InstalledVoiceWithHighestPriority, selectedText, CoreConfig.AudioVolume).ConfigureAwait(false);
if (selectedText.Length > 0)
{
await SpeechSynthesisUtils.TextToSpeech(SpeechSynthesisUtils.InstalledVoiceWithHighestPriority, selectedText, CoreConfig.AudioVolume).ConfigureAwait(false);
}
}
}

Expand Down

0 comments on commit 445faf7

Please sign in to comment.