style<Preference>: new style of preference setting dialog

This commit is contained in:
leo 2021-10-13 11:19:45 +08:00
parent e32df7d461
commit e5996d0fe1
5 changed files with 314 additions and 310 deletions

View file

@ -45,7 +45,7 @@ namespace SourceGit.Commands {
private Timer timer = null;
public static void Start(string repo) {
if (!Models.Preference.Instance.General.AutoFetchRemotes) return;
if (!Models.Preference.Instance.Git.AutoFetchRemotes) return;
// 只自动更新加入管理列表中的仓库(子模块等不自动更新)
var exists = Models.Preference.Instance.FindRepository(repo);

View file

@ -68,11 +68,6 @@ namespace SourceGit.Models {
/// </summary>
public int LastCheckDay { get; set; } = 0;
/// <summary>
/// 启用自动拉取远程变更每10分钟一次
/// </summary>
public bool AutoFetchRemotes { get; set; } = true;
/// <summary>
/// 是否启用崩溃上报
/// </summary>
@ -98,6 +93,11 @@ namespace SourceGit.Models {
/// 默认克隆路径
/// </summary>
public string DefaultCloneDir { get; set; }
/// <summary>
/// 启用自动拉取远程变更每10分钟一次
/// </summary>
public bool AutoFetchRemotes { get; set; } = true;
}
/// <summary>

View file

@ -359,18 +359,17 @@
<sys:String x:Key="Text.Revert.CommitChanges">Commit revert changes</sys:String>
<sys:String x:Key="Text.Preference">Preference</sys:String>
<sys:String x:Key="Text.Preference.General">GENERAL SETTING</sys:String>
<sys:String x:Key="Text.Preference.General">GENERAL</sys:String>
<sys:String x:Key="Text.Preference.Locale">Language</sys:String>
<sys:String x:Key="Text.Preference.FontFamilyWindow">Window Font</sys:String>
<sys:String x:Key="Text.Preference.FontFamilyContent">Content Font</sys:String>
<sys:String x:Key="Text.Preference.AvatarServer">Avatar Server</sys:String>
<sys:String x:Key="Text.Preference.CheckUpdate">Check for update</sys:String>
<sys:String x:Key="Text.Preference.UseDarkTheme">Use dark theme</sys:String>
<sys:String x:Key="Text.Preference.AutoFetch">Fetch remotes automatically (need restart)</sys:String>
<sys:String x:Key="Text.Preference.RestoreTabs">Restore windows</sys:String>
<sys:String x:Key="Text.Preference.EnableCrashReport">Enable crash report (maybe include related path)</sys:String>
<sys:String x:Key="Text.Preference.UseWindowsTerminal">Use Windows Terminal instead of cmd.exe</sys:String>
<sys:String x:Key="Text.Preference.Git">GIT SETTING</sys:String>
<sys:String x:Key="Text.Preference.Git">GIT</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>
<sys:String x:Key="Text.Preference.Git.Version">Git version</sys:String>
@ -381,7 +380,8 @@
<sys:String x:Key="Text.Preference.Git.Email">User Email</sys:String>
<sys:String x:Key="Text.Preference.Git.Email.Placeholder">Global git user email</sys:String>
<sys:String x:Key="Text.Preference.Git.CRLF">Enable Auto CRLF</sys:String>
<sys:String x:Key="Text.Preference.Merger">MERGE TOOL</sys:String>
<sys:String x:Key="Text.Preference.Git.AutoFetch">Fetch remotes automatically (need restart)</sys:String>
<sys:String x:Key="Text.Preference.Merger">MERGE</sys:String>
<sys:String x:Key="Text.Preference.Merger.Type">Merger</sys:String>
<sys:String x:Key="Text.Preference.Merger.Path">Install Path</sys:String>
<sys:String x:Key="Text.Preference.Merger.Path.Placeholder">Input path for merge tool</sys:String>

View file

@ -365,7 +365,6 @@
<sys:String x:Key="Text.Preference.AvatarServer">头像服务</sys:String>
<sys:String x:Key="Text.Preference.CheckUpdate">启用检测更新</sys:String>
<sys:String x:Key="Text.Preference.UseDarkTheme">启用暗色主题</sys:String>
<sys:String x:Key="Text.Preference.AutoFetch">启用定时自动拉取远程更新(重启生效)</sys:String>
<sys:String x:Key="Text.Preference.RestoreTabs">启动时恢复上次打开的仓库</sys:String>
<sys:String x:Key="Text.Preference.EnableCrashReport">开启崩溃上报(可能涉及上报相关路径)</sys:String>
<sys:String x:Key="Text.Preference.UseWindowsTerminal">使用 Windows Terminal 打开 Git 终端</sys:String>
@ -380,6 +379,7 @@
<sys:String x:Key="Text.Preference.Git.Email">邮箱</sys:String>
<sys:String x:Key="Text.Preference.Git.Email.Placeholder">默认GIT用户邮箱</sys:String>
<sys:String x:Key="Text.Preference.Git.CRLF">自动换行转换</sys:String>
<sys:String x:Key="Text.Preference.Git.AutoFetch">启用定时自动拉取远程更新(重启生效)</sys:String>
<sys:String x:Key="Text.Preference.Merger">外部合并工具</sys:String>
<sys:String x:Key="Text.Preference.Merger.Type">工具</sys:String>
<sys:String x:Key="Text.Preference.Merger.Path">安装路径</sys:String>

View file

@ -12,7 +12,7 @@
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Title="{DynamicResource Text.Preference}"
Width="500" SizeToContent="Height">
Width="500" Height="340">
<Grid>
<Grid.Resources>
<converters:FontFamiliesToName x:Key="FontFamiliesToName"/>
@ -53,10 +53,12 @@
HorizontalAlignment="Stretch"
Fill="{DynamicResource Brush.Border0}"/>
<!-- Body -->
<Grid Grid.Row="2" Margin="16,8">
<!-- Tabs -->
<TabControl Grid.Row="2" Margin="0,4">
<!-- General Setting -->
<TabItem Header="{DynamicResource Text.Preference.General}">
<Grid Margin="0,8">
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
@ -67,19 +69,6 @@
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="8"/>
<RowDefinition Height="36"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="8"/>
<RowDefinition Height="36"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="6"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@ -87,21 +76,14 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- General Group -->
<TextBlock
Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
Text="{DynamicResource Text.Preference.General}"
FontSize="16" FontWeight="DemiBold"
Foreground="{DynamicResource Brush.FG2}"/>
<!-- Language -->
<TextBlock
Grid.Row="1" Grid.Column="0"
Grid.Row="0" Grid.Column="0"
Text="{DynamicResource Text.Preference.Locale}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<ComboBox
Grid.Row="1" Grid.Column="1"
Grid.Row="0" Grid.Column="1"
Height="24"
ItemsSource="{Binding Source={x:Static models:Locale.Supported}}"
DisplayMemberPath="Name"
@ -111,12 +93,12 @@
<!-- System Font -->
<TextBlock
Grid.Row="2" Grid.Column="0"
Grid.Row="1" Grid.Column="0"
Text="{DynamicResource Text.Preference.FontFamilyWindow}"
HorizontalAlignment="Right"
Margin="0,0,6,0"/>
<ComboBox
Grid.Row="2" Grid.Column="1"
Grid.Row="1" Grid.Column="1"
Height="24"
ItemsSource="{Binding Source={x:Static models:InstalledFont.GetFonts}}"
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyWindow, Mode=TwoWay, Converter={StaticResource FontFamiliesToName}}"
@ -133,12 +115,12 @@
<!-- Content Font -->
<TextBlock
Grid.Row="3" Grid.Column="0"
Grid.Row="2" Grid.Column="0"
Text="{DynamicResource Text.Preference.FontFamilyContent}"
HorizontalAlignment="Right"
Margin="0,0,6,0"/>
<ComboBox
Grid.Row="3" Grid.Column="1"
Grid.Row="2" Grid.Column="1"
Height="24"
ItemsSource="{Binding Source={x:Static models:InstalledFont.GetFonts}}"
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=TwoWay, Converter={StaticResource FontFamiliesToName}}"
@ -155,12 +137,12 @@
<!-- Avatar -->
<TextBlock
Grid.Row="4" Grid.Column="0"
Grid.Row="3" Grid.Column="0"
Text="{DynamicResource Text.Preference.AvatarServer}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<ComboBox
Grid.Row="4" Grid.Column="1"
Grid.Row="3" Grid.Column="1"
Height="24"
ItemsSource="{Binding Source={x:Static models:AvatarServer.Supported}}"
DisplayMemberPath="Name"
@ -169,56 +151,63 @@
<!-- Enable Check For Update -->
<CheckBox
Grid.Row="5" Grid.Column="1"
Grid.Row="4" Grid.Column="1"
Content="{DynamicResource Text.Preference.CheckUpdate}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.CheckForUpdate, Mode=TwoWay}"/>
<!-- Enable Dark Theme -->
<CheckBox
Grid.Row="6" Grid.Column="1"
Grid.Row="5" Grid.Column="1"
Content="{DynamicResource Text.Preference.UseDarkTheme}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.UseDarkTheme, Mode=TwoWay}"
Checked="ChangeTheme" Unchecked="ChangeTheme"/>
<!-- Auto Fetch -->
<CheckBox
Grid.Row="7" Grid.Column="1"
Content="{DynamicResource Text.Preference.AutoFetch}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.AutoFetchRemotes, Mode=TwoWay}"/>
<!-- Restore Windows -->
<CheckBox
Grid.Row="8" Grid.Column="1"
Grid.Row="6" Grid.Column="1"
Content="{DynamicResource Text.Preference.RestoreTabs}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Restore.IsEnabled, Mode=TwoWay}"/>
<!-- Crash Report -->
<CheckBox
Grid.Row="9" Grid.Column="1"
Grid.Row="7" Grid.Column="1"
Content="{DynamicResource Text.Preference.EnableCrashReport}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.EnableCrashReport, Mode=TwoWay}"/>
<!-- Use Windows Terminal -->
<CheckBox
Grid.Row="10" Grid.Column="1"
Grid.Row="8" Grid.Column="1"
Content="{DynamicResource Text.Preference.UseWindowsTerminal}"
IsEnabled="{Binding ElementName=me, Path=HasWindowsTerminal}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.UseWindowsTerminal, Mode=TwoWay}"/>
</Grid>
</TabItem>
<!-- Git Group -->
<TextBlock
Grid.Row="12" Grid.Column="0" Grid.ColumnSpan="2"
Text="{DynamicResource Text.Preference.Git}"
FontSize="16" FontWeight="DemiBold"
Foreground="{DynamicResource Brush.FG2}"/>
<!-- Git Setting -->
<TabItem Header="{DynamicResource Text.Preference.Git}">
<Grid Margin="0,8">
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="132"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Git Executable Path -->
<TextBlock
Grid.Row="13" Grid.Column="0"
Grid.Row="0" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Path}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<Grid Grid.Row="13" Grid.Column="1">
<Grid Grid.Row="0" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
@ -241,22 +230,22 @@
<!-- Git Version -->
<TextBlock
Grid.Row="14" Grid.Column="0"
Grid.Row="1" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Version}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<TextBlock
Grid.Row="14" Grid.Column="1"
Grid.Row="1" Grid.Column="1"
x:Name="textGitVersion"
Text="{Binding ElementName=me, Path=Version}"/>
<!-- Default Clone Dir -->
<TextBlock
Grid.Row="15" Grid.Column="0"
Grid.Row="2" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Dir}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<Grid Grid.Row="15" Grid.Column="1">
<Grid Grid.Row="2" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
@ -279,12 +268,12 @@
<!-- User -->
<TextBlock
Grid.Row="16" Grid.Column="0"
Grid.Row="3" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.User}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<controls:TextEdit
Grid.Row="16" Grid.Column="1"
Grid.Row="3" Grid.Column="1"
x:Name="editGitUser"
Height="24"
Text="{Binding ElementName=me, Path=User, Mode=TwoWay}"
@ -292,12 +281,12 @@
<!-- Email -->
<TextBlock
Grid.Row="17" Grid.Column="0"
Grid.Row="4" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Email}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<controls:TextEdit
Grid.Row="17" Grid.Column="1"
Grid.Row="4" Grid.Column="1"
x:Name="editGitEmail"
Height="24"
Text="{Binding ElementName=me, Path=Email, Mode=TwoWay}"
@ -305,12 +294,12 @@
<!-- CRLF -->
<TextBlock
Grid.Row="18" Grid.Column="0"
Grid.Row="5" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.CRLF}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<ComboBox
Grid.Row="18" Grid.Column="1"
Grid.Row="5" Grid.Column="1"
x:Name="editGitCrlf"
Height="24"
ItemsSource="{Binding Source={x:Static models:CRLFOption.Supported}}"
@ -326,21 +315,34 @@
</ComboBox.ItemTemplate>
</ComboBox>
<!-- Merge Tool Group -->
<TextBlock
Grid.Row="20" Grid.Column="0" Grid.ColumnSpan="2"
Text="{DynamicResource Text.Preference.Merger}"
FontSize="17" FontWeight="DemiBold"
Foreground="{DynamicResource Brush.FG2}"/>
<!-- Auto Fetch -->
<CheckBox
Grid.Row="6" Grid.Column="1"
Content="{DynamicResource Text.Preference.Git.AutoFetch}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Git.AutoFetchRemotes, Mode=TwoWay}"/>
</Grid>
</TabItem>
<TabItem Header="{DynamicResource Text.Preference.Merger}">
<Grid Margin="0,8">
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="132"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Merge Tool Type -->
<TextBlock
Grid.Row="21" Grid.Column="0"
Grid.Row="0" Grid.Column="0"
Text="{DynamicResource Text.Preference.Merger.Type}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<ComboBox
Grid.Row="21" Grid.Column="1"
Grid.Row="0" Grid.Column="1"
Height="24"
ItemsSource="{Binding Source={x:Static models:MergeTool.Supported}}"
DisplayMemberPath="Name"
@ -350,11 +352,11 @@
<!-- Merge Tool Executable Path -->
<TextBlock
Grid.Row="22" Grid.Column="0"
Grid.Row="1" Grid.Column="0"
Text="{DynamicResource Text.Preference.Merger.Path}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<Grid Grid.Row="22" Grid.Column="1">
<Grid Grid.Row="1" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
@ -375,5 +377,7 @@
Icon="{StaticResource Icon.Folder.Open}"/>
</Grid>
</Grid>
</TabItem>
</TabControl>
</Grid>
</controls:Window>