From 63b42224f3c13708f3502e1ce754a73ef655e1c6 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 13 Mar 2024 16:24:13 +0800 Subject: [PATCH 01/11] update: add thanks to new contributors --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 10270300..3b2645fc 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,10 @@ For **Linux** users: ![Theme Light](./screenshots/theme_light.png) -## Thanks +## Contributing -* [gigi81](https://github.com/gigi81) Github actions integration -* [kekekeks](https://github.com/kekekeks) Way to stage/unstage/discard selected changes in a file. -* [XiaoLinger](https://gitee.com/LingerNN) Hotkey: `CTRL + Enter` to commit -* [carterl](https://gitee.com/carterl) Supports Windows Terminal; Rewrite way to find git executable -* [PUMA](https://gitee.com/whgfu) Configure for default user -* [Rwing](https://gitee.com/rwing) GitFlow: add an option to keep branch after finish -* [XiaoLinger](https://gitee.com/LingerNN) Fix localizations in popup panel +Thanks to all the people who contribute. + + + + From cd2ecb109aee3e2fcf6ab6c5052cff033fe46c03 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 14 Mar 2024 10:55:25 +0800 Subject: [PATCH 02/11] enhance: diff with LFS filtered files --- src/Commands/Diff.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 611bb9a2..8003922b 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -39,20 +39,18 @@ namespace SourceGit.Commands { if (_result.IsLFS) { var ch = line[0]; if (ch == '-') { - line = line.Substring(1); - if (line.StartsWith("oid sha256:")) { - _result.LFSDiff.Old.Oid = line.Substring(11); - } else if (line.StartsWith("size ")) { - _result.LFSDiff.Old.Size = long.Parse(line.Substring(5)); + if (line.StartsWith("-oid sha256:", StringComparison.Ordinal)) { + _result.LFSDiff.Old.Oid = line.Substring(12); + } else if (line.StartsWith("-size ", StringComparison.Ordinal)) { + _result.LFSDiff.Old.Size = long.Parse(line.Substring(6)); } } else if (ch == '+') { - line = line.Substring(1); - if (line.StartsWith("oid sha256:")) { - _result.LFSDiff.New.Oid = line.Substring(11); - } else if (line.StartsWith("size ")) { - _result.LFSDiff.New.Size = long.Parse(line.Substring(5)); + if (line.StartsWith("+oid sha256:", StringComparison.Ordinal)) { + _result.LFSDiff.New.Oid = line.Substring(12); + } else if (line.StartsWith("+size ", StringComparison.Ordinal)) { + _result.LFSDiff.New.Size = long.Parse(line.Substring(6)); } - } else if (line.StartsWith(" size ")) { + } else if (line.StartsWith(" size ", StringComparison.Ordinal)) { _result.LFSDiff.New.Size = _result.LFSDiff.Old.Size = long.Parse(line.Substring(6)); } return; From f6eb1281b57e549d219d7ebc4dc6b48525346b85 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 14 Mar 2024 11:09:05 +0800 Subject: [PATCH 03/11] enhance: force using StringComparison.Ordinal --- src/Commands/Blame.cs | 2 +- src/Commands/Config.cs | 2 +- src/Commands/QueryBranches.cs | 4 ++-- src/Commands/QueryCommits.cs | 2 +- src/Models/Change.cs | 8 +++++--- src/Models/Commit.cs | 2 +- src/Models/User.cs | 2 +- src/Models/Watcher.cs | 2 +- src/ViewModels/CommitDetail.cs | 6 +++--- src/ViewModels/FileTreeNode.cs | 7 ++++--- src/ViewModels/Histories.cs | 3 ++- src/ViewModels/Repository.cs | 2 +- 12 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/Commands/Blame.cs b/src/Commands/Blame.cs index 0598fa0f..b8c977e7 100644 --- a/src/Commands/Blame.cs +++ b/src/Commands/Blame.cs @@ -38,7 +38,7 @@ namespace SourceGit.Commands { if (_result.IsBinary) return; if (string.IsNullOrEmpty(line)) return; - if (line.IndexOf('\0') >= 0) { + if (line.IndexOf('\0', StringComparison.Ordinal) >= 0) { _result.IsBinary = true; _result.LineInfos.Clear(); return; diff --git a/src/Commands/Config.cs b/src/Commands/Config.cs index 4a0ebb30..dfd58e47 100644 --- a/src/Commands/Config.cs +++ b/src/Commands/Config.cs @@ -17,7 +17,7 @@ namespace SourceGit.Commands { if (output.IsSuccess) { var lines = output.StdOut.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { - var idx = line.IndexOf('='); + var idx = line.IndexOf('=', StringComparison.Ordinal); if (idx != -1) { var key = line.Substring(0, idx).Trim(); var val = line.Substring(idx+1).Trim(); diff --git a/src/Commands/QueryBranches.cs b/src/Commands/QueryBranches.cs index 630ba8c3..859f909f 100644 --- a/src/Commands/QueryBranches.cs +++ b/src/Commands/QueryBranches.cs @@ -36,14 +36,14 @@ namespace SourceGit.Commands { var branch = new Models.Branch(); var refName = parts[0]; - if (refName.EndsWith("/HEAD")) return; + if (refName.EndsWith("/HEAD", StringComparison.Ordinal)) return; if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal)) { branch.Name = refName.Substring(PREFIX_LOCAL.Length); branch.IsLocal = true; } else if (refName.StartsWith(PREFIX_REMOTE, StringComparison.Ordinal)) { var name = refName.Substring(PREFIX_REMOTE.Length); - var shortNameIdx = name.IndexOf('/'); + var shortNameIdx = name.IndexOf('/', StringComparison.Ordinal); if (shortNameIdx < 0) return; branch.Remote = name.Substring(0, shortNameIdx); diff --git a/src/Commands/QueryCommits.cs b/src/Commands/QueryCommits.cs index 0d6c31e2..81424409 100644 --- a/src/Commands/QueryCommits.cs +++ b/src/Commands/QueryCommits.cs @@ -51,7 +51,7 @@ namespace SourceGit.Commands { current = new Models.Commit(); line = line.Substring(7); - var decoratorStart = line.IndexOf('('); + var decoratorStart = line.IndexOf('(', StringComparison.Ordinal); if (decoratorStart < 0) { current.SHA = line.Trim(); } else { diff --git a/src/Models/Change.cs b/src/Models/Change.cs index 15596a13..7b6b5958 100644 --- a/src/Models/Change.cs +++ b/src/Models/Change.cs @@ -1,4 +1,6 @@ -namespace SourceGit.Models { +using System; + +namespace SourceGit.Models { public enum ChangeViewMode { List, Grid, @@ -36,12 +38,12 @@ WorkTree = workTree; if (index == ChangeState.Renamed || workTree == ChangeState.Renamed) { - var idx = Path.IndexOf('\t'); + var idx = Path.IndexOf('\t', StringComparison.Ordinal); if (idx >= 0) { OriginalPath = Path.Substring(0, idx); Path = Path.Substring(idx + 1); } else { - idx = Path.IndexOf(" -> "); + idx = Path.IndexOf(" -> ", StringComparison.Ordinal); if (idx > 0) { OriginalPath = Path.Substring(0, idx); Path = Path.Substring(idx + 4); diff --git a/src/Models/Commit.cs b/src/Models/Commit.cs index 36261cf4..5b4f1ff6 100644 --- a/src/Models/Commit.cs +++ b/src/Models/Commit.cs @@ -31,7 +31,7 @@ namespace SourceGit.Models { } public static void ParseUserAndTime(string data, ref User user, ref ulong time) { - var userEndIdx = data.IndexOf('>'); + var userEndIdx = data.IndexOf('>', StringComparison.Ordinal); if (userEndIdx < 0) return; var timeEndIdx = data.IndexOf(' ', userEndIdx + 2); diff --git a/src/Models/User.cs b/src/Models/User.cs index e5ed39ef..7f7a85ef 100644 --- a/src/Models/User.cs +++ b/src/Models/User.cs @@ -23,7 +23,7 @@ namespace SourceGit.Models { if (Caches.ContainsKey(data)) { return Caches[data]; } else { - var nameEndIdx = data.IndexOf('<'); + var nameEndIdx = data.IndexOf('<', System.StringComparison.Ordinal); var name = nameEndIdx >= 2 ? data.Substring(0, nameEndIdx - 1) : string.Empty; var email = data.Substring(nameEndIdx + 1); diff --git a/src/Models/Watcher.cs b/src/Models/Watcher.cs index d20e52d3..9ecbaa1d 100644 --- a/src/Models/Watcher.cs +++ b/src/Models/Watcher.cs @@ -142,7 +142,7 @@ namespace SourceGit.Models { } else if (name.Equals("HEAD", StringComparison.Ordinal) || name.StartsWith("refs/heads/", StringComparison.Ordinal) || name.StartsWith("refs/remotes/", StringComparison.Ordinal) || - name.StartsWith("worktrees/")) { + name.StartsWith("worktrees/", StringComparison.Ordinal)) { _updateBranch = DateTime.Now.AddSeconds(.5).ToFileTime(); } else if (name.StartsWith("objects/", StringComparison.Ordinal) || name.Equals("index", StringComparison.Ordinal)) { _updateWC = DateTime.Now.AddSeconds(1).ToFileTime(); diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 4bdcdfca..3c031ca8 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -360,14 +360,14 @@ namespace SourceGit.ViewModels { } var content = new Commands.QueryFileContent(_repo, _commit.SHA, file.Path).Result(); - if (content.StartsWith("version https://git-lfs.github.com/spec/", StringComparison.OrdinalIgnoreCase)) { + if (content.StartsWith("version https://git-lfs.github.com/spec/", StringComparison.Ordinal)) { var obj = new Models.RevisionLFSObject() { Object = new Models.LFSObject() }; var lines = content.Split('\n', StringSplitOptions.RemoveEmptyEntries); if (lines.Length == 3) { foreach (var line in lines) { - if (line.StartsWith("oid sha256:")) { + if (line.StartsWith("oid sha256:", StringComparison.Ordinal)) { obj.Object.Oid = line.Substring(11); - } else if (line.StartsWith("size ")) { + } else if (line.StartsWith("size ", StringComparison.Ordinal)) { obj.Object.Size = long.Parse(line.Substring(5)); } } diff --git a/src/ViewModels/FileTreeNode.cs b/src/ViewModels/FileTreeNode.cs index 94f30561..cec0620e 100644 --- a/src/ViewModels/FileTreeNode.cs +++ b/src/ViewModels/FileTreeNode.cs @@ -1,4 +1,5 @@ using CommunityToolkit.Mvvm.ComponentModel; +using System; using System.Collections.Generic; namespace SourceGit.ViewModels { @@ -19,7 +20,7 @@ namespace SourceGit.ViewModels { var expanded = changes.Count <= 50; foreach (var c in changes) { - var sepIdx = c.Path.IndexOf('/'); + var sepIdx = c.Path.IndexOf('/', StringComparison.Ordinal); if (sepIdx == -1) { nodes.Add(new FileTreeNode() { FullPath = c.Path, @@ -80,7 +81,7 @@ namespace SourceGit.ViewModels { var expanded = files.Count <= 50; foreach (var f in files) { - var sepIdx = f.Path.IndexOf('/'); + var sepIdx = f.Path.IndexOf('/', StringComparison.Ordinal); if (sepIdx == -1) { nodes.Add(new FileTreeNode() { FullPath = f.Path, @@ -139,7 +140,7 @@ namespace SourceGit.ViewModels { foreach (var node in nodes) { if (node.FullPath == path) return node; - if (node.IsFolder && path.StartsWith(node.FullPath + "/")) { + if (node.IsFolder && path.StartsWith(node.FullPath + "/", StringComparison.Ordinal)) { var foundInChildren = SelectByPath(node.Children, path); if (foundInChildren != null) { node.IsExpanded = true; diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 578d6300..99642050 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -2,6 +2,7 @@ using Avalonia.Platform.Storage; using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; +using System; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; @@ -72,7 +73,7 @@ namespace SourceGit.ViewModels { } public void NavigateTo(string commitSHA) { - var commit = _commits.Find(x => x.SHA.StartsWith(commitSHA)); + var commit = _commits.Find(x => x.SHA.StartsWith(commitSHA, StringComparison.Ordinal)); if (commit != null) { AutoSelectedCommit = commit; diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index f190d7f8..dcf4ce49 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -446,7 +446,7 @@ namespace SourceGit.ViewModels { var limits = $"-{Preference.Instance.MaxHistoryCommits} "; var validFilters = new List(); foreach (var filter in Filters) { - if (filter.StartsWith("refs/")) { + if (filter.StartsWith("refs/", StringComparison.Ordinal)) { if (_branches.FindIndex(x => x.FullName == filter) >= 0) validFilters.Add(filter); } else { if (_tags.FindIndex(t => t.Name == filter) >= 0) validFilters.Add(filter); From f4b396596b53fd4a01d956f56feefe6e41acb979 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 14 Mar 2024 11:59:56 +0800 Subject: [PATCH 04/11] feature: shows selected revision file size if it's a binary file --- src/Models/RevisionFile.cs | 1 + src/ViewModels/CommitDetail.cs | 3 ++- src/Views/RevisionFiles.axaml | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Models/RevisionFile.cs b/src/Models/RevisionFile.cs index 9dd49545..f1effc4d 100644 --- a/src/Models/RevisionFile.cs +++ b/src/Models/RevisionFile.cs @@ -1,5 +1,6 @@ namespace SourceGit.Models { public class RevisionBinaryFile { + public long Size { get; set; } = 0; } public class RevisionTextFile { diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 3c031ca8..1e189191 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -353,8 +353,9 @@ namespace SourceGit.ViewModels { Task.Run(() => { var isBinary = new Commands.IsBinary(_repo, _commit.SHA, file.Path).Result(); if (isBinary) { + var size = new Commands.QueryFileSize(_repo, file.Path, _commit.SHA).Result(); Dispatcher.UIThread.Invoke(() => { - ViewRevisionFileContent = new Models.RevisionBinaryFile(); + ViewRevisionFileContent = new Models.RevisionBinaryFile() { Size = size }; }); return; } diff --git a/src/Views/RevisionFiles.axaml b/src/Views/RevisionFiles.axaml index 064fe80a..17ed8876 100644 --- a/src/Views/RevisionFiles.axaml +++ b/src/Views/RevisionFiles.axaml @@ -81,6 +81,10 @@ + + + + From 035300a612e73508aa0c19cd126b5865029b4ebd Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 14 Mar 2024 18:23:36 +0800 Subject: [PATCH 05/11] style: border-less window style on Linux platform. --- README.md | 3 +- src/App.axaml.cs | 2 +- src/Converters/WindowStateConverters.cs | 8 +- src/Native/Linux.cs | 2 +- src/Native/MacOS.cs | 2 +- src/Native/OS.cs | 6 +- src/Native/Windows.cs | 2 +- src/Views/About.axaml | 24 +- src/Views/About.axaml.cs | 4 + src/Views/AssumeUnchangedManager.axaml | 117 ++--- src/Views/AssumeUnchangedManager.axaml.cs | 5 + src/Views/Blame.axaml | 89 +++- src/Views/Blame.axaml.cs | 21 + src/Views/FileHistories.axaml | 89 +++- src/Views/FileHistories.axaml.cs | 21 + src/Views/Hotkeys.axaml | 125 ++--- src/Views/Hotkeys.axaml.cs | 5 + src/Views/Launcher.axaml | 82 +++- src/Views/Launcher.axaml.cs | 8 + src/Views/Preference.axaml | 529 +++++++++++----------- src/Views/Preference.axaml.cs | 5 + src/Views/Statistics.axaml | 26 +- src/Views/Statistics.axaml.cs | 4 + 23 files changed, 752 insertions(+), 427 deletions(-) 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 @@ - +