diff --git a/README.md b/README.md index 3b2645fc..2af61cbc 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Opensouce Git GUI client. * Revision Diffs * GitFlow support +> **Linux** only tested on `Ubuntu 22.04` on `X11`. + ## How to use **To use this tool, you need to install Git first.** @@ -43,7 +45,6 @@ For **macOS** users: For **Linux** users: * `xdg-open` must be installed to support open native file manager. -* Only tested on `Ubuntu 22.04`. ## Screen Shots diff --git a/src/App.axaml.cs b/src/App.axaml.cs index 98df9dbf..60e44d7b 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -50,7 +50,7 @@ namespace SourceGit { manager.AddFontCollection(monospace); }); - Native.OS.SetupFonts(builder); + Native.OS.SetupApp(builder); return builder; } diff --git a/src/Converters/WindowStateConverters.cs b/src/Converters/WindowStateConverters.cs index 67e5a3be..fc7c0bd4 100644 --- a/src/Converters/WindowStateConverters.cs +++ b/src/Converters/WindowStateConverters.cs @@ -2,13 +2,15 @@ using Avalonia.Data.Converters; using Avalonia.Media; using Avalonia; -using System.Runtime.InteropServices; +using System; namespace SourceGit.Converters { public static class WindowStateConverters { public static FuncValueConverter ToContentMargin = new FuncValueConverter(state => { - if (state == WindowState.Maximized && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { + if (OperatingSystem.IsWindows() && state == WindowState.Maximized) { + return new Thickness(6); + } else if (OperatingSystem.IsLinux() && state != WindowState.Maximized) { return new Thickness(6); } else { return new Thickness(0); @@ -17,7 +19,7 @@ namespace SourceGit.Converters { public static FuncValueConverter ToTitleBarHeight = new FuncValueConverter(state => { - if (state == WindowState.Maximized && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { + if (state == WindowState.Maximized) { return new GridLength(30); } else { return new GridLength(38); diff --git a/src/Native/Linux.cs b/src/Native/Linux.cs index 7776a98f..262a7f3c 100644 --- a/src/Native/Linux.cs +++ b/src/Native/Linux.cs @@ -6,7 +6,7 @@ using System.Runtime.Versioning; namespace SourceGit.Native { [SupportedOSPlatform("linux")] internal class Linux : OS.IBackend { - public void SetupFonts(AppBuilder builder) { + public void SetupApp(AppBuilder builder) { #if USE_FONT_INTER builder.WithInterFont(); #endif diff --git a/src/Native/MacOS.cs b/src/Native/MacOS.cs index c2ccf34b..495fdc2b 100644 --- a/src/Native/MacOS.cs +++ b/src/Native/MacOS.cs @@ -8,7 +8,7 @@ using System.Text; namespace SourceGit.Native { [SupportedOSPlatform("macOS")] internal class MacOS : OS.IBackend { - public void SetupFonts(AppBuilder builder) { + public void SetupApp(AppBuilder builder) { builder.With(new FontManagerOptions() { DefaultFamilyName = "PingFang SC", FontFallbacks = [ diff --git a/src/Native/OS.cs b/src/Native/OS.cs index 747606fc..2c9d41b7 100644 --- a/src/Native/OS.cs +++ b/src/Native/OS.cs @@ -5,7 +5,7 @@ using System.Diagnostics; namespace SourceGit.Native { public static class OS { public interface IBackend { - void SetupFonts(AppBuilder builder); + void SetupApp(AppBuilder builder); string FindGitExecutable(); string FindVSCode(); @@ -41,8 +41,8 @@ namespace SourceGit.Native { } } - public static void SetupFonts(AppBuilder builder) { - _backend?.SetupFonts(builder); + public static void SetupApp(AppBuilder builder) { + _backend?.SetupApp(builder); } public static string FindGitExecutable() { diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index fa7c2b73..7bce6ede 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -13,7 +13,7 @@ namespace SourceGit.Native { [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)] private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs); - public void SetupFonts(AppBuilder builder) { + public void SetupApp(AppBuilder builder) { builder.With(new FontManagerOptions() { DefaultFamilyName = "Microsoft YaHei UI", FontFallbacks = [ diff --git a/src/Views/About.axaml b/src/Views/About.axaml index 0aebc9d8..37185c8e 100644 --- a/src/Views/About.axaml +++ b/src/Views/About.axaml @@ -9,24 +9,32 @@ x:DataType="v:About" Icon="/App.ico" Title="{DynamicResource Text.About}" - Background="{DynamicResource Brush.Window}" + Background="Transparent" SizeToContent="WidthAndHeight" CanResize="False" WindowStartupLocation="CenterScreen" - ExtendClientAreaToDecorationsHint="{OnPlatform True, Linux=False}" - ExtendClientAreaChromeHints="{OnPlatform NoChrome, Linux=Default}"> + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> - + + + + + + PointerPressed="BeginMoveWindow"/> + IsVisible="{OnPlatform True, macOS=False}"/> - + + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> + + + - + + PointerPressed="BeginMoveWindow"/> + IsVisible="{OnPlatform True, macOS=False}"/> - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - + + + + + + diff --git a/src/Views/AssumeUnchangedManager.axaml.cs b/src/Views/AssumeUnchangedManager.axaml.cs index 616db87d..32bf574e 100644 --- a/src/Views/AssumeUnchangedManager.axaml.cs +++ b/src/Views/AssumeUnchangedManager.axaml.cs @@ -1,4 +1,5 @@ using Avalonia.Controls; +using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views { @@ -7,6 +8,10 @@ namespace SourceGit.Views { InitializeComponent(); } + private void BeginMoveWindow(object sender, PointerPressedEventArgs e) { + BeginMoveDrag(e); + } + private void CloseWindow(object sender, RoutedEventArgs e) { Close(); } diff --git a/src/Views/Blame.axaml b/src/Views/Blame.axaml index 3a88f25d..07cba81e 100644 --- a/src/Views/Blame.axaml +++ b/src/Views/Blame.axaml @@ -12,25 +12,32 @@ x:DataType="vm:Blame" Icon="/App.ico" Title="{DynamicResource Text.Blame}" + Background="Transparent" WindowStartupLocation="CenterOwner" - BorderThickness="1" - BorderBrush="{DynamicResource Brush.Border0}" - Background="{DynamicResource Brush.Window}" MinWidth="1280" MinHeight="720" - ExtendClientAreaToDecorationsHint="{OnPlatform True, Linux=False}" - ExtendClientAreaChromeHints="{OnPlatform NoChrome, Linux=Default}"> + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> + + + + + DoubleTapped="MaximizeOrRestoreWindow" + PointerPressed="BeginMoveWindow"/> @@ -40,19 +47,20 @@ - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Views/Blame.axaml.cs b/src/Views/Blame.axaml.cs index 56c6d3ee..91693a68 100644 --- a/src/Views/Blame.axaml.cs +++ b/src/Views/Blame.axaml.cs @@ -308,6 +308,27 @@ namespace SourceGit.Views { InitializeComponent(); } + private void MaximizeOrRestoreWindow(object sender, TappedEventArgs e) { + if (WindowState == WindowState.Maximized) { + WindowState = WindowState.Normal; + } else { + WindowState = WindowState.Maximized; + } + e.Handled = true; + } + + private void CustomResizeWindow(object sender, PointerPressedEventArgs e) { + if (sender is Border border) { + if (border.Tag is WindowEdge edge) { + BeginResizeDrag(edge, e); + } + } + } + + private void BeginMoveWindow(object sender, PointerPressedEventArgs e) { + BeginMoveDrag(e); + } + protected override void OnClosed(EventArgs e) { base.OnClosed(e); GC.Collect(); diff --git a/src/Views/FileHistories.axaml b/src/Views/FileHistories.axaml index 84ea46cd..6dbdd692 100644 --- a/src/Views/FileHistories.axaml +++ b/src/Views/FileHistories.axaml @@ -12,24 +12,31 @@ x:Name="me" Icon="/App.ico" Title="{DynamicResource Text.FileHistory}" + Background="Transparent" MinWidth="1280" MinHeight="720" - BorderThickness="1" - BorderBrush="{DynamicResource Brush.Border0}" - Background="{DynamicResource Brush.Window}" - ExtendClientAreaToDecorationsHint="{OnPlatform True, Linux=False}" - ExtendClientAreaChromeHints="{OnPlatform NoChrome, Linux=Default}"> + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> + + + + + DoubleTapped="MaximizeOrRestoreWindow" + PointerPressed="BeginMoveWindow"/> @@ -39,19 +46,20 @@ - - + + - - + + - + + @@ -109,5 +117,64 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Views/FileHistories.axaml.cs b/src/Views/FileHistories.axaml.cs index e88f8408..25250584 100644 --- a/src/Views/FileHistories.axaml.cs +++ b/src/Views/FileHistories.axaml.cs @@ -7,6 +7,27 @@ namespace SourceGit.Views { InitializeComponent(); } + private void MaximizeOrRestoreWindow(object sender, TappedEventArgs e) { + if (WindowState == WindowState.Maximized) { + WindowState = WindowState.Normal; + } else { + WindowState = WindowState.Maximized; + } + e.Handled = true; + } + + private void CustomResizeWindow(object sender, PointerPressedEventArgs e) { + if (sender is Border border) { + if (border.Tag is WindowEdge edge) { + BeginResizeDrag(edge, e); + } + } + } + + private void BeginMoveWindow(object sender, PointerPressedEventArgs e) { + BeginMoveDrag(e); + } + private void OnPressedSHA(object sender, PointerPressedEventArgs e) { if (sender is TextBlock block) { var histories = DataContext as ViewModels.FileHistories; diff --git a/src/Views/Hotkeys.axaml b/src/Views/Hotkeys.axaml index 549d8cc8..b3b52352 100644 --- a/src/Views/Hotkeys.axaml +++ b/src/Views/Hotkeys.axaml @@ -7,24 +7,32 @@ x:Class="SourceGit.Views.Hotkeys" Icon="/App.ico" Title="{DynamicResource Text.Hotkeys}" - Background="{DynamicResource Brush.Window}" + Background="Transparent" SizeToContent="WidthAndHeight" CanResize="False" WindowStartupLocation="CenterOwner" - ExtendClientAreaToDecorationsHint="{OnPlatform True, Linux=False}" - ExtendClientAreaChromeHints="{OnPlatform NoChrome, Linux=Default}"> + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> - + + + + + + PointerPressed="BeginMoveWindow"/> + IsVisible="{OnPlatform True, macOS=False}"/> - - + + + + - - - - - - + + + - - + + - - - + + - + + + - - - + - - + + + - - + + - - + + - - - + + - + + + - - - + - - + + + - - + + - - - - + + + + + + + + diff --git a/src/Views/Hotkeys.axaml.cs b/src/Views/Hotkeys.axaml.cs index 5a68b6c2..f56f2d5f 100644 --- a/src/Views/Hotkeys.axaml.cs +++ b/src/Views/Hotkeys.axaml.cs @@ -1,4 +1,5 @@ using Avalonia.Controls; +using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views { @@ -7,6 +8,10 @@ namespace SourceGit.Views { InitializeComponent(); } + private void BeginMoveWindow(object sender, PointerPressedEventArgs e) { + BeginMoveDrag(e); + } + private void CloseWindow(object sender, RoutedEventArgs e) { Close(); } diff --git a/src/Views/Launcher.axaml b/src/Views/Launcher.axaml index 4b9460e6..aa5a725f 100644 --- a/src/Views/Launcher.axaml +++ b/src/Views/Launcher.axaml @@ -12,13 +12,12 @@ x:Name="me" Icon="/App.ico" Title="SourceGit" - BorderThickness="1" - BorderBrush="{DynamicResource Brush.Border0}" - Background="{DynamicResource Brush.Window}" + Background="Transparent" MinWidth="1280" MinHeight="720" WindowStartupLocation="CenterScreen" - ExtendClientAreaToDecorationsHint="{OnPlatform True, Linux=False}" - ExtendClientAreaChromeHints="{OnPlatform NoChrome, Linux=Default}"> + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> @@ -29,12 +28,20 @@ + + + + + DoubleTapped="MaximizeOrRestoreWindow" + PointerPressed="BeginMoveWindow"/> @@ -233,8 +240,8 @@ - - + + @@ -364,5 +371,64 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Views/Launcher.axaml.cs b/src/Views/Launcher.axaml.cs index 491434ad..1456e5d0 100644 --- a/src/Views/Launcher.axaml.cs +++ b/src/Views/Launcher.axaml.cs @@ -126,6 +126,14 @@ namespace SourceGit.Views { e.Handled = true; } + private void CustomResizeWindow(object sender, PointerPressedEventArgs e) { + if (sender is Border border) { + if (border.Tag is WindowEdge edge) { + BeginResizeDrag(edge, e); + } + } + } + private void BeginMoveWindow(object sender, PointerPressedEventArgs e) { BeginMoveDrag(e); } diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 19e4d65b..25f5f51c 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -13,24 +13,32 @@ x:Name="me" Icon="/App.ico" Title="{DynamicResource Text.Preference}" - Background="{DynamicResource Brush.Window}" + Background="Transparent" Width="600" SizeToContent="Height" CanResize="False" WindowStartupLocation="CenterScreen" - ExtendClientAreaToDecorationsHint="{OnPlatform True, Linux=False}" - ExtendClientAreaChromeHints="{OnPlatform NoChrome, Linux=Default}"> + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> - + + + + + + PointerPressed="BeginMoveWindow"/> + IsVisible="{OnPlatform True, macOS=False}"/> - - - - - - - - + + + + + + + + + + - - - - https://www.gravatar.com/avatar/ - https://cravatar.cn/avatar/ - - + + + + https://www.gravatar.com/avatar/ + https://cravatar.cn/avatar/ + + - - - - Default - Dark - Light - - + + + + Default + Dark + Light + + - - - - - 0,0,0,4 - 0 - 0 - 8 - 16 - 16 - - + + + + + 0,0,0,4 + 0 + 0 + 8 + 16 + 16 + + - + + + + + + + - + + + + - - - + + + + + + + - - - - + + - - - - - - - + + + + + + - - + + - - - - - - + + - - + + + + + + + + + + + - - + + + - - - - - - - - - - - + + + + - - - + + + - - - - + + + + + + - - - + + + + - - - - - - + + + + - - - - + + + - - - - + + + + + + - - - - - - - - - - - - + - - + - - - - + + + + diff --git a/src/Views/Preference.axaml.cs b/src/Views/Preference.axaml.cs index 38f27a5b..f0eb830b 100644 --- a/src/Views/Preference.axaml.cs +++ b/src/Views/Preference.axaml.cs @@ -1,4 +1,5 @@ using Avalonia.Controls; +using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Platform.Storage; using System; @@ -58,6 +59,10 @@ namespace SourceGit.Views { txtVersion.Text = ver; } + private void BeginMoveWindow(object sender, PointerPressedEventArgs e) { + BeginMoveDrag(e); + } + private void CloseWindow(object sender, RoutedEventArgs e) { var cmd = new Commands.Config(null); diff --git a/src/Views/Statistics.axaml b/src/Views/Statistics.axaml index 5bb06c25..2528a5b1 100644 --- a/src/Views/Statistics.axaml +++ b/src/Views/Statistics.axaml @@ -9,15 +9,27 @@ x:Class="SourceGit.Views.Statistics" x:DataType="vm:Statistics" Title="{DynamicResource Text.Statistics}" - Background="{DynamicResource Brush.Window}" + Background="Transparent" Width="800" Height="450" WindowStartupLocation="CenterOwner" CanResize="False" - ExtendClientAreaToDecorationsHint="{OnPlatform True, Linux=False}" - ExtendClientAreaChromeHints="{OnPlatform NoChrome, Linux=Default}"> + ExtendClientAreaToDecorationsHint="True" + ExtendClientAreaChromeHints="NoChrome" + SystemDecorations="{OnPlatform Full, Linux=None}"> + + + + + + - + + IsVisible="{OnPlatform True, macOS=False}"/> @@ -82,7 +94,7 @@ - +