Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/TypeWhisper.Windows/Controls/Overlay/HotkeyModeWidget.xaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
<UserControl x:Class="TypeWhisper.Windows.Controls.Overlay.HotkeyModeWidget"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:TypeWhisper.Windows.Converters">
xmlns:conv="clr-namespace:TypeWhisper.Windows.Converters"
xmlns:svc="clr-namespace:TypeWhisper.Windows.Services">
<UserControl.Resources>
<conv:HotkeyModeLabelConverter x:Key="HotkeyModeLabel"/>
</UserControl.Resources>
<Border Background="#333" CornerRadius="6" Padding="5,2">
<Border CornerRadius="6" Padding="5,2">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="#333"/>
<Style.Triggers>
<DataTrigger Binding="{Binding CurrentHotkeyMode}" Value="{x:Static svc:HotkeyMode.Toggle}">
<Setter Property="Background" Value="#4DFFA500"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<TextBlock Text="{Binding CurrentHotkeyMode, Converter={StaticResource HotkeyModeLabel}}"
Foreground="#AAA" FontSize="9" FontWeight="SemiBold"
VerticalAlignment="Center"/>
FontSize="9" FontWeight="SemiBold" VerticalAlignment="Center">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="#AAA"/>
<Style.Triggers>
<DataTrigger Binding="{Binding CurrentHotkeyMode}" Value="{x:Static svc:HotkeyMode.Toggle}">
<Setter Property="Foreground" Value="#FFA500"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
</UserControl>
23 changes: 23 additions & 0 deletions src/TypeWhisper.Windows/Converters/ValueConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,29 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
=> throw new NotSupportedException();
}

/// <summary>
/// Converts HotkeyMode? to an overlay border brush.
/// Toggle mode = amber border (attention needed), otherwise transparent.
/// </summary>
public sealed class HotkeyModeToOverlayBorderConverter : IValueConverter
{
private static readonly SolidColorBrush ToggleBrush = CreateFrozen(Color.FromArgb(0xCC, 0xFF, 0xA5, 0x00));
private static readonly SolidColorBrush TransparentBrush = CreateFrozen(Colors.Transparent);

private static SolidColorBrush CreateFrozen(Color color)
{
var brush = new SolidColorBrush(color);
brush.Freeze();
return brush;
}

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> value is HotkeyMode.Toggle ? ToggleBrush : TransparentBrush;

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotSupportedException();
}

/// <summary>
/// Converts HotkeyMode? to a short label: TOG or PTT.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/TypeWhisper.Windows/Resources/Localization/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@

"Status.Ready": "Bereit",
"Status.Recording": "Aufnahme...",
"Status.RecordingToggle": "Aufnahme (Toggle) - Hotkey dr\u00fccken zum Stoppen",
"Status.RecordingHold": "Aufnahme (Halten)...",
"Status.Processing": "Verarbeite...",
"Status.NoSpeech": "Keine Sprache erkannt",
"Status.TooShort": "Zu kurz",
Expand Down
2 changes: 2 additions & 0 deletions src/TypeWhisper.Windows/Resources/Localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@

"Status.Ready": "Ready",
"Status.Recording": "Recording...",
"Status.RecordingToggle": "Recording (Toggle) - press hotkey to stop",
"Status.RecordingHold": "Recording (Hold)...",
"Status.Processing": "Processing...",
"Status.NoSpeech": "No speech detected",
"Status.TooShort": "Too short",
Expand Down
20 changes: 18 additions & 2 deletions src/TypeWhisper.Windows/ViewModels/DictationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,22 @@ partial void OnPartialTextChanged(string value)
IsExpanded = !string.IsNullOrEmpty(value);
}

partial void OnCurrentHotkeyModeChanged(HotkeyMode? value)
{
if (_isRecording)
StatusText = GetRecordingStatusText();
}

private string GetRecordingStatusText()
{
return CurrentHotkeyMode switch
{
HotkeyMode.Toggle => Loc.Instance["Status.RecordingToggle"],
HotkeyMode.PushToTalk => Loc.Instance["Status.RecordingHold"],
_ => Loc.Instance["Status.Recording"]
};
}

private System.Timers.Timer? _feedbackTimer;

partial void OnShowFeedbackChanged(bool value)
Expand Down Expand Up @@ -288,9 +304,9 @@ private async Task StartRecording()
_eventBus.Publish(new RecordingStartedEvent());

State = DictationState.Recording;
StatusText = Loc.Instance["Status.Recording"];
TranscribedText = "";
CurrentHotkeyMode = _hotkey.CurrentMode;
StatusText = GetRecordingStatusText();
TranscribedText = "";
IsOverlayVisible = true;
RecordingSeconds = 0;

Expand Down
3 changes: 3 additions & 0 deletions src/TypeWhisper.Windows/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<conv:NonEmptyToVisibilityConverter x:Key="NonEmptyToVis"/>
<conv:HotkeyModeToOverlayBorderConverter x:Key="HotkeyModeBorder"/>
</Window.Resources>

<Grid Margin="8"
Expand All @@ -29,6 +30,8 @@
<Border x:Name="IslandBorder"
CornerRadius="22"
Background="#F0181818"
BorderBrush="{Binding CurrentHotkeyMode, Converter={StaticResource HotkeyModeBorder}}"
BorderThickness="1.5"
HorizontalAlignment="Center"
Padding="0">
<Border.Effect>
Expand Down