feature<Welcome>: supports to open terminal without repositories

This commit is contained in:
leo 2021-09-13 14:53:24 +08:00
parent f858d32291
commit 26a930aa3a
4 changed files with 507 additions and 474 deletions

View file

@ -297,8 +297,9 @@
<sys:String x:Key="Text.Merge.Mode">Merge Option :</sys:String>
<sys:String x:Key="Text.Welcome.Title">SourceGit</sys:String>
<sys:String x:Key="Text.Welcome.OpenOrInit">Open Local Repository</sys:String>
<sys:String x:Key="Text.Welcome.Clone">Clone Remote Repository</sys:String>
<sys:String x:Key="Text.Welcome.OpenOrInit">Open local repository</sys:String>
<sys:String x:Key="Text.Welcome.OpenTerminal">Open terminal</sys:String>
<sys:String x:Key="Text.Welcome.Clone">Clone remote repository</sys:String>
<sys:String x:Key="Text.Welcome.DragDrop">DRAG-DROP YOUR FOLDER</sys:String>
<sys:String x:Key="Text.Welcome.Start">START</sys:String>
<sys:String x:Key="Text.Welcome.Recent">RECENT OPENED</sys:String>

View file

@ -297,6 +297,7 @@
<sys:String x:Key="Text.Welcome.Title">欢迎使用本软件</sys:String>
<sys:String x:Key="Text.Welcome.OpenOrInit">打开本地仓库</sys:String>
<sys:String x:Key="Text.Welcome.OpenTerminal">打开GIT终端</sys:String>
<sys:String x:Key="Text.Welcome.Clone">克隆远程仓库</sys:String>
<sys:String x:Key="Text.Welcome.DragDrop">支持拖放操作</sys:String>
<sys:String x:Key="Text.Welcome.Start">开始使用</sys:String>

View file

@ -52,16 +52,22 @@
Text="{DynamicResource Text.Welcome.Start}"
FontSize="13pt"/>
<StackPanel Grid.Row="1" Margin="4,12,0,0" Orientation="Vertical">
<Button Grid.Column="0" Grid.Row="0" Click="OnOpenClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<Button Click="OnOpenClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Path Width="16" Height="16" Data="{StaticResource Icon.Folder.Open}" Fill="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="12,0,0,0" Text="{DynamicResource Text.Welcome.OpenOrInit}" Foreground="{DynamicResource Brush.Accent1}"/>
<Path Width="16" Height="15" Data="{StaticResource Icon.Folder.Open}" Fill="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.OpenOrInit}" Foreground="{DynamicResource Brush.Accent1}"/>
</StackPanel>
</Button>
<Button Grid.Column="0" Grid.Row="1" Click="OnCloneClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<Button Click="OnCloneClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<StackPanel Orientation="Horizontal">
<Path Width="16" Height="16" Data="{StaticResource Icon.Pull}" Fill="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="12,0,0,0" Text="{DynamicResource Text.Welcome.Clone}" Foreground="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.Clone}" Foreground="{DynamicResource Brush.Accent1}"/>
</StackPanel>
</Button>
<Button Click="OnOpenTerminalClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<StackPanel Orientation="Horizontal">
<Path Width="16" Height="14" Data="{StaticResource Icon.Terminal}" Fill="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.OpenTerminal}" Foreground="{DynamicResource Brush.Accent1}"/>
</StackPanel>
</Button>
</StackPanel>

View file

@ -78,6 +78,31 @@ namespace SourceGit.Views.Widgets {
if (dialog.ShowDialog() == true) CheckAndOpen(dialog.SelectedPath);
}
private void OnOpenTerminalClicked(object sender, RoutedEventArgs e) {
if (MakeSureReady()) {
var bash = Path.Combine(Models.Preference.Instance.Git.Path, "..", "bash.exe");
if (!File.Exists(bash)) {
Models.Exception.Raise(App.Text("MissingBash"));
return;
}
if (Models.Preference.Instance.General.UseWindowsTerminal) {
Process.Start(new ProcessStartInfo {
FileName = "wt",
Arguments = "\"{bash}\"",
UseShellExecute = false,
});
} else {
Process.Start(new ProcessStartInfo {
FileName = bash,
UseShellExecute = true,
});
}
e.Handled = true;
}
}
private void OnCloneClicked(object sender, RoutedEventArgs e) {
if (MakeSureReady()) new Popups.Clone().Show();
}