mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 21:30:37 +08:00
feature: use Ctrl + -/= to zoom in/out window content (#1810)
Co-authored-by: Danielku15 <danielku15@coderline.net> Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -478,6 +478,7 @@
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenPreferences" xml:space="preserve">Open Preferences dialog</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.ShowWorkspaceDropdownMenu" xml:space="preserve">Show workspace dropdown menu</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.SwitchTab" xml:space="preserve">Switch active tab</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.Zoom" xml:space="preserve">Zoom in/out</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">REPOSITORY</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">Commit staged changes</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">Commit and push staged changes</x:String>
|
||||
|
||||
@@ -482,6 +482,7 @@
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenPreferences" xml:space="preserve">打开偏好设置面板</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.ShowWorkspaceDropdownMenu" xml:space="preserve">显示工作区下拉菜单</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.SwitchTab" xml:space="preserve">切换显示页面</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.Zoom" xml:space="preserve">缩放内容</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">仓库页面快捷键</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">提交暂存区更改</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">提交暂存区更改并推送</x:String>
|
||||
|
||||
@@ -482,6 +482,7 @@
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenPreferences" xml:space="preserve">開啟偏好設定面板</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.ShowWorkspaceDropdownMenu" xml:space="preserve">顯示工作區的下拉式選單</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.SwitchTab" xml:space="preserve">切換目前頁面</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.Zoom" xml:space="preserve">放大/縮小內容</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">存放庫頁面快速鍵</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">提交暫存區變更</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">提交暫存區變更並推送</x:String>
|
||||
|
||||
@@ -34,13 +34,20 @@
|
||||
ClipToBounds="True">
|
||||
<Border Margin="{TemplateBinding Padding}">
|
||||
<VisualLayerManager>
|
||||
<Border>
|
||||
<ContentPresenter Name="PART_ContentPresenter"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Content="{TemplateBinding Content}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
<LayoutTransformControl>
|
||||
<LayoutTransformControl.LayoutTransform>
|
||||
<ScaleTransform ScaleX="{Binding Source={x:Static vm:Preferences.Instance}, Path=Zoom, Mode=OneWay}"
|
||||
ScaleY="{Binding Source={x:Static vm:Preferences.Instance}, Path=Zoom, Mode=OneWay}"/>
|
||||
</LayoutTransformControl.LayoutTransform>
|
||||
|
||||
<Border>
|
||||
<ContentPresenter Name="PART_ContentPresenter"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Content="{TemplateBinding Content}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</LayoutTransformControl>
|
||||
</VisualLayerManager>
|
||||
</Border>
|
||||
</Border>
|
||||
@@ -129,13 +136,20 @@
|
||||
BorderThickness="1"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<VisualLayerManager>
|
||||
<Border CornerRadius="{TemplateBinding CornerRadius}" ClipToBounds="True">
|
||||
<ContentPresenter Name="PART_ContentPresenter"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Content="{TemplateBinding Content}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
<LayoutTransformControl>
|
||||
<LayoutTransformControl.LayoutTransform>
|
||||
<ScaleTransform ScaleX="{Binding Source={x:Static vm:Preferences.Instance}, Path=Zoom, Mode=OneWay}"
|
||||
ScaleY="{Binding Source={x:Static vm:Preferences.Instance}, Path=Zoom, Mode=OneWay}"/>
|
||||
</LayoutTransformControl.LayoutTransform>
|
||||
|
||||
<Border CornerRadius="{TemplateBinding CornerRadius}" ClipToBounds="True">
|
||||
<ContentPresenter Name="PART_ContentPresenter"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Content="{TemplateBinding Content}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</LayoutTransformControl>
|
||||
</VisualLayerManager>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -104,6 +104,12 @@ namespace SourceGit.ViewModels
|
||||
set => SetProperty(ref _editorTabWidth, value);
|
||||
}
|
||||
|
||||
public double Zoom
|
||||
{
|
||||
get => _zoom;
|
||||
set => SetProperty(ref _zoom, value);
|
||||
}
|
||||
|
||||
public LayoutInfo Layout
|
||||
{
|
||||
get => _layout;
|
||||
@@ -770,6 +776,7 @@ namespace SourceGit.ViewModels
|
||||
private double _defaultFontSize = 13;
|
||||
private double _editorFontSize = 13;
|
||||
private int _editorTabWidth = 4;
|
||||
private double _zoom = 1.0;
|
||||
private LayoutInfo _layout = new();
|
||||
|
||||
private int _maxHistoryCommits = 20000;
|
||||
|
||||
@@ -97,10 +97,30 @@ namespace SourceGit.Views
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
if (e is { Handled: false, Key: Key.Escape, KeyModifiers: KeyModifiers.None } && CloseOnESC)
|
||||
if (e.Handled)
|
||||
return;
|
||||
|
||||
if (e is { Key: Key.Escape, KeyModifiers: KeyModifiers.None } && CloseOnESC)
|
||||
{
|
||||
Close();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.KeyModifiers == (OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
|
||||
{
|
||||
if (e.Key == Key.OemPlus)
|
||||
{
|
||||
var zoom = Math.Min(ViewModels.Preferences.Instance.Zoom + 0.05, 2.5);
|
||||
ViewModels.Preferences.Instance.Zoom = zoom;
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.OemMinus)
|
||||
{
|
||||
var zoom = Math.Max(ViewModels.Preferences.Instance.Zoom - 0.05, 1);
|
||||
ViewModels.Preferences.Instance.Zoom = zoom;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
|
||||
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Classes="bold" Text="{OnPlatform Ctrl+\,, macOS=⌘+\,}"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.OpenPreferences}"/>
|
||||
|
||||
@@ -70,8 +70,11 @@
|
||||
<TextBlock Grid.Row="7" Grid.Column="0" Classes="bold" Text="{OnPlatform Ctrl+P, macOS=⌘+P}"/>
|
||||
<TextBlock Grid.Row="7" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.SwitchTab}" />
|
||||
|
||||
<TextBlock Grid.Row="8" Grid.Column="0" Classes="bold" Text="{OnPlatform Ctrl+Q, macOS=⌘+Q}"/>
|
||||
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Quit}" />
|
||||
<TextBlock Grid.Row="8" Grid.Column="0" Classes="bold" Text="{OnPlatform 'Ctrl+-/=', macOS='⌘+-/='}"/>
|
||||
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.Zoom}" />
|
||||
|
||||
<TextBlock Grid.Row="9" Grid.Column="0" Classes="bold" Text="{OnPlatform Ctrl+Q, macOS=⌘+Q}"/>
|
||||
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Quit}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="{DynamicResource Text.Hotkeys.Repo}"
|
||||
|
||||
Reference in New Issue
Block a user