code_review: PR #1173

- rename c-style `file_arg` to `fileArg`
- add missing translations for zh_CN and zh_TW
- re-design conflict view and add tooltip for `USE THEIRS` and `USE MINE`
- re-order unstaged toolbar buttons

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-11 10:02:33 +08:00
parent a99ab37797
commit 1799de4907
No known key found for this signature in database
5 changed files with 115 additions and 92 deletions

View file

@ -14,11 +14,11 @@ namespace SourceGit.Commands
cmd.RaiseError = true;
// NOTE: If no <file> names are specified, 'git mergetool' will run the merge tool program on every file with merge conflicts.
var file_arg = string.IsNullOrEmpty(file) ? "" : $"\"{file}\"";
var fileArg = string.IsNullOrEmpty(file) ? "" : $"\"{file}\"";
if (toolType == 0)
{
cmd.Args = $"mergetool {file_arg}";
cmd.Args = $"mergetool {fileArg}";
return cmd.Exec();
}
@ -35,7 +35,7 @@ namespace SourceGit.Commands
return false;
}
cmd.Args = $"-c mergetool.sourcegit.cmd=\"\\\"{toolPath}\\\" {supported.Cmd}\" -c mergetool.writeToTemp=true -c mergetool.keepBackup=false -c mergetool.trustExitCode=true mergetool --tool=sourcegit {file_arg}";
cmd.Args = $"-c mergetool.sourcegit.cmd=\"\\\"{toolPath}\\\" {supported.Cmd}\" -c mergetool.writeToTemp=true -c mergetool.keepBackup=false -c mergetool.trustExitCode=true mergetool --tool=sourcegit {fileArg}";
return cmd.Exec();
}

View file

@ -731,7 +731,11 @@
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">自动暂存所有变更并提交</x:String>
<x:String x:Key="Text.WorkingCopy.ConfirmCommitWithFilter" xml:space="preserve">当前有 {0} 个文件在暂存区中,但仅显示了 {1} 个文件({2} 个文件被过滤掉了),是否继续提交?</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">检测到冲突</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.OpenExternalMergeTool" xml:space="preserve">打开合并工具</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts" xml:space="preserve">打开合并工具解决冲突</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">文件冲突已解决</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.UseMine" xml:space="preserve">使用 MINE</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.UseTheirs" xml:space="preserve">使用 THEIRS</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">显示未跟踪文件</x:String>
<x:String x:Key="Text.WorkingCopy.NoCommitHistories" xml:space="preserve">没有提交信息记录</x:String>
<x:String x:Key="Text.WorkingCopy.NoCommitTemplates" xml:space="preserve">没有可应用的提交信息模板</x:String>

View file

@ -730,7 +730,11 @@
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">自動暫存全部變更並提交</x:String>
<x:String x:Key="Text.WorkingCopy.ConfirmCommitWithFilter" xml:space="preserve">您已暫存 {0} 檔案,但只顯示 {1} 檔案 ({2} 檔案被篩選器隱藏)。您要繼續嗎?</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">檢測到衝突</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.OpenExternalMergeTool" xml:space="preserve">使用外部合併工具開啟</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts" xml:space="preserve">使用外部合併工具開啟</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">檔案衝突已解決</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.UseMine" xml:space="preserve">使用 MINE</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.UseTheirs" xml:space="preserve">使用 THEIRS</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">顯示未追蹤檔案</x:String>
<x:String x:Key="Text.WorkingCopy.NoCommitHistories" xml:space="preserve">沒有提交訊息記錄</x:String>
<x:String x:Key="Text.WorkingCopy.NoCommitTemplates" xml:space="preserve">沒有可套用的提交訊息範本</x:String>

View file

@ -12,7 +12,11 @@
<Border Background="{DynamicResource Brush.Window}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">
<Grid VerticalAlignment="Center">
<StackPanel Orientation="Vertical" IsVisible="{Binding !IsResolved}">
<StackPanel.DataTemplates>
<Path Width="64" Height="64" Data="{StaticResource Icons.Conflict}" Fill="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/>
<TextBlock Margin="0,16" FontSize="20" FontWeight="Bold" Text="{DynamicResource Text.WorkingCopy.Conflicts}" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/>
<Border Margin="16,0" Padding="8" CornerRadius="4" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">
<Border.DataTemplates>
<DataTemplate DataType="vm:ConflictSourceBranch">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.Branch}"/>
@ -83,12 +87,8 @@
<TextBlock Margin="4,0,0,0" Text="{Binding}"/>
</StackPanel>
</DataTemplate>
</StackPanel.DataTemplates>
</Border.DataTemplates>
<Path Width="64" Height="64" Data="{StaticResource Icons.Conflict}" Fill="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/>
<TextBlock Margin="0,16" FontSize="20" FontWeight="Bold" Text="{DynamicResource Text.WorkingCopy.Conflicts}" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Center"/>
<Border Margin="16,0" Padding="8" CornerRadius="4" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">
<Border.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="Theirs" Converter="{x:Static ObjectConverters.IsNotNull}"/>
@ -105,9 +105,24 @@
</Border>
<StackPanel Margin="0,8,0,0" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Classes="flat" Margin="0,0,0,0" Content="{DynamicResource Text.WorkingCopy.Conflicts.UseTheirs}" Command="{Binding UseTheirs}"/>
<Button Classes="flat" Margin="8,0,0,0" Content="{DynamicResource Text.WorkingCopy.Conflicts.UseMine}" Command="{Binding UseMine}"/>
<Button Classes="flat" Margin="8,0,0,0" Content="{DynamicResource Text.WorkingCopy.Conflicts.OpenExternalMergeTool}" Command="{Binding OpenExternalMergeTool}"/>
<Button Classes="flat" Margin="0,0,0,0" Command="{Binding UseTheirs}" ToolTip.Tip="git checkout --theirs">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.Incoming}"/>
<TextBlock Margin="6,0,0,0" Text="{DynamicResource Text.WorkingCopy.Conflicts.UseTheirs}" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button Classes="flat" Margin="8,0,0,0" Command="{Binding UseMine}" ToolTip.Tip="git checkout --theirs">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.Local}"/>
<TextBlock Margin="6,0,0,0" Text="{DynamicResource Text.WorkingCopy.Conflicts.UseMine}" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button Classes="flat" Margin="8,0,0,0" Command="{Binding OpenExternalMergeTool}">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.OpenWith}"/>
<TextBlock Margin="6,0,0,0" Text="{DynamicResource Text.WorkingCopy.Conflicts.OpenExternalMergeTool}" VerticalAlignment="Center"/>
</StackPanel>
</Button>
</StackPanel>
</StackPanel>

View file

@ -68,6 +68,19 @@
<v:LoadingIcon Grid.Column="3" Width="14" Height="14" Margin="8,0,0,0" IsVisible="{Binding IsStaging}"/>
<Button Grid.Column="5"
Classes="icon_button"
Width="26" Height="14"
Padding="0"
ToolTip.Tip="{DynamicResource Text.WorkingCopy.Unstaged.ViewAssumeUnchaged}"
Command="{Binding OpenAssumeUnchanged}">
<Path Width="14" Height="14" Data="{StaticResource Icons.File.Ignore}"/>
</Button>
<ToggleButton Grid.Column="6"
Classes="toggle_untracked"
Width="26" Height="14"
ToolTip.Tip="{DynamicResource Text.WorkingCopy.IncludeUntracked}"
IsChecked="{Binding IncludeUntracked, Mode=TwoWay}"/>
<Button Grid.Column="7"
Classes="icon_button"
Width="26" Height="14"
Padding="0"
@ -76,19 +89,6 @@
Command="{Binding OpenExternalMergeToolAllConflicts}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Conflict}"/>
</Button>
<Button Grid.Column="6"
Classes="icon_button"
Width="26" Height="14"
Padding="0"
ToolTip.Tip="{DynamicResource Text.WorkingCopy.Unstaged.ViewAssumeUnchaged}"
Command="{Binding OpenAssumeUnchanged}">
<Path Width="14" Height="14" Data="{StaticResource Icons.File.Ignore}"/>
</Button>
<ToggleButton Grid.Column="7"
Classes="toggle_untracked"
Width="26" Height="14"
ToolTip.Tip="{DynamicResource Text.WorkingCopy.IncludeUntracked}"
IsChecked="{Binding IncludeUntracked, Mode=TwoWay}"/>
<Button Grid.Column="8"
Classes="icon_button"
Width="26" Height="14"