code_review: PR #187

* replace icon with common whitespace icon in other editors
* button tooltip translations
* rename `_showHiddenSymbols` to `_showHiddenSymbolsInDiffView` to make its usage clear
* change the order of this button
This commit is contained in:
leo 2024-06-19 18:15:32 +08:00
parent 4e44d6a7b1
commit fec2b402e0
No known key found for this signature in database
8 changed files with 35 additions and 30 deletions

View file

@ -34,14 +34,6 @@
<!-- Toolbar Buttons -->
<StackPanel Grid.Column="3" Margin="8,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
<ToggleButton Classes="line_path"
Width="32"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbols, Mode=TwoWay}"
IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.ShowHiddenSymbols}">
<Path Width="18" Height="18" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Diff.ShowHiddenSymbols}"/>
</ToggleButton>
<Button Classes="icon_button" Width="32" Command="{Binding IncrUnified}" IsVisible="{Binding IsTextDiff}" ToolTip.Tip="{DynamicResource Text.Diff.VisualLines.Incr}">
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Lines.Incr}"/>
</Button>
@ -70,6 +62,14 @@
<Path Width="12" Height="12" Data="{StaticResource Icons.WordWrap}" Margin="0,2,0,0"/>
</ToggleButton>
<ToggleButton Classes="line_path"
Width="32"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView, Mode=TwoWay}"
IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.ShowHiddenSymbols}">
<Path Width="11" Height="11" Stretch="Uniform" Data="{StaticResource Icons.Whitespace}" Margin="0,1,0,0"/>
</ToggleButton>
<ToggleButton Classes="line_path"
Width="32" Height="18"
Background="Transparent"

View file

@ -23,7 +23,7 @@
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbols}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
/>
</DataTemplate>
@ -43,7 +43,7 @@
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbols}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
/>
<Rectangle Grid.Column="1" Fill="{DynamicResource Brush.Border2}" Width="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
@ -62,7 +62,7 @@
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbols}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
/>
</Grid>
</DataTemplate>

View file

@ -105,16 +105,15 @@ namespace SourceGit.Views
set => SetValue(UseSyntaxHighlightingProperty, value);
}
/// <summary>
/// ShowHiddenSymbols StyledProperty definition
/// </summary>
public static readonly StyledProperty<bool> ShowHiddenSymbolsProperty =
AvaloniaProperty.Register<IThemedTextDiffPresenter, bool>(nameof(ShowHiddenSymbols));
AvaloniaProperty.Register<IThemedTextDiffPresenter, bool>(nameof(ShowHiddenSymbols), false);
/// <summary>
/// Gets or sets the ShowHiddenSymbols property. This StyledProperty
/// indicates thath show hidden symbol like space and tab
/// indicates that show hidden symbol like space and tab
/// </summary>
public bool ShowHiddenSymbols
{
@ -157,17 +156,23 @@ namespace SourceGit.Views
base.OnPropertyChanged(change);
if (change.Property == UseSyntaxHighlightingProperty)
UpdateTextMate();
else if(change.Property == ShowHiddenSymbolsProperty)
{
var showHiddenSymbols = change.NewValue is true;
this.Options.ShowTabs = showHiddenSymbols;
this.Options.ShowSpaces = showHiddenSymbols;
UpdateTextMate();
}
else if (change.Property == ShowHiddenSymbolsProperty)
{
var val = change.NewValue is true;
Options.ShowTabs = val;
Options.ShowSpaces = val;
}
else if (change.Property == FileNameProperty)
{
Models.TextMateHelper.SetGrammarByFileName(_textMate, FileName);
}
else if (change.Property.Name == "ActualThemeVariant" && change.NewValue != null)
{
Models.TextMateHelper.SetThemeByApp(_textMate);
}
}
protected void UpdateTextMate()