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

@ -101,5 +101,5 @@
<StreamGeometry x:Key="Icons.Lock">M832 464h-68V240a128 128 0 00-128-128h-248a128 128 0 00-128 128v224H192c-18 0-32 14-32 32v384c0 18 14 32 32 32h640c18 0 32-14 32-32v-384c0-18-14-32-32-32zm-292 237v53a8 8 0 01-8 8h-40a8 8 0 01-8-8v-53a48 48 0 1156 0zm152-237H332V240a56 56 0 0156-56h248a56 56 0 0156 56v224z</StreamGeometry>
<StreamGeometry x:Key="Icons.Unlock">M832 464H332V240c0-31 25-56 56-56h248c31 0 56 25 56 56v68c0 4 4 8 8 8h56c4 0 8-4 8-8v-68c0-71-57-128-128-128H388c-71 0-128 57-128 128v224h-68c-18 0-32 14-32 32v384c0 18 14 32 32 32h640c18 0 32-14 32-32V496c0-18-14-32-32-32zM540 701v53c0 4-4 8-8 8h-40c-4 0-8-4-8-8v-53c-12-9-20-23-20-39 0-27 22-48 48-48s48 22 48 48c0 16-8 30-20 39z</StreamGeometry>
<StreamGeometry x:Key="Icons.Track">M897 673v13c0 51-42 93-93 93h-10c-1 0-2 0-2 0H220c-23 0-42 19-42 42v13c0 23 19 42 42 42h552c14 0 26 12 26 26 0 14-12 26-26 26H220c-51 0-93-42-93-93v-13c0-51 42-93 93-93h20c1-0 2-0 2-0h562c23 0 42-19 42-42v-13c0-11-5-22-13-29-8-7-17-11-28-10H660c-14 0-26-12-26-26 0-14 12-26 26-26h144c24-1 47 7 65 24 18 17 29 42 29 67zM479 98c-112 0-203 91-203 203 0 44 14 85 38 118l132 208c15 24 50 24 66 0l133-209c23-33 37-73 37-117 0-112-91-203-203-203zm0 327c-68 0-122-55-122-122s55-122 122-122 122 55 122 122-55 122-122 122z</StreamGeometry>
<StreamGeometry x:Key="Icons.Diff.ShowHiddenSymbols">m 319.21875,-801.79687 c -62.76888,0 -119.97164,17.53932 -171.5625,52.57812 -51.590859,35.0388 -88.971614,81.95982 -112.1875,140.85938 23.215886,58.89955 60.596641,105.89871 112.1875,140.9375 51.59086,35.03879 108.79362,52.57812 171.5625,52.57812 62.76888,0 119.97164,-17.53933 171.5625,-52.57812 51.59086,-35.03879 88.97162,-82.03795 112.1875,-140.9375 -23.21588,-58.89956 -60.59664,-105.82058 -112.1875,-140.85938 -51.59086,-35.0388 -108.79362,-52.57812 -171.5625,-52.57812 z m 0,51.5625 c 48.58139,0 93.20033,12.85703 133.82812,38.4375 40.6278,25.58047 71.70694,60.0152 93.20313,103.4375 -21.49619,43.42229 -52.57533,77.93516 -93.20313,103.51562 -40.62779,25.58047 -85.24673,38.35938 -133.82812,38.35938 -48.58139,0 -93.20033,-12.77891 -133.82812,-38.35938 -40.6278,-25.58046 -71.70694,-60.09333 -93.20313,-103.51562 21.49619,-43.4223 52.57533,-77.85703 93.20313,-103.4375 40.62779,-25.58047 85.24673,-38.4375 133.82812,-38.4375 z m 0,25.85937 c -32.24429,0 -59.6165,11.25712 -82.1875,33.82813 -22.571,22.571 -33.90625,49.94321 -33.90625,82.1875 0,32.24428 11.33525,59.69462 33.90625,82.26562 22.571,22.571 49.94321,33.82813 82.1875,33.82813 32.24429,0 59.6165,-11.25713 82.1875,-33.82813 22.571,-22.571 33.90625,-50.02134 33.90625,-82.26562 0,-32.24429 -11.33525,-59.6165 -33.90625,-82.1875 -22.571,-22.57101 -49.94321,-33.82813 -82.1875,-33.82813 z m 0,46.40625 c 19.34657,0 35.75428,6.76991 49.29688,20.3125 13.54259,13.5426 20.3125,29.9503 20.3125,49.29688 0,19.34657 -6.76991,35.8324 -20.3125,49.375 -13.5426,13.5426 -29.95031,20.3125 -49.29688,20.3125 -19.34657,0 -35.75428,-6.7699 -49.29688,-20.3125 -13.54259,-13.5426 -20.31249,-30.02843 -20.3125,-49.375 0,-19.34658 6.76991,-35.75428 20.3125,-49.29688 13.5426,-13.54259 29.95031,-20.3125 49.29688,-20.3125 z m 458.04688,93.82813 v 193.04687 H 599.53125 v -85.54687 L 440.3125,-317.42187 599.53125,-158.20312 V -243.75 h 324.6875 l 0.3125,-340.39062 z</StreamGeometry>
<StreamGeometry x:Key="Icons.Whitespace">M416 64H768v64h-64v704h64v64H448v-64h64V512H416a224 224 0 1 1 0-448zM576 832h64V128H576v704zM416 128H512v320H416a160 160 0 0 1 0-320z</StreamGeometry>
</ResourceDictionary>

View file

@ -171,7 +171,7 @@
<x:String x:Key="Text.Diff.VisualLines.Decr" xml:space="preserve">Decrease Number of Visible Lines</x:String>
<x:String x:Key="Text.Diff.VisualLines.Incr" xml:space="preserve">Increase Number of Visible Lines</x:String>
<x:String x:Key="Text.Diff.Welcome" xml:space="preserve">SELECT FILE TO VIEW CHANGES</x:String>
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">Show hidden symbols(space, tab)</x:String>
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">Show hidden symbols</x:String>
<x:String x:Key="Text.DiffWithMerger" xml:space="preserve">Open In Merge Tool</x:String>
<x:String x:Key="Text.Discard" xml:space="preserve">Discard Changes</x:String>
<x:String x:Key="Text.Discard.All" xml:space="preserve">All local changes in working copy.</x:String>

View file

@ -174,7 +174,7 @@
<x:String x:Key="Text.Diff.VisualLines.Decr" xml:space="preserve">减少可见的行数</x:String>
<x:String x:Key="Text.Diff.VisualLines.Incr" xml:space="preserve">增加可见的行数</x:String>
<x:String x:Key="Text.Diff.Welcome" xml:space="preserve">请选择需要对比的文件</x:String>
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">显示隐藏符号(空格、制表符)</x:String>
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">显示隐藏符号</x:String>
<x:String x:Key="Text.DiffWithMerger" xml:space="preserve">使用外部比对工具查看</x:String>
<x:String x:Key="Text.Discard" xml:space="preserve">放弃更改确认</x:String>
<x:String x:Key="Text.Discard.All" xml:space="preserve">所有本地址未提交的修改。</x:String>

View file

@ -174,7 +174,7 @@
<x:String x:Key="Text.Diff.VisualLines.Decr" xml:space="preserve">減少可見的行數</x:String>
<x:String x:Key="Text.Diff.VisualLines.Incr" xml:space="preserve">增加可見的行數</x:String>
<x:String x:Key="Text.Diff.Welcome" xml:space="preserve">請選擇需要對比的檔案</x:String>
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">顯示隱藏符號(空格、製表符</x:String>
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">顯示隱藏符號</x:String>
<x:String x:Key="Text.DiffWithMerger" xml:space="preserve">使用外部比對工具檢視</x:String>
<x:String x:Key="Text.Discard" xml:space="preserve">放棄更改確認</x:String>
<x:String x:Key="Text.Discard.All" xml:space="preserve">所有本地址未提交的修改。</x:String>

View file

@ -182,6 +182,12 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _enableDiffViewWordWrap, value);
}
public bool ShowHiddenSymbolsInDiffView
{
get => _showHiddenSymbolsInDiffView;
set => SetProperty(ref _showHiddenSymbolsInDiffView, value);
}
public Models.ChangeViewMode UnstagedChangeViewMode
{
get => _unstagedChangeViewMode;
@ -320,12 +326,6 @@ namespace SourceGit.ViewModels
set;
} = 0;
public bool ShowHiddenSymbols
{
get => _showHiddenSymbols;
set => SetProperty(ref _showHiddenSymbols, value);
}
[JsonIgnore]
public bool ShouldCheck4UpdateOnStartup
{
@ -541,7 +541,7 @@ namespace SourceGit.ViewModels
private bool _useSideBySideDiff = false;
private bool _useSyntaxHighlighting = false;
private bool _enableDiffViewWordWrap = false;
private bool _showHiddenSymbols = false;
private bool _showHiddenSymbolsInDiffView = false;
private Models.ChangeViewMode _unstagedChangeViewMode = Models.ChangeViewMode.List;
private Models.ChangeViewMode _stagedChangeViewMode = Models.ChangeViewMode.List;

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()