refactor<Theme>: move theme switcher from launcher to preference

This commit is contained in:
leo 2021-10-13 10:56:01 +08:00
parent 2759b4aa2e
commit e32df7d461
7 changed files with 36 additions and 33 deletions

View file

@ -28,9 +28,6 @@
<Geometry x:Key="Icon.Curve">M1017 598c0-25-25-50-50-50c-30 0-50 25-50 50c0 35-10 136-55 186c-25 25-55 35-95 35c-70 0-121-191-161-326c-50-196-100-377-231-377c-186 0-271 286-326 472c-10 40-20 75-30 95c-10 25 5 55 30 65c25 10 55-5 65-30c10-25 20-60 35-105c35-136 116-397 226-397c55 0 105 181 141 301c55 196 110 402 256 402c65 0 121-20 161-65c90-95 85-251 85-256z</Geometry>
<Geometry x:Key="Icon.DarkTheme">M512 768c-38 0-74-9-107-23C493 704 555 615 555 512c0-103-61-192-149-233C438 265 474 256 512 256a256 256 0 01256 256a256 256 0 01-256 256m341-397V171h-200L512 29 371 171H171v200L29 512 171 653V853h200L512 995 653 853H853v-200L995 512 853 371z</Geometry>
<Geometry x:Key="Icon.LightTheme">M853 653l141-141-141-141 0-200-200 0-141-141-141 141-200 0 0 200-141 141 141 141 0 200 200 0 141 141 141-141 200 0 0-200zM512 768c-141 0-256-115-256-256s115-256 256-256s256 115 256 256s-115 256-256 256z</Geometry>
<Geometry x:Key="Icon.Down">M509 546l271-271 91 91-348 349-1-1-13 13-363-361 91-91z</Geometry>
<Geometry x:Key="Icon.DoubleDown">M256 224l0 115L512 544l256-205 0-115-256 205L256 224zM512 685l-256-205L256 595 512 800 768 595l0-115L512 685z</Geometry>
<Geometry x:Key="Icon.Up">M170 831l343-342L855 831l105-105-448-448L64 726 170 831z</Geometry>

View file

@ -15,7 +15,6 @@
<sys:String x:Key="Text.Filter">FILTER</sys:String>
<sys:String x:Key="Text.Optional">Optional.</sys:String>
<sys:String x:Key="Text.OpenFolder">SELECT FOLDER</sys:String>
<sys:String x:Key="Text.ThemeSwitcher">CHANGE THEME</sys:String>
<sys:String x:Key="Text.URL">URL :</sys:String>
<sys:String x:Key="Text.RepositoryURL">Git Repository URL</sys:String>
@ -366,6 +365,7 @@
<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>

View file

@ -14,7 +14,6 @@
<sys:String x:Key="Text.Filter">过滤</sys:String>
<sys:String x:Key="Text.Optional">选填</sys:String>
<sys:String x:Key="Text.OpenFolder">选择文件夹</sys:String>
<sys:String x:Key="Text.ThemeSwitcher">切换主题</sys:String>
<sys:String x:Key="Text.URL">仓库地址 </sys:String>
<sys:String x:Key="Text.RepositoryURL">远程仓库地址</sys:String>
@ -365,6 +364,7 @@
<sys:String x:Key="Text.Preference.FontFamilyContent">文本字体</sys:String>
<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>

View file

@ -42,7 +42,6 @@
<!-- Right controls -->
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="27" WindowChrome.IsHitTestVisibleInChrome="True">
<controls:IconButton Click="OpenPreference" Width="28" Padding="6" Icon="{StaticResource Icon.Preference}" ToolTip="{DynamicResource Text.Launcher.Preference}"/>
<ToggleButton Style="{StaticResource Style.ToggleButton.Theme}" Width="28" IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.UseDarkTheme, Mode=TwoWay}" Checked="ChangeTheme" Unchecked="ChangeTheme" ToolTip="{DynamicResource Text.ThemeSwitcher}"/>
<controls:IconButton Click="OpenAbout" Width="28" Padding="6" Icon="{StaticResource Icon.Help}" ToolTip="{DynamicResource Text.Launcher.About}"/>
<Rectangle Margin="4,0" Width="1" Height="16" VerticalAlignment="Center" Fill="{DynamicResource Brush.Border2}"/>

View file

@ -78,10 +78,6 @@ namespace SourceGit.Views {
#endregion
#region RIGHT_COMMANDS
private void ChangeTheme(object sender, RoutedEventArgs e) {
Models.Theme.Change();
}
private void OpenPreference(object sender, RoutedEventArgs e) {
var dialog = new Preference() { Owner = this };
dialog.ShowDialog();

View file

@ -66,6 +66,7 @@
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="8"/>
<RowDefinition Height="36"/>
<RowDefinition Height="28"/>
@ -172,45 +173,52 @@
Content="{DynamicResource Text.Preference.CheckUpdate}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.CheckForUpdate, Mode=TwoWay}"/>
<!-- Auto Fetch -->
<!-- Enable Dark Theme -->
<CheckBox
Grid.Row="6" 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="7" Grid.Column="1"
Grid.Row="8" 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="8" Grid.Column="1"
Grid.Row="9" 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="9" Grid.Column="1"
Grid.Row="10" 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}"/>
<!-- Git Group -->
<TextBlock
Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="2"
Grid.Row="12" Grid.Column="0" Grid.ColumnSpan="2"
Text="{DynamicResource Text.Preference.Git}"
FontSize="16" FontWeight="DemiBold"
Foreground="{DynamicResource Brush.FG2}"/>
<!-- Git Executable Path -->
<TextBlock
Grid.Row="12" Grid.Column="0"
Grid.Row="13" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Path}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<Grid Grid.Row="12" Grid.Column="1">
<Grid Grid.Row="13" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
@ -233,22 +241,22 @@
<!-- Git Version -->
<TextBlock
Grid.Row="13" Grid.Column="0"
Grid.Row="14" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Version}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<TextBlock
Grid.Row="13" Grid.Column="1"
Grid.Row="14" Grid.Column="1"
x:Name="textGitVersion"
Text="{Binding ElementName=me, Path=Version}"/>
<!-- Default Clone Dir -->
<TextBlock
Grid.Row="14" Grid.Column="0"
Grid.Row="15" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Dir}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<Grid Grid.Row="14" Grid.Column="1">
<Grid Grid.Row="15" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
@ -271,12 +279,12 @@
<!-- User -->
<TextBlock
Grid.Row="15" Grid.Column="0"
Grid.Row="16" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.User}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<controls:TextEdit
Grid.Row="15" Grid.Column="1"
Grid.Row="16" Grid.Column="1"
x:Name="editGitUser"
Height="24"
Text="{Binding ElementName=me, Path=User, Mode=TwoWay}"
@ -284,12 +292,12 @@
<!-- Email -->
<TextBlock
Grid.Row="16" Grid.Column="0"
Grid.Row="17" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.Email}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<controls:TextEdit
Grid.Row="16" Grid.Column="1"
Grid.Row="17" Grid.Column="1"
x:Name="editGitEmail"
Height="24"
Text="{Binding ElementName=me, Path=Email, Mode=TwoWay}"
@ -297,12 +305,12 @@
<!-- CRLF -->
<TextBlock
Grid.Row="17" Grid.Column="0"
Grid.Row="18" Grid.Column="0"
Text="{DynamicResource Text.Preference.Git.CRLF}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<ComboBox
Grid.Row="17" Grid.Column="1"
Grid.Row="18" Grid.Column="1"
x:Name="editGitCrlf"
Height="24"
ItemsSource="{Binding Source={x:Static models:CRLFOption.Supported}}"
@ -320,19 +328,19 @@
<!-- Merge Tool Group -->
<TextBlock
Grid.Row="19" Grid.Column="0" Grid.ColumnSpan="2"
Grid.Row="20" Grid.Column="0" Grid.ColumnSpan="2"
Text="{DynamicResource Text.Preference.Merger}"
FontSize="17" FontWeight="DemiBold"
Foreground="{DynamicResource Brush.FG2}"/>
<!-- Merge Tool Type -->
<TextBlock
Grid.Row="20" Grid.Column="0"
Grid.Row="21" Grid.Column="0"
Text="{DynamicResource Text.Preference.Merger.Type}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<ComboBox
Grid.Row="20" Grid.Column="1"
Grid.Row="21" Grid.Column="1"
Height="24"
ItemsSource="{Binding Source={x:Static models:MergeTool.Supported}}"
DisplayMemberPath="Name"
@ -342,11 +350,11 @@
<!-- Merge Tool Executable Path -->
<TextBlock
Grid.Row="21" Grid.Column="0"
Grid.Row="22" Grid.Column="0"
Text="{DynamicResource Text.Preference.Merger.Path}"
HorizontalAlignment="Right"
Margin="0,0,8,0"/>
<Grid Grid.Row="21" Grid.Column="1">
<Grid Grid.Row="22" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>

View file

@ -52,7 +52,10 @@ namespace SourceGit.Views {
#region EVENTS
private void LocaleChanged(object sender, SelectionChangedEventArgs e) {
Models.Locale.Change();
e.Handled = true;
}
private void ChangeTheme(object sender, RoutedEventArgs e) {
Models.Theme.Change();
}
private void SelectGitPath(object sender, RoutedEventArgs e) {