mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-23 01:36:57 -08:00
feature<Preference>: query git config after selecting git path
This commit is contained in:
parent
adce866716
commit
1a5fdc540c
3 changed files with 19 additions and 7 deletions
|
@ -194,7 +194,7 @@ namespace SourceGit.Models {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测配置是否
|
/// 检测配置是否正常
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public bool IsReady {
|
public bool IsReady {
|
||||||
|
|
|
@ -265,6 +265,7 @@
|
||||||
Margin="0,0,8,0"/>
|
Margin="0,0,8,0"/>
|
||||||
<controls:TextEdit
|
<controls:TextEdit
|
||||||
Grid.Row="14" Grid.Column="1"
|
Grid.Row="14" Grid.Column="1"
|
||||||
|
x:Name="editGitUser"
|
||||||
Height="24"
|
Height="24"
|
||||||
Text="{Binding ElementName=me, Path=User, Mode=TwoWay}"
|
Text="{Binding ElementName=me, Path=User, Mode=TwoWay}"
|
||||||
Placeholder="{DynamicResource Text.Preference.Git.User.Placeholder}"/>
|
Placeholder="{DynamicResource Text.Preference.Git.User.Placeholder}"/>
|
||||||
|
@ -277,6 +278,7 @@
|
||||||
Margin="0,0,8,0"/>
|
Margin="0,0,8,0"/>
|
||||||
<controls:TextEdit
|
<controls:TextEdit
|
||||||
Grid.Row="15" Grid.Column="1"
|
Grid.Row="15" Grid.Column="1"
|
||||||
|
x:Name="editGitEmail"
|
||||||
Height="24"
|
Height="24"
|
||||||
Text="{Binding ElementName=me, Path=Email, Mode=TwoWay}"
|
Text="{Binding ElementName=me, Path=Email, Mode=TwoWay}"
|
||||||
Placeholder="{DynamicResource Text.Preference.Git.Email.Placeholder}"/>
|
Placeholder="{DynamicResource Text.Preference.Git.Email.Placeholder}"/>
|
||||||
|
@ -289,6 +291,7 @@
|
||||||
Margin="0,0,8,0"/>
|
Margin="0,0,8,0"/>
|
||||||
<ComboBox
|
<ComboBox
|
||||||
Grid.Row="16" Grid.Column="1"
|
Grid.Row="16" Grid.Column="1"
|
||||||
|
x:Name="editGitCrlf"
|
||||||
Height="24"
|
Height="24"
|
||||||
ItemsSource="{Binding Source={x:Static models:CRLFOption.Supported}}"
|
ItemsSource="{Binding Source={x:Static models:CRLFOption.Supported}}"
|
||||||
SelectedValuePath="Value"
|
SelectedValuePath="Value"
|
||||||
|
|
|
@ -24,12 +24,7 @@ namespace SourceGit.Views {
|
||||||
public bool EnableWindowsTerminal { get; set; } = PathFindOnPath(new StringBuilder("wt.exe"), null);
|
public bool EnableWindowsTerminal { get; set; } = PathFindOnPath(new StringBuilder("wt.exe"), null);
|
||||||
|
|
||||||
public Preference() {
|
public Preference() {
|
||||||
if (Models.Preference.Instance.IsReady) {
|
if (!UpdateGitInfoIfReady()) {
|
||||||
User = new Commands.Config().Get("user.name");
|
|
||||||
Email = new Commands.Config().Get("user.email");
|
|
||||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
|
||||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
|
||||||
} else {
|
|
||||||
User = "";
|
User = "";
|
||||||
Email = "";
|
Email = "";
|
||||||
CRLF = "false";
|
CRLF = "false";
|
||||||
|
@ -42,6 +37,15 @@ namespace SourceGit.Views {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool UpdateGitInfoIfReady() {
|
||||||
|
if (!Models.Preference.Instance.IsReady) return false;
|
||||||
|
User = new Commands.Config().Get("user.name");
|
||||||
|
Email = new Commands.Config().Get("user.email");
|
||||||
|
CRLF = new Commands.Config().Get("core.autocrlf");
|
||||||
|
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#region EVENTS
|
#region EVENTS
|
||||||
private void LocaleChanged(object sender, SelectionChangedEventArgs e) {
|
private void LocaleChanged(object sender, SelectionChangedEventArgs e) {
|
||||||
Models.Locale.Change();
|
Models.Locale.Change();
|
||||||
|
@ -65,6 +69,11 @@ namespace SourceGit.Views {
|
||||||
if (dialog.ShowDialog() == true) {
|
if (dialog.ShowDialog() == true) {
|
||||||
Models.Preference.Instance.Git.Path = dialog.FileName;
|
Models.Preference.Instance.Git.Path = dialog.FileName;
|
||||||
editGitPath?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
editGitPath?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
|
if (UpdateGitInfoIfReady()) {
|
||||||
|
editGitUser?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
|
editGitEmail?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
|
editGitCrlf?.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateTarget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue