mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-23 01:36:57 -08:00
feature<Avatar>: add settings for avatar server
This commit is contained in:
parent
6a9ee67524
commit
3dfe3ae252
6 changed files with 73 additions and 21 deletions
|
@ -53,6 +53,10 @@ namespace SourceGit {
|
|||
/// </summary>
|
||||
public string Locale { get; set; } = "en_US";
|
||||
/// <summary>
|
||||
/// Base URL to get avatar
|
||||
/// </summary>
|
||||
public string AvatarServer { get; set; } = "https://www.gravatar.com/avatar";
|
||||
/// <summary>
|
||||
/// Main window width
|
||||
/// </summary>
|
||||
public double WindowWidth { get; set; }
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace SourceGit.Helpers {
|
|||
|
||||
Action job = () => {
|
||||
try {
|
||||
HttpWebRequest req = WebRequest.CreateHttp("https://www.gravatar.com/avatar/" + md5 + "?d=404");
|
||||
HttpWebRequest req = WebRequest.CreateHttp(App.Setting.UI.AvatarServer + md5 + "?d=404");
|
||||
req.Timeout = 2000;
|
||||
req.Method = "GET";
|
||||
|
||||
|
|
|
@ -348,6 +348,7 @@
|
|||
<sys:String x:Key="Text.Preference.Locale">Display Language :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.UseLight">Light Theme :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.CheckUpdate">Check for Update :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.AvatarServer">Avatar Server :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git">GIT INSTANCE</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path">Install Path :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path.Placeholder">Input path for git.exe</sys:String>
|
||||
|
|
|
@ -348,6 +348,7 @@
|
|||
<sys:String x:Key="Text.Preference.Locale">显示语言 :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.UseLight">启用浅色主题 :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.CheckUpdate">检测更新 :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.AvatarServer">头像服务 :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git">GIT配置</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path">安装路径 :</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path.Placeholder">填写git.exe所在位置</sys:String>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
xmlns:app="clr-namespace:SourceGit"
|
||||
xmlns:git="clr-namespace:SourceGit.Git"
|
||||
mc:Ignorable="d"
|
||||
Height="560" Width="500"
|
||||
Height="588" Width="500"
|
||||
Title="{StaticResource Text.Preference}"
|
||||
WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
|
||||
|
||||
|
@ -63,6 +63,7 @@
|
|||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="18"/>
|
||||
<RowDefinition Height="36"/>
|
||||
<RowDefinition Height="28"/>
|
||||
|
@ -112,10 +113,20 @@
|
|||
IsChecked="{Binding Source={x:Static app:App.Setting}, Path=CheckUpdate, Mode=TwoWay}"
|
||||
TextElement.FontStyle="Italic"/>
|
||||
|
||||
<Label Grid.Row="4" Grid.Column="0" Content="{StaticResource Text.Preference.AvatarServer}" HorizontalAlignment="Right"/>
|
||||
<ComboBox Grid.Row="4" Grid.Column="1"
|
||||
x:Name="cmbAvatarServer"
|
||||
Height="24"
|
||||
Width="140"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalContentAlignment="Center"
|
||||
DisplayMemberPath="Desc"
|
||||
SelectionChanged="ChangeAvatarServer"/>
|
||||
|
||||
<!-- GIT相关配置 -->
|
||||
<Label Grid.Row="5" Grid.ColumnSpan="2" Content="{StaticResource Text.Preference.Git}" FontSize="16" FontWeight="DemiBold" Opacity=".85"/>
|
||||
<Label Grid.Row="6" Grid.Column="0" Content="{StaticResource Text.Preference.Git.Path}" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="6" Grid.Column="1">
|
||||
<Label Grid.Row="6" Grid.ColumnSpan="2" Content="{StaticResource Text.Preference.Git}" FontSize="16" FontWeight="DemiBold" Opacity=".85"/>
|
||||
<Label Grid.Row="7" Grid.Column="0" Content="{StaticResource Text.Preference.Git.Path}" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="7" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="28"/>
|
||||
|
@ -130,8 +141,8 @@
|
|||
<Path Width="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Label Grid.Row="7" Grid.Column="0" Content="{StaticResource Text.Preference.Git.Dir}" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="7" Grid.Column="1">
|
||||
<Label Grid.Row="8" Grid.Column="0" Content="{StaticResource Text.Preference.Git.Dir}" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="8" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="28"/>
|
||||
|
@ -148,13 +159,13 @@
|
|||
</Grid>
|
||||
|
||||
<!-- Global User -->
|
||||
<Label Grid.Row="9" Grid.ColumnSpan="2" Content="{StaticResource Text.Preference.Global}" FontSize="16" FontWeight="DemiBold" Opacity=".85"/>
|
||||
<Label Grid.Row="10" Grid.Column="0" Content="{StaticResource Text.Preference.User}" HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Row="10" Grid.Column="1" Height="24" helpers:TextBoxHelper.Placeholder="Global git user name" Text="{Binding ElementName=me, Path=GlobalUser, Mode=TwoWay}"/>
|
||||
<Label Grid.Row="11" Grid.Column="0" Content="{StaticResource Text.Preference.Email}" HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Row="11" Grid.Column="1" Height="24" helpers:TextBoxHelper.Placeholder="Global git user email" Text="{Binding ElementName=me, Path=GlobalUserEmail, Mode=TwoWay}"/>
|
||||
<Label Grid.Row="12" Grid.Column="0" Content="{StaticResource Text.Preference.CRLF}" HorizontalAlignment="Right"/>
|
||||
<ComboBox Grid.Row="12" Grid.Column="1"
|
||||
<Label Grid.Row="10" Grid.ColumnSpan="2" Content="{StaticResource Text.Preference.Global}" FontSize="16" FontWeight="DemiBold" Opacity=".85"/>
|
||||
<Label Grid.Row="11" Grid.Column="0" Content="{StaticResource Text.Preference.User}" HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Row="11" Grid.Column="1" Height="24" helpers:TextBoxHelper.Placeholder="Global git user name" Text="{Binding ElementName=me, Path=GlobalUser, Mode=TwoWay}"/>
|
||||
<Label Grid.Row="12" Grid.Column="0" Content="{StaticResource Text.Preference.Email}" HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Row="12" Grid.Column="1" Height="24" helpers:TextBoxHelper.Placeholder="Global git user email" Text="{Binding ElementName=me, Path=GlobalUserEmail, Mode=TwoWay}"/>
|
||||
<Label Grid.Row="13" Grid.Column="0" Content="{StaticResource Text.Preference.CRLF}" HorizontalAlignment="Right"/>
|
||||
<ComboBox Grid.Row="13" Grid.Column="1"
|
||||
x:Name="cmbAutoCRLF"
|
||||
Height="24"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
@ -171,9 +182,9 @@
|
|||
</ComboBox>
|
||||
|
||||
<!-- 合并工具配置 -->
|
||||
<Label Grid.Row="14" Grid.ColumnSpan="2" Content="{StaticResource Text.Preference.Merger}" FontSize="16" FontWeight="DemiBold" Opacity=".85"/>
|
||||
<Label Grid.Row="15" Grid.Column="0" Content="{StaticResource Text.Preference.Merger.Type}" HorizontalAlignment="Right"/>
|
||||
<ComboBox Grid.Row="15" Grid.Column="1"
|
||||
<Label Grid.Row="15" Grid.ColumnSpan="2" Content="{StaticResource Text.Preference.Merger}" FontSize="16" FontWeight="DemiBold" Opacity=".85"/>
|
||||
<Label Grid.Row="16" Grid.Column="0" Content="{StaticResource Text.Preference.Merger.Type}" HorizontalAlignment="Right"/>
|
||||
<ComboBox Grid.Row="16" Grid.Column="1"
|
||||
Height="24"
|
||||
Padding="2,0,0,0"
|
||||
HorizontalContentAlignment="Left"
|
||||
|
@ -182,8 +193,8 @@
|
|||
ItemsSource="{Binding Source={x:Static git:MergeTool.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectionChanged="ChangeMergeTool"/>
|
||||
<Label Grid.Row="16" Grid.Column="0" Content="{StaticResource Text.Preference.Merger.Path}" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="16" Grid.Column="1">
|
||||
<Label Grid.Row="17" Grid.Column="0" Content="{StaticResource Text.Preference.Merger.Path}" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="17" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="28"/>
|
||||
|
@ -198,8 +209,8 @@
|
|||
<Path Width="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Label Grid.Row="17" Grid.Column="0" Content="{StaticResource Text.Preference.Merger.Cmd}" HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Row="17" Grid.Column="1"
|
||||
<Label Grid.Row="18" Grid.Column="0" Content="{StaticResource Text.Preference.Merger.Cmd}" HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Row="18" Grid.Column="1"
|
||||
x:Name="txtMergeParam"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource Brush.FG2}"/>
|
||||
|
|
|
@ -63,6 +63,19 @@ namespace SourceGit.UI {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Avatar server
|
||||
/// </summary>
|
||||
public class AvatarServer {
|
||||
public string Value { get; set; }
|
||||
public string Desc { get; set; }
|
||||
|
||||
public AvatarServer(string v, string d) {
|
||||
Value = v;
|
||||
Desc = d;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
|
@ -81,6 +94,13 @@ namespace SourceGit.UI {
|
|||
cmbLang.ItemsSource = locales;
|
||||
cmbLang.SelectedItem = locales.Find(o => o.Value == App.Setting.UI.Locale);
|
||||
|
||||
var avatarServers = new List<AvatarServer>() {
|
||||
new AvatarServer("https://www.gravatar.com/avatar/", "Gravatar官网"),
|
||||
new AvatarServer("https://cdn.s.loli.top/avatar/", "Gravatar中国CDN"),
|
||||
};
|
||||
cmbAvatarServer.ItemsSource = avatarServers;
|
||||
cmbAvatarServer.SelectedItem = avatarServers.Find(o => o.Value == App.Setting.UI.AvatarServer);
|
||||
|
||||
int mergeType = App.Setting.Tools.MergeTool;
|
||||
var merger = Git.MergeTool.Supported[mergeType];
|
||||
txtMergePath.IsReadOnly = !merger.IsConfigured;
|
||||
|
@ -126,6 +146,21 @@ namespace SourceGit.UI {
|
|||
App.SaveSetting();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set avatar server.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ChangeAvatarServer(object sender, SelectionChangedEventArgs e) {
|
||||
if (e.AddedItems.Count != 1) return;
|
||||
|
||||
var s = e.AddedItems[0] as AvatarServer;
|
||||
if (s == null) return;
|
||||
|
||||
App.Setting.UI.AvatarServer = s.Value;
|
||||
App.SaveSetting();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select git executable file path.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in a new issue