From c247b03223eba231e414396b6641dfdc9ba7ae7e Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 22 Mar 2024 12:03:04 +0800 Subject: [PATCH] feature: allow customized font size --- .../Converters/FontSizeModifyConverters.cs | 13 ++++++++ src/SourceGit/Resources/Locales.Designer.cs | 9 ++++++ src/SourceGit/Resources/Locales.en.resx | 3 ++ src/SourceGit/Resources/Locales.resx | 3 ++ src/SourceGit/Resources/Locales.zh.resx | 3 ++ src/SourceGit/Resources/Styles.axaml | 10 ++---- src/SourceGit/ViewModels/Preference.cs | 7 ++++ src/SourceGit/Views/Blame.axaml | 3 +- src/SourceGit/Views/CommitBaseInfo.axaml | 23 +++++++------ src/SourceGit/Views/CommitChanges.axaml | 9 +++--- src/SourceGit/Views/CommitDetail.axaml | 2 +- src/SourceGit/Views/FileHistories.axaml | 8 ++--- src/SourceGit/Views/Histories.axaml | 5 +-- src/SourceGit/Views/Hotkeys.axaml | 7 ++-- src/SourceGit/Views/Launcher.axaml | 3 +- src/SourceGit/Views/Preference.axaml | 32 ++++++++++++++++--- src/SourceGit/Views/Repository.axaml | 25 +++++++-------- src/SourceGit/Views/RevisionCompare.axaml | 25 +++++++-------- src/SourceGit/Views/RevisionFiles.axaml | 5 ++- src/SourceGit/Views/StashesPage.axaml | 8 ++--- src/SourceGit/Views/TextDiffView.axaml | 3 -- src/SourceGit/Views/Welcome.axaml | 2 +- src/SourceGit/Views/WorkingCopy.axaml | 16 +++++----- 23 files changed, 137 insertions(+), 87 deletions(-) create mode 100644 src/SourceGit/Converters/FontSizeModifyConverters.cs diff --git a/src/SourceGit/Converters/FontSizeModifyConverters.cs b/src/SourceGit/Converters/FontSizeModifyConverters.cs new file mode 100644 index 00000000..a908c99c --- /dev/null +++ b/src/SourceGit/Converters/FontSizeModifyConverters.cs @@ -0,0 +1,13 @@ +using Avalonia.Data.Converters; + +namespace SourceGit.Converters +{ + public static class FontSizeModifyConverters + { + public static FuncValueConverter Increase = + new FuncValueConverter(v => v + 1.0); + + public static FuncValueConverter Decrease = + new FuncValueConverter(v => v - 1.0); + } +} diff --git a/src/SourceGit/Resources/Locales.Designer.cs b/src/SourceGit/Resources/Locales.Designer.cs index ca6b1087..e3031dd9 100644 --- a/src/SourceGit/Resources/Locales.Designer.cs +++ b/src/SourceGit/Resources/Locales.Designer.cs @@ -2265,6 +2265,15 @@ namespace SourceGit.Resources { } } + /// + /// Looks up a localized string similar to Default Font Size. + /// + public static string Text_Preference_General_DefaultFontSize { + get { + return ResourceManager.GetString("Text.Preference.General.DefaultFontSize", resourceCulture); + } + } + /// /// Looks up a localized string similar to Language. /// diff --git a/src/SourceGit/Resources/Locales.en.resx b/src/SourceGit/Resources/Locales.en.resx index 3cf630ae..98817ed8 100644 --- a/src/SourceGit/Resources/Locales.en.resx +++ b/src/SourceGit/Resources/Locales.en.resx @@ -1296,4 +1296,7 @@ Monospace FontFamily + + Default Font Size + \ No newline at end of file diff --git a/src/SourceGit/Resources/Locales.resx b/src/SourceGit/Resources/Locales.resx index bedb8136..958c7119 100644 --- a/src/SourceGit/Resources/Locales.resx +++ b/src/SourceGit/Resources/Locales.resx @@ -1296,4 +1296,7 @@ Monospace FontFamily + + Default Font Size + \ No newline at end of file diff --git a/src/SourceGit/Resources/Locales.zh.resx b/src/SourceGit/Resources/Locales.zh.resx index 50ae5094..f3baef16 100644 --- a/src/SourceGit/Resources/Locales.zh.resx +++ b/src/SourceGit/Resources/Locales.zh.resx @@ -1296,4 +1296,7 @@ 等宽字体 + + 默认字体大小 + \ No newline at end of file diff --git a/src/SourceGit/Resources/Styles.axaml b/src/SourceGit/Resources/Styles.axaml index 3be7e26f..89e141b3 100644 --- a/src/SourceGit/Resources/Styles.axaml +++ b/src/SourceGit/Resources/Styles.axaml @@ -17,6 +17,7 @@ @@ -103,7 +101,6 @@ + + + + + - + - - diff --git a/src/SourceGit/Views/Repository.axaml b/src/SourceGit/Views/Repository.axaml index 419ab893..aa7b8612 100644 --- a/src/SourceGit/Views/Repository.axaml +++ b/src/SourceGit/Views/Repository.axaml @@ -113,14 +113,14 @@ - + - + - + - - + + @@ -225,7 +225,7 @@ - + - + @@ -347,7 +347,7 @@ - + @@ -361,7 +361,6 @@ - - - + + + - + diff --git a/src/SourceGit/Views/RevisionCompare.axaml b/src/SourceGit/Views/RevisionCompare.axaml index f8140965..83e0f776 100644 --- a/src/SourceGit/Views/RevisionCompare.axaml +++ b/src/SourceGit/Views/RevisionCompare.axaml @@ -19,12 +19,12 @@ VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding StartPoint.Author}"/> - - - + + + - + @@ -37,12 +37,12 @@ VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding EndPoint.Author}"/> - - - + + + - + @@ -58,7 +58,6 @@ - + @@ -149,7 +148,7 @@ - + @@ -157,7 +156,7 @@ - + @@ -182,7 +181,7 @@ - + diff --git a/src/SourceGit/Views/RevisionFiles.axaml b/src/SourceGit/Views/RevisionFiles.axaml index 64a08b83..dd1a9826 100644 --- a/src/SourceGit/Views/RevisionFiles.axaml +++ b/src/SourceGit/Views/RevisionFiles.axaml @@ -20,7 +20,6 @@ - + @@ -89,7 +88,7 @@ - + diff --git a/src/SourceGit/Views/StashesPage.axaml b/src/SourceGit/Views/StashesPage.axaml index 8d173455..12d0f985 100644 --- a/src/SourceGit/Views/StashesPage.axaml +++ b/src/SourceGit/Views/StashesPage.axaml @@ -65,11 +65,11 @@ - - + + - + @@ -113,7 +113,7 @@ - + diff --git a/src/SourceGit/Views/TextDiffView.axaml b/src/SourceGit/Views/TextDiffView.axaml index 2c43d6ee..ab4dc588 100644 --- a/src/SourceGit/Views/TextDiffView.axaml +++ b/src/SourceGit/Views/TextDiffView.axaml @@ -18,7 +18,6 @@ Foreground="{DynamicResource Brush.FG1}" SecondaryFG="{DynamicResource Brush.FG2}" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" - FontSize="12" DiffData="{Binding}" SyncScrollOffset="{Binding $parent[v:DiffView].DataContext.(vm:DiffContext).SyncScrollOffset, Mode=TwoWay}" UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting, Mode=TwoWay}"/> @@ -37,7 +36,6 @@ Foreground="{DynamicResource Brush.FG1}" SecondaryFG="{DynamicResource Brush.FG2}" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" - FontSize="12" DiffData="{Binding}"/> @@ -53,7 +51,6 @@ Foreground="{DynamicResource Brush.FG1}" SecondaryFG="{DynamicResource Brush.FG2}" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" - FontSize="12" DiffData="{Binding}"/> diff --git a/src/SourceGit/Views/Welcome.axaml b/src/SourceGit/Views/Welcome.axaml index 3f85489f..2ca840dd 100644 --- a/src/SourceGit/Views/Welcome.axaml +++ b/src/SourceGit/Views/Welcome.axaml @@ -147,7 +147,7 @@ Classes="italic" Margin="0,0,8,0" HorizontalAlignment="Center" VerticalAlignment="Center" - FontSize="12" + FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:FontSizeModifyConverters.Decrease}}" Text="{DynamicResource Text.Welcome.DragDropTip}" Foreground="{DynamicResource Brush.FG2}"/> diff --git a/src/SourceGit/Views/WorkingCopy.axaml b/src/SourceGit/Views/WorkingCopy.axaml index cc747e1b..fdb76903 100644 --- a/src/SourceGit/Views/WorkingCopy.axaml +++ b/src/SourceGit/Views/WorkingCopy.axaml @@ -86,7 +86,7 @@ - + @@ -122,7 +122,7 @@ - + @@ -130,7 +130,7 @@ - + @@ -158,7 +158,7 @@ - + @@ -211,7 +211,7 @@ - + @@ -247,7 +247,7 @@ - + @@ -255,7 +255,7 @@ - + @@ -283,7 +283,7 @@ - +