Merge branch 'develop' into feature/allowing_to_checkout_commit

This commit is contained in:
Filipe Ramalho 2024-05-25 15:43:27 -03:00 committed by GitHub
commit db9ca5ba25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 822 additions and 283 deletions

0
build/build.linux.sh Normal file → Executable file
View file

View file

@ -1,2 +1,2 @@
#!/bin/bash
exec /opt/sourcegit/sourcegit
exec /opt/sourcegit/sourcegit $1

View file

@ -36,7 +36,7 @@
return cmd.Exec();
}
public static bool Delete(string repo, string name)
public static bool DeleteLocal(string repo, string name)
{
var cmd = new Command();
cmd.WorkingDirectory = repo;
@ -44,5 +44,25 @@
cmd.Args = $"branch -D {name}";
return cmd.Exec();
}
public static bool DeleteRemote(string repo, string remote, string name)
{
var cmd = new Command();
cmd.WorkingDirectory = repo;
cmd.Context = repo;
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey))
{
cmd.Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
}
else
{
cmd.Args = "-c credential.helper=manager ";
}
cmd.Args += $"push {remote} --delete {name}";
return cmd.Exec();
}
}
}

View file

@ -33,31 +33,6 @@ namespace SourceGit.Commands
Args += $"{remote} {local}:{remoteBranch}";
}
/// <summary>
/// Only used to delete a remote branch!!!!!!
/// </summary>
/// <param name="repo"></param>
/// <param name="remote"></param>
/// <param name="branch"></param>
public Push(string repo, string remote, string branch)
{
WorkingDirectory = repo;
Context = repo;
TraitErrorAsOutput = true;
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey))
{
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
}
else
{
Args = "-c credential.helper=manager ";
}
Args += $"push {remote} --delete {branch}";
}
public Push(string repo, string remote, string tag, bool isDelete)
{
WorkingDirectory = repo;

View file

@ -5,12 +5,22 @@ namespace SourceGit.Commands
{
public static class Tag
{
public static bool Add(string repo, string name, string basedOn, string message)
public static bool Add(string repo, string name, string basedOn)
{
var cmd = new Command();
cmd.WorkingDirectory = repo;
cmd.Context = repo;
cmd.Args = $"tag -a {name} {basedOn} ";
cmd.Args = $"tag {name} {basedOn}";
return cmd.Exec();
}
public static bool Add(string repo, string name, string basedOn, string message, bool sign)
{
var param = sign ? "-s -a" : "-a";
var cmd = new Command();
cmd.WorkingDirectory = repo;
cmd.Context = repo;
cmd.Args = $"tag {param} {name} {basedOn} ";
if (!string.IsNullOrEmpty(message))
{

View file

@ -0,0 +1,9 @@
using Avalonia.Controls.Converters;
namespace SourceGit.Converters
{
public static class EnumConverters
{
public static readonly EnumToBoolConverter Equals = new EnumToBoolConverter();
}
}

View file

@ -31,7 +31,7 @@ namespace SourceGit.Converters
{
if (state == WindowState.Maximized)
{
return new GridLength(30);
return new GridLength(OperatingSystem.IsMacOS() ? 34 : 30);
}
else
{

View file

@ -6,9 +6,9 @@ namespace SourceGit.Models
{
[GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-/]+/[\w\-\.]+\.git$")]
private static partial Regex REG_HTTPS();
[GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-]+/[\w\-\.]+\.git$")]
[GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-/]+/[\w\-\.]+\.git$")]
private static partial Regex REG_SSH1();
[GeneratedRegex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$")]
[GeneratedRegex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-/]+/[\w\-\.]+\.git$")]
private static partial Regex REG_SSH2();
private static readonly Regex[] URL_FORMATS = [

View file

@ -35,6 +35,7 @@
<x:String x:Key="Text.BranchCM.Checkout" xml:space="preserve">Checkout${0}$</x:String>
<x:String x:Key="Text.BranchCM.CopyName" xml:space="preserve">Copy Branch Name</x:String>
<x:String x:Key="Text.BranchCM.Delete" xml:space="preserve">Delete${0}$</x:String>
<x:String x:Key="Text.BranchCM.DeleteMultiBranches" xml:space="preserve">Delete selected {0} branches</x:String>
<x:String x:Key="Text.BranchCM.DiscardAll" xml:space="preserve">Discard all changes</x:String>
<x:String x:Key="Text.BranchCM.FastForward" xml:space="preserve">Fast-Forward to${0}$</x:String>
<x:String x:Key="Text.BranchCM.Finish" xml:space="preserve">Git Flow - Finish${0}$</x:String>
@ -85,9 +86,10 @@
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">Save as Patch ...</x:String>
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">Squash Into Parent</x:String>
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">CHANGES</x:String>
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Search Files ...</x:String>
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">Search Changes ...</x:String>
<x:String x:Key="Text.CommitDetail.Files" xml:space="preserve">FILES</x:String>
<x:String x:Key="Text.CommitDetail.Files.LFS" xml:space="preserve">LFS File</x:String>
<x:String x:Key="Text.CommitDetail.Files.Search" xml:space="preserve">Search Files ...</x:String>
<x:String x:Key="Text.CommitDetail.Files.Submodule" xml:space="preserve">Submodule</x:String>
<x:String x:Key="Text.CommitDetail.Files.Tag" xml:space="preserve">Tag</x:String>
<x:String x:Key="Text.CommitDetail.Files.Tree" xml:space="preserve">Tree</x:String>
@ -114,20 +116,28 @@
<x:String x:Key="Text.CreateBranch.LocalChanges" xml:space="preserve">Local Changes :</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.Discard" xml:space="preserve">Discard</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.StashAndReply" xml:space="preserve">Stash &amp; Reapply</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.DoNothing" xml:space="preserve">Do Nothing</x:String>
<x:String x:Key="Text.CreateBranch.Name" xml:space="preserve">New Branch Name :</x:String>
<x:String x:Key="Text.CreateBranch.Name.Placeholder" xml:space="preserve">Enter branch name.</x:String>
<x:String x:Key="Text.CreateBranch.Title" xml:space="preserve">Create Local Branch</x:String>
<x:String x:Key="Text.CreateTag" xml:space="preserve">Create Tag</x:String>
<x:String x:Key="Text.CreateTag.BasedOn" xml:space="preserve">New Tag At :</x:String>
<x:String x:Key="Text.CreateTag.GPGSign" xml:space="preserve">GPG signing</x:String>
<x:String x:Key="Text.CreateTag.Message" xml:space="preserve">Tag Message :</x:String>
<x:String x:Key="Text.CreateTag.Message.Placeholder" xml:space="preserve">Optional.</x:String>
<x:String x:Key="Text.CreateTag.Name" xml:space="preserve">Tag Name :</x:String>
<x:String x:Key="Text.CreateTag.Name.Placeholder" xml:space="preserve">Recommended format v1.0.0-alpha</x:String>
<x:String x:Key="Text.CreateTag.PushToAllRemotes" xml:space="preserve">Push to all remotes after created</x:String>
<x:String x:Key="Text.CreateTag.Type" xml:space="preserve">Kind </x:String>
<x:String x:Key="Text.CreateTag.Type.Annotated" xml:space="preserve">annotated</x:String>
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">lightweight</x:String>
<x:String x:Key="Text.Cut" xml:space="preserve">Cut</x:String>
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">Delete Branch</x:String>
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">Branch :</x:String>
<x:String x:Key="Text.DeleteBranch.IsRemoteTip" xml:space="preserve">You are about to delete a remote branch!!!</x:String>
<x:String x:Key="Text.DeleteBranch.WithTrackingRemote" xml:space="preserve">Also delete remote branch${0}$</x:String>
<x:String x:Key="Text.DeleteMultiBranch" xml:space="preserve">Delete Multiple Branches</x:String>
<x:String x:Key="Text.DeleteMultiBranch.Tip" xml:space="preserve">You are trying to delete multiple branches at one time. Be sure to double-check before taking action!</x:String>
<x:String x:Key="Text.DeleteRemote" xml:space="preserve">Delete Remote</x:String>
<x:String x:Key="Text.DeleteRemote.Remote" xml:space="preserve">Remote :</x:String>
<x:String x:Key="Text.DeleteRepositoryNode.Target" xml:space="preserve">Target :</x:String>
@ -315,8 +325,10 @@
<x:String x:Key="Text.Push.Remote" xml:space="preserve">Remote :</x:String>
<x:String x:Key="Text.Push.Title" xml:space="preserve">Push Changes To Remote</x:String>
<x:String x:Key="Text.Push.To" xml:space="preserve">Remote Branch :</x:String>
<x:String x:Key="Text.Push.Tracking" xml:space="preserve">Tracking remote branch--set-upstream</x:String>
<x:String x:Key="Text.Push.WithAllTags" xml:space="preserve">Push all tags</x:String>
<x:String x:Key="Text.PushTag" xml:space="preserve">Push Tag To Remote</x:String>
<x:String x:Key="Text.PushTag.PushAllRemotes" xml:space="preserve">Push to all remotes</x:String>
<x:String x:Key="Text.PushTag.Remote" xml:space="preserve">Remote :</x:String>
<x:String x:Key="Text.PushTag.Tag" xml:space="preserve">Tag :</x:String>
<x:String x:Key="Text.Quit" xml:space="preserve">Quit</x:String>

View file

@ -35,6 +35,7 @@
<x:String x:Key="Text.BranchCM.Checkout" xml:space="preserve">检出(checkout)${0}$</x:String>
<x:String x:Key="Text.BranchCM.CopyName" xml:space="preserve">复制分支名</x:String>
<x:String x:Key="Text.BranchCM.Delete" xml:space="preserve">删除${0}$</x:String>
<x:String x:Key="Text.BranchCM.DeleteMultiBranches" xml:space="preserve">删除选中的 {0} 个分支</x:String>
<x:String x:Key="Text.BranchCM.DiscardAll" xml:space="preserve">放弃所有更改</x:String>
<x:String x:Key="Text.BranchCM.FastForward" xml:space="preserve">快进(fast-forward)到${0}$</x:String>
<x:String x:Key="Text.BranchCM.Finish" xml:space="preserve">GIT工作流 - 完成${0}$</x:String>
@ -80,9 +81,10 @@
<x:String x:Key="Text.CommitCM.SaveAsPatch" xml:space="preserve">另存为补丁 ...</x:String>
<x:String x:Key="Text.CommitCM.Squash" xml:space="preserve">合并此提交到上一个提交</x:String>
<x:String x:Key="Text.CommitDetail.Changes" xml:space="preserve">变更对比</x:String>
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">查找文件...</x:String>
<x:String x:Key="Text.CommitDetail.Changes.Search" xml:space="preserve">查找变更...</x:String>
<x:String x:Key="Text.CommitDetail.Files" xml:space="preserve">文件列表</x:String>
<x:String x:Key="Text.CommitDetail.Files.LFS" xml:space="preserve">LFS文件</x:String>
<x:String x:Key="Text.CommitDetail.Files.Search" xml:space="preserve">查找文件...</x:String>
<x:String x:Key="Text.CommitDetail.Files.Submodule" xml:space="preserve">子模块</x:String>
<x:String x:Key="Text.CommitDetail.Files.Tag" xml:space="preserve">标签文件</x:String>
<x:String x:Key="Text.CommitDetail.Files.Tree" xml:space="preserve">子树</x:String>
@ -107,22 +109,30 @@
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">新分支基于 </x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">完成后切换到新分支</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges" xml:space="preserve">未提交更改 </x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.Discard" xml:space="preserve">忽略</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.StashAndReply" xml:space="preserve">贮藏(stash)并自动恢复</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.Discard" xml:space="preserve">放弃所有</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.StashAndReply" xml:space="preserve">贮藏并自动恢复</x:String>
<x:String x:Key="Text.CreateBranch.LocalChanges.DoNothing" xml:space="preserve">GIT默认</x:String>
<x:String x:Key="Text.CreateBranch.Name" xml:space="preserve">新分支名 </x:String>
<x:String x:Key="Text.CreateBranch.Name.Placeholder" xml:space="preserve">填写分支名称。</x:String>
<x:String x:Key="Text.CreateBranch.Title" xml:space="preserve">创建本地分支</x:String>
<x:String x:Key="Text.CreateTag" xml:space="preserve">新建标签</x:String>
<x:String x:Key="Text.CreateTag.BasedOn" xml:space="preserve">标签位于 </x:String>
<x:String x:Key="Text.CreateTag.GPGSign" xml:space="preserve">使用GPG签名</x:String>
<x:String x:Key="Text.CreateTag.Message" xml:space="preserve">标签描述 </x:String>
<x:String x:Key="Text.CreateTag.Message.Placeholder" xml:space="preserve">选填。</x:String>
<x:String x:Key="Text.CreateTag.Name" xml:space="preserve">标签名 </x:String>
<x:String x:Key="Text.CreateTag.Name.Placeholder" xml:space="preserve">推荐格式 v1.0.0-alpha</x:String>
<x:String x:Key="Text.CreateTag.PushToAllRemotes" xml:space="preserve">推送到所有远程仓库</x:String>
<x:String x:Key="Text.CreateTag.Type" xml:space="preserve">类型 </x:String>
<x:String x:Key="Text.CreateTag.Type.Annotated" xml:space="preserve">附注标签</x:String>
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">轻量标签</x:String>
<x:String x:Key="Text.Cut" xml:space="preserve">剪切</x:String>
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">删除分支确认</x:String>
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">分支名 </x:String>
<x:String x:Key="Text.DeleteBranch.IsRemoteTip" xml:space="preserve">您正在删除远程上的分支,请务必小心!!!</x:String>
<x:String x:Key="Text.DeleteBranch.WithTrackingRemote" xml:space="preserve">同时删除远程分支${0}$</x:String>
<x:String x:Key="Text.DeleteMultiBranch" xml:space="preserve">删除多个分支</x:String>
<x:String x:Key="Text.DeleteMultiBranch.Tip" xml:space="preserve">您正在尝试一次性删除多个分支,请务必仔细检查后再执行操作!</x:String>
<x:String x:Key="Text.DeleteRemote" xml:space="preserve">删除远程确认</x:String>
<x:String x:Key="Text.DeleteRemote.Remote" xml:space="preserve">远程名 </x:String>
<x:String x:Key="Text.DeleteRepositoryNode.Target" xml:space="preserve">目标 </x:String>
@ -310,8 +320,10 @@
<x:String x:Key="Text.Push.Remote" xml:space="preserve">远程仓库 </x:String>
<x:String x:Key="Text.Push.Title" xml:space="preserve">推送到远程仓库</x:String>
<x:String x:Key="Text.Push.To" xml:space="preserve">远程分支 </x:String>
<x:String x:Key="Text.Push.Tracking" xml:space="preserve">跟踪远程分支(--set-upstream</x:String>
<x:String x:Key="Text.Push.WithAllTags" xml:space="preserve">同时推送标签</x:String>
<x:String x:Key="Text.PushTag" xml:space="preserve">推送标签到远程仓库</x:String>
<x:String x:Key="Text.PushTag.PushAllRemotes" xml:space="preserve">推送到所有远程仓库</x:String>
<x:String x:Key="Text.PushTag.Remote" xml:space="preserve">远程仓库 </x:String>
<x:String x:Key="Text.PushTag.Tag" xml:space="preserve">标签 </x:String>
<x:String x:Key="Text.Quit" xml:space="preserve">退出</x:String>

View file

@ -13,6 +13,9 @@
<Style.Resources>
<x:Double x:Key="ScrollBarSize">12</x:Double>
</Style.Resources>
<Setter Property="ShowDelay" Value="0:0:0.1"/>
<Setter Property="HideDelay" Value="0:0:0.2"/>
</Style>
<Style Selector="ContentPresenter">
@ -133,12 +136,12 @@
</Setter>
</Style>
<Style Selector="TextBox:pointerover /template/ Border#PART_BorderElement">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent1}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}"/>
<Setter Property="Background" Value="{DynamicResource Brush.Contents}"/>
</Style>
<Style Selector="TextBox:focus /template/ Border#PART_BorderElement">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent1}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}"/>
<Setter Property="Background" Value="{DynamicResource Brush.Contents}"/>
</Style>
<Style Selector="TextBox:disabled /template/ Border#PART_BorderElement">
@ -483,37 +486,15 @@
</Style>
<Style Selector="ListBox.page_switcher ListBoxItem">
<Setter Property="Template">
<ControlTemplate>
<Grid>
<ContentPresenter Name="PART_ContentPresenter"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" />
<Border Background="{DynamicResource Brush.FG2}"
Width="4"
HorizontalAlignment="Left" VerticalAlignment="Stretch"
IsHitTestVisible="False"
IsVisible="{TemplateBinding IsSelected}"/>
</Grid>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="ListBox.page_switcher ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Brush.SwitcherBG}"/>
<Setter Property="Margin" Value="4,0,2,0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="CornerRadius" Value="4"/>
</Style>
<Style Selector="ListBox.page_switcher ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Brush.SwitcherHover}"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBox.page_switcher ListBoxItem:selected:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Brush.SwitcherBG}"/>
<Style Selector="ListBox.page_switcher ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Brush.AccentHovered}"/>
</Style>
<Style Selector="ContextMenu">
@ -722,7 +703,7 @@
<Thickness x:Key="ComboBoxDropdownBorderPadding">4,0</Thickness>
<Thickness x:Key="ComboBoxItemThemePadding">6,4</Thickness>
<SolidColorBrush x:Key="ComboBoxDropDownBackground" Color="{DynamicResource Color.Contents}"/>
<SolidColorBrush x:Key="ComboBoxDropDownBorderBrush" Color="{DynamicResource Color.Accent1}"/>
<SolidColorBrush x:Key="ComboBoxDropDownBorderBrush" Color="{DynamicResource SystemAccentColor}"/>
</Style.Resources>
<Setter Property="MinHeight" Value="20"/>
@ -734,7 +715,7 @@
<Setter Property="VerticalOffset" Value="2"/>
</Style>
<Style Selector="^:pointerover /template/ Border#Background">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent1}" />
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="Opacity" Value=".6"/>
@ -758,7 +739,7 @@
</Grid.ColumnDefinitions>
<Border x:Name="Border" Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" Background="Transparent" CornerRadius="2">
<Path x:Name="Icon" Height="12" Width="12" Data="{DynamicResource Icons.Check}" Fill="{DynamicResource Brush.Accent1}" IsVisible="False" Margin="0,2,0,0"/>
<Path x:Name="Icon" Height="12" Width="12" Data="{DynamicResource Icons.Check}" Fill="{DynamicResource Brush.Accent}" IsVisible="False" Margin="0,2,0,0"/>
</Border>
<ContentPresenter x:Name="ContentPresenter"
@ -773,7 +754,7 @@
</Setter>
<Style Selector="^:pointerover /template/ Border#Border">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent1}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}"/>
</Style>
<Style Selector="^:checked /template/ Path#Icon">
<Setter Property="IsVisible" Value="True"/>
@ -817,10 +798,10 @@
</Setter>
<Style Selector="^:pointerover /template/ Ellipse#Border">
<Setter Property="Stroke" Value="{DynamicResource Brush.Accent1}"/>
<Setter Property="Stroke" Value="{DynamicResource Brush.Accent}"/>
</Style>
<Style Selector="^:checked /template/ Ellipse#Dot">
<Setter Property="Fill" Value="{DynamicResource Brush.Accent1}"/>
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}"/>
</Style>
</Style>
@ -897,7 +878,7 @@
<Setter Property="Fill" Value="{DynamicResource Brush.FG2}"/>
</Style>
<Style Selector="ToggleButton.filter:pointerover /template/ Path#PART_IndicatorIcon">
<Setter Property="Stroke" Value="{DynamicResource Brush.Accent2}"/>
<Setter Property="Stroke" Value="{DynamicResource Brush.AccentHovered}"/>
</Style>
<Style Selector="ToggleButton.tree_expander">
<Setter Property="Margin" Value="0" />
@ -964,7 +945,7 @@
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ToggleButton.line_path:checked Path">
<Setter Property="Fill" Value="{DynamicResource Brush.Accent1}"/>
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}"/>
</Style>
<Style Selector="ToggleButton.toggle_untracked">
@ -1002,6 +983,7 @@
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="MinHeight" Value="24"/>
<Setter Property="Opacity" Value="1"/>
<Style.Resources>
<x:Double x:Key="TabItemPipeThickness">1</x:Double>
@ -1009,10 +991,12 @@
</Style>
<Style Selector="TabItem:pointerover TextBlock.tab_header">
<Setter Property="Opacity" Value=".8"/>
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
<Setter Property="Opacity" Value="1"/>
</Style>
<Style Selector="TabItem:selected TextBlock.tab_header">
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}"/>
<Setter Property="Opacity" Value="1"/>
</Style>
@ -1075,11 +1059,11 @@
</Setter>
<Style Selector="^ /template/ Border#PART_LayoutRoot:pointerover">
<Setter Property="Background" Value="{DynamicResource Brush.Accent2}" />
<Setter Property="Background" Value="{DynamicResource Brush.AccentHovered}" />
</Style>
<Style Selector="^:selected /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource Brush.Accent1}" />
<Setter Property="Background" Value="{DynamicResource Brush.Accent}" />
</Style>
</Style>
<Style Selector="TreeViewItem[IsExpanded=True] Path.folder_icon">

View file

@ -14,8 +14,6 @@
<Color x:Key="Color.Decorator">#FF6F6F6F</Color>
<Color x:Key="Color.DecoratorIcon">#FFF8F8F8</Color>
<Color x:Key="Color.Conflict">#FF836C2E</Color>
<Color x:Key="Color.SwitcherHover">#FFDFDFDF</Color>
<Color x:Key="Color.SwitcherBG">#FFCFCFCF</Color>
<Color x:Key="Color.Border0">#FFCFCFCF</Color>
<Color x:Key="Color.Border1">#FF898989</Color>
<Color x:Key="Color.Border2">#FFCFCFCF</Color>
@ -27,9 +25,6 @@
<Color x:Key="Color.FG1">#FF1F1F1F</Color>
<Color x:Key="Color.FG2">#FF6F6F6F</Color>
<Color x:Key="Color.FG3">#FFFFFFFF</Color>
<Color x:Key="Color.Accent1">#FF4295FF</Color>
<Color x:Key="Color.Accent1Hovered">#FF529DFB</Color>
<Color x:Key="Color.Accent2">#4C007ACC</Color>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
@ -45,8 +40,6 @@
<Color x:Key="Color.Decorator">#FF505050</Color>
<Color x:Key="Color.DecoratorIcon">#FFF8F8F8</Color>
<Color x:Key="Color.Conflict">#FFFAFAD2</Color>
<Color x:Key="Color.SwitcherHover">#FF323232</Color>
<Color x:Key="Color.SwitcherBG">#FF3F3F3F</Color>
<Color x:Key="Color.Border0">#FF181818</Color>
<Color x:Key="Color.Border1">#FF7C7C7C</Color>
<Color x:Key="Color.Border2">#FF404040</Color>
@ -58,9 +51,6 @@
<Color x:Key="Color.FG1">#FFF1F1F1</Color>
<Color x:Key="Color.FG2">#40F1F1F1</Color>
<Color x:Key="Color.FG3">#FF252525</Color>
<Color x:Key="Color.Accent1">#FF007ACC</Color>
<Color x:Key="Color.Accent1Hovered">#FF006BBE</Color>
<Color x:Key="Color.Accent2">#8C007ACC</Color>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
@ -76,8 +66,6 @@
<SolidColorBrush x:Key="Brush.Decorator" Color="{DynamicResource Color.Decorator}"/>
<SolidColorBrush x:Key="Brush.DecoratorIcon" Color="{DynamicResource Color.DecoratorIcon}"/>
<SolidColorBrush x:Key="Brush.Conflict" Color="{DynamicResource Color.Conflict}"/>
<SolidColorBrush x:Key="Brush.SwitcherHover" Color="{DynamicResource Color.SwitcherHover}"/>
<SolidColorBrush x:Key="Brush.SwitcherBG" Color="{DynamicResource Color.SwitcherBG}"/>
<SolidColorBrush x:Key="Brush.Border0" Color="{DynamicResource Color.Border0}"/>
<SolidColorBrush x:Key="Brush.Border1" Color="{DynamicResource Color.Border1}"/>
<SolidColorBrush x:Key="Brush.Border2" Color="{DynamicResource Color.Border2}"/>
@ -89,7 +77,6 @@
<SolidColorBrush x:Key="Brush.FG1" Color="{DynamicResource Color.FG1}"/>
<SolidColorBrush x:Key="Brush.FG2" Color="{DynamicResource Color.FG2}"/>
<SolidColorBrush x:Key="Brush.FG3" Color="{DynamicResource Color.FG3}"/>
<SolidColorBrush x:Key="Brush.Accent1" Color="{DynamicResource Color.Accent1}"/>
<SolidColorBrush x:Key="Brush.Accent1Hovered" Color="{DynamicResource Color.Accent1Hovered}"/>
<SolidColorBrush x:Key="Brush.Accent2" Color="{DynamicResource Color.Accent2}"/>
<SolidColorBrush x:Key="Brush.Accent" Color="{DynamicResource SystemAccentColor}"/>
<SolidColorBrush x:Key="Brush.AccentHovered" Color="{DynamicResource SystemListLowColor}"/>
</ResourceDictionary>

View file

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
@ -29,13 +30,18 @@ namespace SourceGit.ViewModels
public bool UseSSH
{
get => _useSSH;
set => SetProperty(ref _useSSH, value);
set
{
if (SetProperty(ref _useSSH, value))
ValidateProperty(_sshkey, nameof(SSHKey));
}
}
[CustomValidation(typeof(AddRemote), nameof(ValidateSSHKey))]
public string SSHKey
{
get;
set;
get => _sshkey;
set => SetProperty(ref _sshkey, value, true);
}
public AddRemote(Repository repo)
@ -71,6 +77,20 @@ namespace SourceGit.ViewModels
return ValidationResult.Success;
}
public static ValidationResult ValidateSSHKey(string sshkey, ValidationContext ctx)
{
if (ctx.ObjectInstance is AddRemote add && add._useSSH)
{
if (string.IsNullOrEmpty(sshkey))
return new ValidationResult("SSH private key is required");
if (!File.Exists(sshkey))
return new ValidationResult("Given SSH private key can NOT be found!");
}
return ValidationResult.Success;
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
@ -84,11 +104,8 @@ namespace SourceGit.ViewModels
SetProgressDescription("Fetching from added remote ...");
new Commands.Fetch(_repo.FullPath, _name, true, SetProgressDescription).Exec();
if (_useSSH)
{
SetProgressDescription("Post processing ...");
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", SSHKey);
}
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
}
CallUIThread(() =>
{
@ -103,5 +120,6 @@ namespace SourceGit.ViewModels
private string _name = string.Empty;
private string _url = string.Empty;
private bool _useSSH = false;
private string _sshkey = string.Empty;
}
}

View file

@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using Avalonia;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
{
public enum BranchTreeNodeType
@ -13,8 +17,10 @@ namespace SourceGit.ViewModels
Branch,
}
public class BranchTreeNode
public class BranchTreeNode : ObservableObject
{
public const double DEFAULT_CORNER = 4.0;
public string Name { get; set; }
public BranchTreeNodeType Type { get; set; }
public object Backend { get; set; }
@ -57,6 +63,43 @@ namespace SourceGit.ViewModels
get => IsBranch && (Backend as Models.Branch).IsCurrent;
}
public bool IsSelected
{
get => _isSelected;
set => SetProperty(ref _isSelected, value);
}
public CornerRadius CornerRadius
{
get => _cornerRadius;
set => SetProperty(ref _cornerRadius, value);
}
public void UpdateCornerRadius(ref BranchTreeNode prev)
{
if (_isSelected && prev != null && prev.IsSelected)
{
var prevTop = prev.CornerRadius.TopLeft;
prev.CornerRadius = new CornerRadius(prevTop, 0);
CornerRadius = new CornerRadius(0, DEFAULT_CORNER);
}
else if (CornerRadius.TopLeft != DEFAULT_CORNER ||
CornerRadius.BottomLeft != DEFAULT_CORNER)
{
CornerRadius = new CornerRadius(DEFAULT_CORNER);
}
prev = this;
if (!IsBranch && IsExpanded)
{
foreach (var child in Children)
child.UpdateCornerRadius(ref prev);
}
}
private bool _isSelected = false;
private CornerRadius _cornerRadius = new CornerRadius(DEFAULT_CORNER);
public class Builder
{
public List<BranchTreeNode> Locals => _locals;

View file

@ -113,7 +113,7 @@ namespace SourceGit.ViewModels
CallUIThread(() =>
{
var repo = Preference.AddRepository(path, Path.Combine(path, ".git"));
var node = Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, null);
var node = Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, null, true);
_launcher.OpenRepositoryInTab(node, _page);
});

View file

@ -3,6 +3,13 @@ using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public enum BeforeCreateBranchAction
{
StashAndReaply,
Discard,
DoNothing,
}
public class CreateBranch : Popup
{
[Required(ErrorMessage = "Branch name is required!")]
@ -20,13 +27,13 @@ namespace SourceGit.ViewModels
private set;
}
public bool CheckoutAfterCreated
public BeforeCreateBranchAction PreAction
{
get;
set;
} = true;
get => _preAction;
set => SetProperty(ref _preAction, value);
}
public bool AutoStash
public bool CheckoutAfterCreated
{
get;
set;
@ -90,7 +97,7 @@ namespace SourceGit.ViewModels
bool needPopStash = false;
if (_repo.WorkingCopyChangesCount > 0)
{
if (AutoStash)
if (_preAction == BeforeCreateBranchAction.StashAndReaply)
{
SetProgressDescription("Adding untracked changes...");
var succ = new Commands.Add(_repo.FullPath).Exec();
@ -108,7 +115,7 @@ namespace SourceGit.ViewModels
needPopStash = true;
}
else
else if (_preAction == BeforeCreateBranchAction.Discard)
{
SetProgressDescription("Discard local changes...");
Commands.Discard.All(_repo.FullPath);
@ -137,5 +144,6 @@ namespace SourceGit.ViewModels
private readonly Repository _repo = null;
private string _name = null;
private readonly string _baseOnRevision = null;
private BeforeCreateBranchAction _preAction = BeforeCreateBranchAction.StashAndReaply;
}
}

View file

@ -1,12 +1,16 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class CreateTag : Popup
{
public object BasedOn
{
get;
private set;
}
[Required(ErrorMessage = "Tag name is required!")]
[RegularExpression(@"^[\w\-\.]+$", ErrorMessage = "Bad tag name format!")]
[CustomValidation(typeof(CreateTag), nameof(ValidateTagName))]
@ -22,11 +26,23 @@ namespace SourceGit.ViewModels
set;
}
public object BasedOn
public bool Annotated
{
get => _annotated;
set => SetProperty(ref _annotated, value);
}
public bool SignTag
{
get;
private set;
}
set;
} = false;
public bool PushToAllRemotes
{
get;
set;
} = true;
public CreateTag(Repository repo, Models.Branch branch)
{
@ -65,14 +81,29 @@ namespace SourceGit.ViewModels
return Task.Run(() =>
{
Commands.Tag.Add(_repo.FullPath, TagName, _basedOn, Message);
var succ = false;
if (_annotated)
succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag);
else
succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn);
if (succ && PushToAllRemotes)
{
foreach (var remote in _repo.Remotes)
{
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
new Commands.Push(_repo.FullPath, remote.Name, _tagName, false).Exec();
}
}
CallUIThread(() => _repo.SetWatcherEnabled(true));
return true;
return succ;
});
}
private readonly Repository _repo = null;
private string _tagName = string.Empty;
private bool _annotated = true;
private readonly string _basedOn = string.Empty;
}
}

View file

@ -52,14 +52,17 @@ namespace SourceGit.ViewModels
{
if (Target.IsLocal)
{
Commands.Branch.Delete(_repo.FullPath, Target.Name);
Commands.Branch.DeleteLocal(_repo.FullPath, Target.Name);
if (_alsoDeleteTrackingRemote && TrackingRemoteBranch != null)
new Commands.Push(_repo.FullPath, TrackingRemoteBranch.Remote, TrackingRemoteBranch.Name).Exec();
{
SetProgressDescription("Deleting tracking remote branch...");
Commands.Branch.DeleteRemote(_repo.FullPath, TrackingRemoteBranch.Remote, TrackingRemoteBranch.Name);
}
}
else
{
new Commands.Push(_repo.FullPath, Target.Remote, Target.Name).Exec();
Commands.Branch.DeleteRemote(_repo.FullPath, Target.Remote, Target.Name);
}
CallUIThread(() => _repo.SetWatcherEnabled(true));

View file

@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class DeleteMultipleBranches : Popup
{
public List<Models.Branch> Targets
{
get;
}
public DeleteMultipleBranches(Repository repo, List<Models.Branch> branches, bool isLocal)
{
_repo = repo;
_isLocal = isLocal;
Targets = branches;
View = new Views.DeleteMultipleBranches() { DataContext = this };
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = "Deleting multiple branches...";
return Task.Run(() =>
{
if (_isLocal)
{
foreach (var target in Targets)
{
SetProgressDescription($"Deleting local branch : {target.Name}");
Commands.Branch.DeleteLocal(_repo.FullPath, target.Name);
}
}
else
{
foreach (var target in Targets)
{
SetProgressDescription($"Deleting remote branch : {target.Remote}/{target.Name}");
Commands.Branch.DeleteRemote(_repo.FullPath, target.Remote, target.Name);
}
}
CallUIThread(() => _repo.SetWatcherEnabled(true));
return true;
});
}
private Repository _repo = null;
private bool _isLocal = false;
}
}

View file

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
@ -29,13 +30,18 @@ namespace SourceGit.ViewModels
public bool UseSSH
{
get => _useSSH;
set => SetProperty(ref _useSSH, value);
set
{
if (SetProperty(ref _useSSH, value))
ValidateProperty(_sshkey, nameof(SSHKey));
}
}
[CustomValidation(typeof(EditRemote), nameof(ValidateSSHKey))]
public string SSHKey
{
get;
set;
get => _sshkey;
set => SetProperty(ref _sshkey, value, true);
}
public EditRemote(Repository repo, Models.Remote remote)
@ -85,6 +91,20 @@ namespace SourceGit.ViewModels
return ValidationResult.Success;
}
public static ValidationResult ValidateSSHKey(string sshkey, ValidationContext ctx)
{
if (ctx.ObjectInstance is EditRemote edit && edit.UseSSH)
{
if (string.IsNullOrEmpty(sshkey))
return new ValidationResult("SSH private key is required");
if (!File.Exists(sshkey))
return new ValidationResult("Given SSH private key can NOT be found!");
}
return ValidationResult.Success;
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
@ -106,11 +126,8 @@ namespace SourceGit.ViewModels
_remote.URL = _url;
}
if (_useSSH)
{
SetProgressDescription("Post processing ...");
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", SSHKey);
}
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
CallUIThread(() => _repo.SetWatcherEnabled(true));
return true;
@ -122,5 +139,6 @@ namespace SourceGit.ViewModels
private string _name = string.Empty;
private string _url = string.Empty;
private bool _useSSH = false;
private string _sshkey = string.Empty;
}
}

View file

@ -11,9 +11,11 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _targetPath, value);
}
public Init(string path)
public Init(string path, RepositoryNode parent)
{
TargetPath = path;
_targetPath = path;
_parentNode = parent;
View = new Views.Init() { DataContext = this };
}
@ -31,13 +33,14 @@ namespace SourceGit.ViewModels
CallUIThread(() =>
{
var repo = Preference.AddRepository(_targetPath, gitDir);
Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, null);
Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, _parentNode, true);
});
return true;
});
}
private string _targetPath;
private string _targetPath = string.Empty;
private RepositoryNode _parentNode = null;
}
}

View file

@ -32,7 +32,27 @@ namespace SourceGit.ViewModels
Pages = new AvaloniaList<LauncherPage>();
AddNewTab();
if (Preference.Instance.RestoreTabs)
var commandlines = Environment.GetCommandLineArgs();
if (commandlines.Length == 2)
{
var path = commandlines[1];
var root = new Commands.QueryRepositoryRootPath(path).Result();
if (string.IsNullOrEmpty(root))
{
Pages[0].Notifications.Add(new Models.Notification
{
IsError = true,
Message = $"Given path: '{path}' is NOT a valid repository!"
});
return;
}
var gitDir = new Commands.QueryGitDir(root).Result();
var repo = Preference.AddRepository(root, gitDir);
var node = Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, null, false);
OpenRepositoryInTab(node, null);
}
else if (Preference.Instance.RestoreTabs)
{
foreach (var id in Preference.Instance.OpenedTabs)
{

View file

@ -363,7 +363,7 @@ namespace SourceGit.ViewModels
return FindNodeRecursive(id, _instance.RepositoryNodes);
}
public static RepositoryNode FindOrAddNodeByRepositoryPath(string repo, RepositoryNode parent)
public static RepositoryNode FindOrAddNodeByRepositoryPath(string repo, RepositoryNode parent, bool shouldMoveNode)
{
var node = FindNodeRecursive(repo, _instance.RepositoryNodes);
if (node == null)
@ -378,7 +378,7 @@ namespace SourceGit.ViewModels
AddNode(node, parent);
}
else
else if (shouldMoveNode)
{
MoveNode(node, parent);
}

View file

@ -82,6 +82,12 @@ namespace SourceGit.ViewModels
set;
}
public bool Tracking
{
get;
set;
} = true;
public bool ForcePush
{
get;
@ -154,7 +160,7 @@ namespace SourceGit.ViewModels
remoteBranchName,
PushAllTags,
ForcePush,
string.IsNullOrEmpty(_selectedLocalBranch.Upstream),
Tracking,
SetProgressDescription).Exec();
CallUIThread(() => _repo.SetWatcherEnabled(true));
return succ;

View file

@ -22,6 +22,12 @@ namespace SourceGit.ViewModels
set;
}
public bool PushAllRemotes
{
get => _pushAllRemotes;
set => SetProperty(ref _pushAllRemotes, value);
}
public PushTag(Repository repo, Models.Tag target)
{
_repo = repo;
@ -33,16 +39,33 @@ namespace SourceGit.ViewModels
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = $"Pushing tag '{Target.Name}' to remote '{SelectedRemote.Name}' ...";
ProgressDescription = $"Pushing tag ...";
return Task.Run(() =>
{
var succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec();
bool succ = true;
if (_pushAllRemotes)
{
foreach (var remote in _repo.Remotes)
{
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
succ = new Commands.Push(_repo.FullPath, remote.Name, Target.Name, false).Exec();
if (!succ)
break;
}
}
else
{
SetProgressDescription($"Pushing tag to remote {SelectedRemote.Name} ...");
succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec();
}
CallUIThread(() => _repo.SetWatcherEnabled(true));
return succ;
});
}
private readonly Repository _repo = null;
private bool _pushAllRemotes = false;
}
}

View file

@ -730,6 +730,12 @@ namespace SourceGit.ViewModels
PopupHost.ShowPopup(new CheckoutCommit(this, commit));
}
public void DeleteMultipleBranches(List<Models.Branch> branches, bool isLocal)
{
if (PopupHost.CanCreatePopup())
PopupHost.ShowPopup(new DeleteMultipleBranches(this, branches, isLocal));
}
public void CreateNewTag()
{
var current = Branches.Find(x => x.IsCurrent);

View file

@ -26,7 +26,7 @@ namespace SourceGit.ViewModels
}
}
public void InitRepository(string path)
public void InitRepository(string path, RepositoryNode parent)
{
if (!Preference.Instance.IsGitConfigured)
{
@ -36,7 +36,7 @@ namespace SourceGit.ViewModels
if (PopupHost.CanCreatePopup())
{
PopupHost.ShowPopup(new Init(path));
PopupHost.ShowPopup(new Init(path, parent));
}
}

View file

@ -70,7 +70,7 @@
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="0,8,32,8">
<StackPanel Height="48" Orientation="Horizontal">
<TextBlock Classes="bold" Text="SourceGit" FontSize="32" />
<Border Margin="12,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent1}" Effect="drop-shadow(0 0 6 #40000000)">
<Border Margin="12,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent}" Effect="drop-shadow(0 0 6 #40000000)">
<TextBlock Classes="monospace" Margin="8,0" Text="{Binding Version}" FontSize="12" Foreground="White"/>
</Border>
</StackPanel>
@ -82,19 +82,19 @@
<StackPanel Orientation="Vertical" Margin="0,24,0,0">
<StackPanel Orientation="Horizontal" Height="18">
<TextBlock Text="{DynamicResource Text.About.BuildWith}" />
<TextBlock Text="Avalonia UI" Cursor="Hand" Foreground="{DynamicResource Brush.Accent1}" TextDecorations="Underline" PointerPressed="OnVisitAvaloniaUI"/>
<TextBlock Text="Avalonia UI" Cursor="Hand" Foreground="{DynamicResource Brush.Accent}" TextDecorations="Underline" PointerPressed="OnVisitAvaloniaUI"/>
<TextBlock Text=" &amp; " />
<TextBlock Text="AvaloniaEdit" Cursor="Hand" Foreground="{DynamicResource Brush.Accent1}" TextDecorations="Underline" PointerPressed="OnVisitAvaloniaEdit"/>
<TextBlock Text="AvaloniaEdit" Cursor="Hand" Foreground="{DynamicResource Brush.Accent}" TextDecorations="Underline" PointerPressed="OnVisitAvaloniaEdit"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Height="18" Margin="0,2,0,0">
<TextBlock Text="{DynamicResource Text.About.Fonts}" />
<TextBlock Text="JetBrains Mono" Cursor="Hand" Foreground="{DynamicResource Brush.Accent1}" TextDecorations="Underline" PointerPressed="OnVisitJetBrainsMonoFont"/>
<TextBlock Text="JetBrains Mono" Cursor="Hand" Foreground="{DynamicResource Brush.Accent}" TextDecorations="Underline" PointerPressed="OnVisitJetBrainsMonoFont"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Height="18" Margin="0,2,0,0">
<TextBlock Text="{DynamicResource Text.About.SourceCode}" />
<TextBlock Text="Github" Cursor="Hand" Foreground="{DynamicResource Brush.Accent1}" TextDecorations="Underline" PointerPressed="OnVisitSourceCode"/>
<TextBlock Text="Github" Cursor="Hand" Foreground="{DynamicResource Brush.Accent}" TextDecorations="Underline" PointerPressed="OnVisitSourceCode"/>
</StackPanel>
</StackPanel>
</StackPanel>

View file

@ -299,7 +299,8 @@ namespace SourceGit.Views
var menu = new ContextMenu();
menu.Items.Add(copy);
menu.Open(TextArea.TextView);
TextArea.TextView.OpenContextMenu(menu);
e.Handled = true;
}

View file

@ -22,9 +22,9 @@
Height="26"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="Transparent"
CornerRadius="4"
Watermark="{DynamicResource Text.CommitDetail.Changes.Search}"
Text="{Binding SearchChangeFilter, Mode=TwoWay}"
v:AutoFocusBehaviour.IsEnabled="True">
Text="{Binding SearchChangeFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>
<Path Width="14" Height="14" Margin="4,0,0,0" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Search}"/>
</TextBox.InnerLeftContent>

View file

@ -24,7 +24,7 @@ namespace SourceGit.Views
{
var detail = DataContext as ViewModels.CommitDetail;
var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
menu.Open(datagrid);
datagrid.OpenContextMenu(menu);
}
e.Handled = true;
@ -39,7 +39,7 @@ namespace SourceGit.Views
if (node != null && !node.IsFolder)
{
var menu = detail.CreateChangeContextMenu(node.Backend as Models.Change);
menu.Open(view);
view.OpenContextMenu(menu);
}
}

View file

@ -33,7 +33,7 @@ namespace SourceGit.Views
}
var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
menu.Open(datagrid);
datagrid.OpenContextMenu(menu);
}
e.Handled = true;
}

View file

@ -0,0 +1,26 @@
using System.ComponentModel;
using Avalonia.Controls;
namespace SourceGit.Views
{
public static class ContextMenuExtension
{
public static void OpenContextMenu(this Control control, ContextMenu menu)
{
if (menu == null) return;
menu.PlacementTarget = control;
menu.Closing += OnContextMenuClosing; // Clear context menu because it is dynamic.
control.ContextMenu = menu;
control.ContextMenu.Open();
}
private static void OnContextMenuClosing(object sender, CancelEventArgs e)
{
if (sender is ContextMenu menu && menu.PlacementTarget != null)
menu.PlacementTarget.ContextMenu = null;
}
}
}

View file

@ -62,10 +62,15 @@
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.StashAndReply}"
GroupName="LocalChanges"
IsChecked="{Binding AutoStash, Mode=TwoWay}"/>
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={x:Static c:EnumConverters.Equals}, ConverterParameter={x:Static vm:BeforeCreateBranchAction.StashAndReaply}}"/>
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.Discard}"
GroupName="LocalChanges"
Margin="8,0,0,0"/>
Margin="8,0,0,0"
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={x:Static c:EnumConverters.Equals}, ConverterParameter={x:Static vm:BeforeCreateBranchAction.Discard}}"/>
<RadioButton Content="{DynamicResource Text.CreateBranch.LocalChanges.DoNothing}"
GroupName="LocalChanges"
Margin="8,0,0,0"
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={x:Static c:EnumConverters.Equals}, ConverterParameter={x:Static vm:BeforeCreateBranchAction.DoNothing}}"/>
</StackPanel>
<CheckBox Grid.Row="3" Grid.Column="1"

View file

@ -13,7 +13,7 @@
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.CreateTag}"/>
<Grid Margin="0,16,8,0" RowDefinitions="32,32,64" ColumnDefinitions="150,*">
<Grid Margin="0,16,8,0" RowDefinitions="32,32,32,Auto,Auto,32" ColumnDefinitions="150,*">
<TextBlock Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
@ -49,16 +49,41 @@
v:AutoFocusBehaviour.IsEnabled="True"/>
<TextBlock Grid.Row="2" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.CreateTag.Type}"/>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
<RadioButton Content="{DynamicResource Text.CreateTag.Type.Annotated}"
GroupName="TagKind"
IsChecked="{Binding Annotated, Mode=TwoWay}"/>
<RadioButton Content="{DynamicResource Text.CreateTag.Type.Lightweight}"
GroupName="TagKind"
Margin="8,0,0,0"/>
</StackPanel>
<TextBlock Grid.Row="3" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="0,6,8,0"
Text="{DynamicResource Text.CreateTag.Message}"/>
<TextBox Grid.Row="2" Grid.Column="1"
Height="56"
Text="{DynamicResource Text.CreateTag.Message}"
IsVisible="{Binding Annotated}"/>
<TextBox Grid.Row="3" Grid.Column="1"
Height="64"
AcceptsReturn="True" AcceptsTab="False"
VerticalAlignment="Center" VerticalContentAlignment="Top"
CornerRadius="2"
Watermark="{DynamicResource Text.CreateTag.Message.Placeholder}"
Text="{Binding Message, Mode=TwoWay}"/>
Text="{Binding Message, Mode=TwoWay}"
IsVisible="{Binding Annotated}"/>
<CheckBox Grid.Row="4" Grid.Column="1"
Height="32" Margin="0,4,0,0"
Content="{DynamicResource Text.CreateTag.GPGSign}"
IsChecked="{Binding SignTag, Mode=TwoWay}"
IsVisible="{Binding Annotated}"/>
<CheckBox Grid.Row="5" Grid.Column="1"
Content="{DynamicResource Text.CreateTag.PushToAllRemotes}"
IsChecked="{Binding PushToAllRemotes, Mode=TwoWay}"/>
</Grid>
</StackPanel>
</UserControl>

View file

@ -0,0 +1,82 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.DeleteMultipleBranches"
x:DataType="vm:DeleteMultipleBranches">
<StackPanel Orientation="Vertical" Margin="8,0">
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.DeleteMultiBranch}" />
<Border Margin="4,16,0,0"
Background="{DynamicResource Brush.Contents}"
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border1}"
CornerRadius="4"
Padding="4">
<DataGrid MaxHeight="200"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Targets}"
SelectionMode="Single"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
IsReadOnly="True"
HeadersVisibility="None"
Focusable="False"
RowHeight="26"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<DataGrid.Styles>
<Style Selector="DataGridRow">
<Setter Property="CornerRadius" Value="4" />
</Style>
<Style Selector="DataGridRow /template/ Border#RowBorder">
<Setter Property="ClipToBounds" Value="True" />
</Style>
<Style Selector="DataGridRow:pointerover /template/ Rectangle#BackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource Brush.AccentHovered}" />
</Style>
<Style Selector="DataGridRow:selected /template/ Rectangle#BackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}" />
</Style>
</DataGrid.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Header="ICON">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Path Width="10" Height="10" Margin="4,0,8,0" Data="{StaticResource Icons.Branch}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*" Header="NAME">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={x:Static c:BranchConverters.ToName}}" ClipToBounds="True"
Classes="monospace" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border>
<TextBlock Margin="4,8,0,0"
Text="{DynamicResource Text.DeleteMultiBranch.Tip}"
TextWrapping="Wrap"
Foreground="{DynamicResource Brush.FG2}"
FontStyle="Italic" />
</StackPanel>
</UserControl>

View file

@ -0,0 +1,13 @@
using Avalonia.Controls;
namespace SourceGit.Views
{
public partial class DeleteMultipleBranches : UserControl
{
public DeleteMultipleBranches()
{
InitializeComponent();
}
}
}

View file

@ -12,7 +12,7 @@
<StackPanel Orientation="Vertical" Margin="8,0">
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.Remote.AddTitle}"/>
Text="{DynamicResource Text.Remote.EditTitle}"/>
<Grid Margin="0,16,0,0" RowDefinitions="32,32,Auto" ColumnDefinitions="150,*">
<TextBlock Grid.Row="0" Grid.Column="0"

View file

@ -300,7 +300,7 @@ namespace SourceGit.Views
if (DataContext is ViewModels.Histories histories)
{
var menu = histories.MakeContextMenu();
menu?.Open(sender as Control);
(sender as Control)?.OpenContextMenu(menu);
}
e.Handled = true;
}

View file

@ -321,7 +321,7 @@
<ProgressBar Margin="0,8,0,0"
HorizontalAlignment="Stretch"
IsIndeterminate="True"
Background="{DynamicResource Brush.FG2}" Foreground="{DynamicResource Brush.Accent1}"
Background="{DynamicResource Brush.FG2}" Foreground="{DynamicResource Brush.Accent}"
Minimum="0" Maximum="100"/>
</StackPanel>
</StackPanel>

View file

@ -396,17 +396,10 @@
<Grid Margin="8" RowDefinitions="32,32,32" ColumnDefinitions="Auto,*">
<TextBlock Grid.Row="0" Grid.Column="0"
Text="{DynamicResource Text.Preference.GPG.Enabled}"
HorizontalAlignment="Right"
Margin="0,0,16,0"/>
<CheckBox Grid.Row="0" Grid.Column="1"
IsChecked="{Binding #me.EnableGPGSigning, Mode=TwoWay}"/>
<TextBlock Grid.Row="1" Grid.Column="0"
Text="{DynamicResource Text.Preference.GPG.Path}"
HorizontalAlignment="Right"
Margin="0,0,16,0"/>
<TextBox Grid.Row="1" Grid.Column="1"
<TextBox Grid.Row="0" Grid.Column="1"
Height="28"
CornerRadius="3"
Text="{Binding #me.GPGExecutableFile, Mode=TwoWay}">
@ -417,15 +410,19 @@
</TextBox.InnerRightContent>
</TextBox>
<TextBlock Grid.Row="2" Grid.Column="0"
<TextBlock Grid.Row="1" Grid.Column="0"
Text="{DynamicResource Text.Preference.GPG.UserKey}"
HorizontalAlignment="Right"
Margin="0,0,16,0"/>
<TextBox Grid.Row="2" Grid.Column="1"
<TextBox Grid.Row="1" Grid.Column="1"
Height="28"
CornerRadius="3"
Text="{Binding #me.GPGUserKey, Mode=TwoWay}"
Watermark="{DynamicResource Text.Preference.GPG.UserKey.Placeholder}"/>
<CheckBox Grid.Row="2" Grid.Column="1"
Content="{DynamicResource Text.Preference.GPG.Enabled}"
IsChecked="{Binding #me.EnableGPGSigning, Mode=TwoWay}"/>
</Grid>
</TabItem>

View file

@ -207,10 +207,17 @@ namespace SourceGit.Views
private async void SelectGPGExecutable(object sender, RoutedEventArgs e)
{
var pattern = OperatingSystem.IsWindows() ? "gpg.exe" : "gpg";
var patterns = new List<string>();
if (OperatingSystem.IsWindows())
patterns.Add("gpg.exe");
else if (OperatingSystem.IsLinux())
patterns.AddRange(new string[] { "gpg", "gpg2" });
else
patterns.Add("gpg");
var options = new FilePickerOpenOptions()
{
FileTypeFilter = [new FilePickerFileType("GPG Executable") { Patterns = [pattern] }],
FileTypeFilter = [new FilePickerFileType("GPG Executable") { Patterns = patterns }],
AllowMultiple = false,
};

View file

@ -13,7 +13,7 @@
Classes="bold"
Text="{DynamicResource Text.Push.Title}"/>
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32,32" ColumnDefinitions="150,*">
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32,32,32" ColumnDefinitions="150,*">
<TextBlock Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
@ -73,10 +73,14 @@
</ComboBox>
<CheckBox Grid.Row="3" Grid.Column="1"
Content="{DynamicResource Text.Push.Tracking}"
IsChecked="{Binding Tracking, Mode=TwoWay}"/>
<CheckBox Grid.Row="4" Grid.Column="1"
Content="{DynamicResource Text.Push.WithAllTags}"
IsChecked="{Binding PushAllTags, Mode=TwoWay}"/>
<CheckBox Grid.Row="4" Grid.Column="1"
<CheckBox Grid.Row="5" Grid.Column="1"
Content="{DynamicResource Text.Push.Force}"
IsChecked="{Binding ForcePush, Mode=TwoWay}"/>
</Grid>

View file

@ -12,7 +12,7 @@
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.PushTag}"/>
<Grid Margin="0,16,0,0" RowDefinitions="32,32" ColumnDefinitions="150,*">
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32" ColumnDefinitions="150,*">
<TextBlock Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
@ -31,7 +31,8 @@
Height="28" Padding="8,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
ItemsSource="{Binding Remotes}"
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}">
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}"
IsEnabled="{Binding !PushAllRemotes}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="{x:Type m:Remote}">
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
@ -41,6 +42,10 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<CheckBox Grid.Row="2" Grid.Column="1"
Content="{DynamicResource Text.PushTag.PushAllRemotes}"
IsChecked="{Binding PushAllRemotes, Mode=TwoWay}"/>
</Grid>
</StackPanel>
</UserControl>

View file

@ -109,7 +109,7 @@
</Grid.ColumnDefinitions>
<!-- Left Normal Mode -->
<Grid Grid.Column="0" RowDefinitions="28,Auto,5,28,28,Auto,28,*,28,Auto,28,Auto" Margin="0,0,0,4" IsVisible="{Binding !IsSearching}">
<Grid Grid.Column="0" Classes="repository_leftpanel" RowDefinitions="28,Auto,5,28,28,Auto,28,*,28,Auto,28,Auto" Margin="0,0,0,4" IsVisible="{Binding !IsSearching}">
<!-- WorkingCopy -->
<TextBlock Grid.Row="0" Classes="group_header_label" Text="{DynamicResource Text.Repository.Workspace}"/>
<ListBox Grid.Row="1" Classes="page_switcher" Background="Transparent" SelectedIndex="{Binding SelectedViewIndex, Mode=TwoWay}">
@ -119,14 +119,14 @@
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem Height="28" Padding="0">
<ListBoxItem Height="28">
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="20,*">
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Data="{StaticResource Icons.Histories}"/>
<TextBlock Grid.Column="1" Classes="monospace" Text="{DynamicResource Text.Histories}"/>
</Grid>
</ListBoxItem>
<ListBoxItem Height="28" Padding="0">
<ListBoxItem Height="28">
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="20,*,Auto">
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Data="{StaticResource Icons.Send}"/>
<TextBlock Grid.Column="1" Classes="monospace" Text="{DynamicResource Text.WorkingCopy}"/>
@ -142,7 +142,7 @@
</Grid>
</ListBoxItem>
<ListBoxItem Height="28" Padding="0">
<ListBoxItem Height="28">
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="20,*,Auto">
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Data="{StaticResource Icons.Stashes}"/>
<TextBlock Grid.Column="1" Classes="monospace" Text="{DynamicResource Text.Stashes}"/>
@ -198,19 +198,31 @@
<TreeView Grid.Row="5"
x:Name="localBranchTree"
MaxHeight="400"
Margin="4,0,2,0"
SelectionMode="Multiple"
ItemsSource="{Binding LocalBranchTrees}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
LostFocus="OnLocalBranchTreeLostFocus"
ContextRequested="OnLocalBranchContextMenuRequested"
SelectionChanged="OnLocalBranchTreeSelectionChanged">
<TreeView.Styles>
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
<Setter Property="CornerRadius" Value="{Binding CornerRadius}"/>
</Style>
<Style Selector="Grid.repository_leftpanel TreeViewItem:selected /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource Brush.AccentHovered}" />
</Style>
<Style Selector="Grid.repository_leftpanel:focus-within TreeViewItem:selected /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource Brush.Accent}" />
</Style>
</TreeView.Styles>
<TreeView.ItemTemplate>
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
<Grid Height="24" ColumnDefinitions="20,*,Auto,Auto" Background="Transparent" ContextRequested="OnLocalBranchContextMenuRequested" DoubleTapped="OnDoubleTappedLocalBranchNode">
<Grid Height="24" ColumnDefinitions="20,*,Auto,Auto" Background="Transparent" DoubleTapped="OnDoubleTappedLocalBranchNode">
<Path Grid.Column="0" Classes="folder_icon" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,1,0,0" IsVisible="{Binding IsFolder}"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Check}" IsVisible="{Binding IsCurrent}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" VerticalAlignment="Center">
@ -250,20 +262,32 @@
</Grid>
<TreeView Grid.Row="7"
x:Name="remoteBranchTree"
Margin="4,0,2,0"
SelectionMode="Multiple"
ItemsSource="{Binding RemoteBranchTrees}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
LostFocus="OnRemoteBranchTreeLostFocus"
ContextRequested="OnRemoteBranchContextMenuRequested"
SelectionChanged="OnRemoteBranchTreeSelectionChanged">
<TreeView.Styles>
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
<Setter Property="CornerRadius" Value="{Binding CornerRadius}"/>
</Style>
<Style Selector="Grid.repository_leftpanel TreeViewItem:selected /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource Brush.AccentHovered}" />
</Style>
<Style Selector="Grid.repository_leftpanel:focus-within TreeViewItem:selected /template/ Border#PART_LayoutRoot">
<Setter Property="Background" Value="{DynamicResource Brush.Accent}" />
</Style>
</TreeView.Styles>
<TreeView.ItemTemplate>
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type vm:BranchTreeNode}">
<Grid Height="24" ColumnDefinitions="20,*,Auto" Background="Transparent" ContextRequested="OnRemoteBranchContextMenuRequested">
<Grid Height="24" ColumnDefinitions="20,*,Auto" Background="Transparent">
<Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" HorizontalAlignment="Left" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Remote}" IsVisible="{Binding IsRemote}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" IsVisible="{Binding IsBranch}" VerticalAlignment="Center"/>
@ -294,7 +318,9 @@
</Grid>
</ToggleButton>
<DataGrid Grid.Row="9"
x:Name="tagsList"
MaxHeight="200"
Margin="4,0,2,0"
Background="Transparent"
ItemsSource="{Binding Tags}"
SelectionMode="Single"
@ -307,10 +333,27 @@
RowHeight="24"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
LostFocus="OnTagDataGridLostFocus"
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
SelectionChanged="OnTagDataGridSelectionChanged"
ContextRequested="OnTagContextRequested">
<DataGrid.Styles>
<Style Selector="DataGridRow">
<Setter Property="CornerRadius" Value="4" />
</Style>
<Style Selector="DataGridRow /template/ Border#RowBorder">
<Setter Property="ClipToBounds" Value="True" />
</Style>
<Style Selector="Grid.repository_leftpanel DataGridRow:selected /template/ Rectangle#BackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource Brush.AccentHovered}" />
</Style>
<Style Selector="Grid.repository_leftpanel:focus-within DataGridRow:selected /template/ Rectangle#BackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}" />
</Style>
</DataGrid.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Header="ICON">
<DataGridTemplateColumn.CellTemplate>
@ -364,6 +407,7 @@
</ToggleButton>
<DataGrid Grid.Row="11"
MaxHeight="200"
Margin="4,0,6,0"
Background="Transparent"
ItemsSource="{Binding Submodules}"
SelectionMode="Single"
@ -378,6 +422,24 @@
VerticalScrollBarVisibility="Auto"
ContextRequested="OnSubmoduleContextRequested"
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
<DataGrid.Styles>
<Style Selector="DataGridRow">
<Setter Property="CornerRadius" Value="4" />
</Style>
<Style Selector="DataGridRow /template/ Border#RowBorder">
<Setter Property="ClipToBounds" Value="True" />
</Style>
<Style Selector="DataGridRow:pointerover /template/ Rectangle#BackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource Brush.AccentHovered}" />
</Style>
<Style Selector="DataGridRow:selected /template/ Rectangle#BackgroundRectangle">
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}" />
</Style>
</DataGrid.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Header="ICON">
<DataGridTemplateColumn.CellTemplate>
@ -390,7 +452,7 @@
<DataGridTemplateColumn Width="*" Header="NAME">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Classes="monospace"/>
<TextBlock Text="{Binding}" ClipToBounds="True" Classes="monospace"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
@ -408,6 +470,7 @@
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}"
CornerRadius="4"
Watermark="{DynamicResource Text.Repository.SearchTip}"
Text="{Binding SearchCommitFilter, Mode=TwoWay}"
VerticalContentAlignment="Center"

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Avalonia;
@ -6,6 +7,7 @@ using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace SourceGit.Views
{
@ -66,41 +68,26 @@ namespace SourceGit.Views
if (sender is Button button && DataContext is ViewModels.Repository repo)
{
var menu = repo.CreateContextMenuForExternalTools();
if (menu != null)
{
menu.Open(button);
button.OpenContextMenu(menu);
e.Handled = true;
}
}
}
private void OnLocalBranchTreeLostFocus(object sender, RoutedEventArgs e)
{
if (sender is TreeView tree)
tree.UnselectAll();
}
private void OnRemoteBranchTreeLostFocus(object sender, RoutedEventArgs e)
{
if (sender is TreeView tree)
tree.UnselectAll();
}
private void OnTagDataGridLostFocus(object sender, RoutedEventArgs e)
{
if (sender is DataGrid datagrid)
datagrid.SelectedItem = null;
}
private void OnLocalBranchTreeSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is TreeView tree && tree.SelectedItem != null)
if (sender is TreeView tree && tree.SelectedItem != null && DataContext is ViewModels.Repository repo)
{
remoteBranchTree.UnselectAll();
tagsList.SelectedItem = null;
var node = tree.SelectedItem as ViewModels.BranchTreeNode;
if (node.IsBranch && DataContext is ViewModels.Repository repo)
ViewModels.BranchTreeNode prev = null;
foreach (var node in repo.LocalBranchTrees)
node.UpdateCornerRadius(ref prev);
if (tree.SelectedItems.Count == 1)
{
var node = tree.SelectedItem as ViewModels.BranchTreeNode;
if (node.IsBranch)
repo.NavigateToCommit((node.Backend as Models.Branch).Head);
}
}
@ -108,13 +95,19 @@ namespace SourceGit.Views
private void OnRemoteBranchTreeSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is TreeView tree && tree.SelectedItem != null)
if (sender is TreeView tree && tree.SelectedItem != null && DataContext is ViewModels.Repository repo)
{
localBranchTree.UnselectAll();
tagsList.SelectedItem = null;
var node = tree.SelectedItem as ViewModels.BranchTreeNode;
if (node.IsBranch && DataContext is ViewModels.Repository repo)
ViewModels.BranchTreeNode prev = null;
foreach (var node in repo.RemoteBranchTrees)
node.UpdateCornerRadius(ref prev);
if (tree.SelectedItems.Count == 1)
{
var node = tree.SelectedItem as ViewModels.BranchTreeNode;
if (node.IsBranch)
repo.NavigateToCommit((node.Backend as Models.Branch).Head);
}
}
@ -124,31 +117,29 @@ namespace SourceGit.Views
{
if (sender is DataGrid datagrid && datagrid.SelectedItem != null)
{
localBranchTree.UnselectAll();
remoteBranchTree.UnselectAll();
var tag = datagrid.SelectedItem as Models.Tag;
if (DataContext is ViewModels.Repository repo)
{
repo.NavigateToCommit(tag.SHA);
}
}
}
private void OnSearchCommitPanelPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{
var grid = sender as Grid;
if (e.Property == IsVisibleProperty && grid.IsVisible)
{
txtSearchCommitsBox.Focus();
}
}
private void OnSearchKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
if (DataContext is ViewModels.Repository repo)
{
repo.StartSearchCommits();
}
e.Handled = true;
}
}
@ -174,10 +165,8 @@ namespace SourceGit.Views
if (toggle.DataContext is ViewModels.BranchTreeNode node)
{
if (node.IsBranch)
{
filter = (node.Backend as Models.Branch).FullName;
}
}
else if (toggle.DataContext is Models.Tag tag)
{
filter = tag.Name;
@ -195,15 +184,42 @@ namespace SourceGit.Views
private void OnLocalBranchContextMenuRequested(object sender, ContextRequestedEventArgs e)
{
remoteBranchTree.UnselectAll();
tagsList.SelectedItem = null;
if (sender is Grid grid && grid.DataContext is ViewModels.BranchTreeNode node)
var repo = DataContext as ViewModels.Repository;
var tree = sender as TreeView;
if (tree.SelectedItems.Count == 0)
{
if (node.IsBranch && DataContext is ViewModels.Repository repo)
{
var menu = repo.CreateContextMenuForLocalBranch(node.Backend as Models.Branch);
if (menu != null)
menu.Open(grid);
e.Handled = true;
return;
}
var branches = new List<Models.Branch>();
foreach (var item in tree.SelectedItems)
CollectBranchesFromNode(branches, item as ViewModels.BranchTreeNode);
if (branches.Count == 1)
{
var item = (e.Source as Control)?.FindAncestorOfType<TreeViewItem>(true);
if (item != null)
{
var menu = repo.CreateContextMenuForLocalBranch(branches[0]);
item.OpenContextMenu(menu);
}
}
else if (branches.Count > 1 && branches.Find(x => x.IsCurrent) == null)
{
var menu = new ContextMenu();
var deleteMulti = new MenuItem();
deleteMulti.Header = App.Text("BranchCM.DeleteMultiBranches", branches.Count);
deleteMulti.Icon = App.CreateMenuIcon("Icons.Clear");
deleteMulti.Click += (_, ev) =>
{
repo.DeleteMultipleBranches(branches, true);
ev.Handled = true;
};
menu.Items.Add(deleteMulti);
tree.OpenContextMenu(menu);
}
e.Handled = true;
@ -212,22 +228,60 @@ namespace SourceGit.Views
private void OnRemoteBranchContextMenuRequested(object sender, ContextRequestedEventArgs e)
{
localBranchTree.UnselectAll();
tagsList.SelectedItem = null;
if (sender is Grid grid && grid.DataContext is ViewModels.BranchTreeNode node && DataContext is ViewModels.Repository repo)
var repo = DataContext as ViewModels.Repository;
var tree = sender as TreeView;
if (tree.SelectedItems.Count == 0)
{
if (node.IsRemote)
e.Handled = true;
return;
}
if (tree.SelectedItems.Count == 1)
{
var node = tree.SelectedItem as ViewModels.BranchTreeNode;
if (node != null && node.IsRemote)
{
var item = (e.Source as Control)?.FindAncestorOfType<TreeViewItem>(true);
if (item != null && item.DataContext == node)
{
var menu = repo.CreateContextMenuForRemote(node.Backend as Models.Remote);
if (menu != null)
menu.Open(grid);
item.OpenContextMenu(menu);
}
else if (node.IsBranch)
e.Handled = true;
return;
}
}
var branches = new List<Models.Branch>();
foreach (var item in tree.SelectedItems)
CollectBranchesFromNode(branches, item as ViewModels.BranchTreeNode);
if (branches.Count == 1)
{
var menu = repo.CreateContextMenuForRemoteBranch(node.Backend as Models.Branch);
if (menu != null)
menu.Open(grid);
var item = (e.Source as Control)?.FindAncestorOfType<TreeViewItem>(true);
if (item != null)
{
var menu = repo.CreateContextMenuForRemoteBranch(branches[0]);
item.OpenContextMenu(menu);
}
}
else if (branches.Count > 1)
{
var menu = new ContextMenu();
var deleteMulti = new MenuItem();
deleteMulti.Header = App.Text("BranchCM.DeleteMultiBranches", branches.Count);
deleteMulti.Icon = App.CreateMenuIcon("Icons.Clear");
deleteMulti.Click += (_, ev) =>
{
repo.DeleteMultipleBranches(branches, false);
ev.Handled = true;
};
menu.Items.Add(deleteMulti);
tree.OpenContextMenu(menu);
}
e.Handled = true;
}
@ -238,8 +292,7 @@ namespace SourceGit.Views
{
var tag = datagrid.SelectedItem as Models.Tag;
var menu = repo.CreateContextMenuForTag(tag);
if (menu != null)
menu.Open(datagrid);
datagrid.OpenContextMenu(menu);
}
e.Handled = true;
@ -251,8 +304,7 @@ namespace SourceGit.Views
{
var submodule = datagrid.SelectedItem as string;
var menu = repo.CreateContextMenuForSubmodule(submodule);
if (menu != null)
menu.Open(datagrid);
datagrid.OpenContextMenu(menu);
}
e.Handled = true;
@ -263,8 +315,7 @@ namespace SourceGit.Views
if (DataContext is ViewModels.Repository repo)
{
var menu = repo.CreateContextMenuForGitFlow();
if (menu != null)
menu.Open(sender as Button);
(sender as Control)?.OpenContextMenu(menu);
}
e.Handled = true;
@ -313,5 +364,23 @@ namespace SourceGit.Views
e.Handled = true;
}
}
private void CollectBranchesFromNode(List<Models.Branch> outs, ViewModels.BranchTreeNode node)
{
if (node == null || node.IsRemote)
return;
if (node.IsFolder)
{
foreach (var child in node.Children)
CollectBranchesFromNode(outs, child);
}
else
{
var b = node.Backend as Models.Branch;
if (b != null && !outs.Contains(b))
outs.Add(b);
}
}
}
}

View file

@ -47,23 +47,18 @@
Text="{Binding HttpProxy, Mode=TwoWay}"/>
<TextBlock Grid.Row="3" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.Preference.GPG.Enabled}"/>
<CheckBox Grid.Row="3" Grid.Column="1"
x:Name="chkGPGSigningEnabled"
IsChecked="{Binding GPGSigningEnabled, Mode=TwoWay}"/>
<TextBlock Grid.Row="4" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.Preference.GPG.UserKey}"/>
<TextBox Grid.Row="4" Grid.Column="1"
<TextBox Grid.Row="3" Grid.Column="1"
Height="28"
CornerRadius="3"
Watermark="{DynamicResource Text.Preference.GPG.UserKey.Placeholder}"
Text="{Binding GPGUserSigningKey, Mode=TwoWay}"
IsEnabled="{Binding #chkGPGSigningEnabled.IsChecked}"/>
Text="{Binding GPGUserSigningKey, Mode=TwoWay}"/>
<CheckBox Grid.Row="4" Grid.Column="1"
Content="{DynamicResource Text.Preference.GPG.Enabled}"
IsChecked="{Binding GPGSigningEnabled, Mode=TwoWay}"/>
</Grid>
</StackPanel>
</UserControl>

View file

@ -61,6 +61,7 @@
Height="26"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="Transparent"
CornerRadius="4"
Watermark="{DynamicResource Text.CommitDetail.Changes.Search}"
Text="{Binding SearchFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>

View file

@ -25,7 +25,7 @@ namespace SourceGit.Views
{
var compare = DataContext as ViewModels.RevisionCompare;
var menu = compare.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
menu.Open(datagrid);
datagrid.OpenContextMenu(menu);
}
e.Handled = true;
@ -40,7 +40,7 @@ namespace SourceGit.Views
if (node != null && !node.IsFolder)
{
var menu = compare.CreateChangeContextMenu(node.Backend as Models.Change);
menu.Open(view);
view.OpenContextMenu(menu);
}
}

View file

@ -23,9 +23,9 @@
Height="26"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="Transparent"
Watermark="{DynamicResource Text.CommitDetail.Changes.Search}"
Text="{Binding SearchFileFilter, Mode=TwoWay}"
v:AutoFocusBehaviour.IsEnabled="True">
CornerRadius="4"
Watermark="{DynamicResource Text.CommitDetail.Files.Search}"
Text="{Binding SearchFileFilter, Mode=TwoWay}">
<TextBox.InnerLeftContent>
<Path Width="14" Height="14" Margin="4,0,0,0" Fill="{DynamicResource Brush.FG2}" Data="{StaticResource Icons.Search}"/>
</TextBox.InnerLeftContent>

View file

@ -198,7 +198,8 @@ namespace SourceGit.Views
var menu = new ContextMenu();
menu.Items.Add(copy);
menu.Open(TextArea.TextView);
TextArea.TextView.OpenContextMenu(menu);
e.Handled = true;
}
@ -219,7 +220,7 @@ namespace SourceGit.Views
if (!node.IsFolder)
{
var menu = detail.CreateRevisionFileContextMenu(node.Backend as Models.Object);
menu.Open(sender as Control);
(sender as Control)?.OpenContextMenu(menu);
}
e.Handled = true;

View file

@ -69,7 +69,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8">
<Path Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="Green"/>
<TextBlock Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.SelfUpdate.Available}"/>
<Border Margin="4,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent1}" Effect="drop-shadow(0 0 6 #40000000)">
<Border Margin="4,0,0,0" Height="20" CornerRadius="10" Background="{DynamicResource Brush.Accent}" Effect="drop-shadow(0 0 6 #40000000)">
<TextBlock Classes="monospace" Margin="8,0" Text="{Binding TagName}" FontSize="12" Foreground="White"/>
</Border>
</StackPanel>

View file

@ -172,7 +172,7 @@
<v:Chart Grid.Column="1"
Margin="16,0,0,0"
LineBrush="{DynamicResource Brush.Border1}"
ShapeBrush="{DynamicResource Brush.Accent1}"
ShapeBrush="{DynamicResource Brush.Accent}"
Samples="{Binding Samples}"/>
</Grid>
</DataTemplate>

View file

@ -137,6 +137,9 @@ namespace SourceGit.Views
var width = textView.Bounds.Width;
foreach (var line in textView.VisualLines)
{
if (line.FirstDocumentLine == null)
continue;
var index = line.FirstDocumentLine.LineNumber;
if (index > _editor.DiffData.Lines.Count)
break;
@ -320,7 +323,8 @@ namespace SourceGit.Views
};
menu.Items.Add(copy);
menu.Open(TextArea.TextView);
TextArea.TextView.OpenContextMenu(menu);
e.Handled = true;
}
@ -516,6 +520,9 @@ namespace SourceGit.Views
var infos = _editor.IsOld ? _editor.DiffData.Old : _editor.DiffData.New;
foreach (var line in textView.VisualLines)
{
if (line.FirstDocumentLine == null)
continue;
var index = line.FirstDocumentLine.LineNumber;
if (index > infos.Count)
break;
@ -731,7 +738,8 @@ namespace SourceGit.Views
};
menu.Items.Add(copy);
menu.Open(TextArea.TextView);
TextArea.TextView.OpenContextMenu(menu);
e.Handled = true;
}

View file

@ -42,7 +42,7 @@ namespace SourceGit.Views
if (sender is Grid grid && DataContext is ViewModels.Welcome vm)
{
var menu = vm.CreateContextMenu(grid.DataContext as ViewModels.RepositoryNode);
menu?.Open(grid);
grid.OpenContextMenu(menu);
e.Handled = true;
}
}
@ -248,7 +248,7 @@ namespace SourceGit.Views
{
Dispatcher.UIThread.Invoke(() =>
{
(DataContext as ViewModels.Welcome).InitRepository(path);
(DataContext as ViewModels.Welcome).InitRepository(path, parent);
});
return;
}
@ -257,7 +257,7 @@ namespace SourceGit.Views
Dispatcher.UIThread.Invoke(() =>
{
var repo = ViewModels.Preference.AddRepository(root, gitDir);
var node = ViewModels.Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, parent);
var node = ViewModels.Preference.FindOrAddNodeByRepositoryPath(repo.FullPath, parent, true);
launcher.OpenRepositoryInTab(node, page);
});
});

View file

@ -205,8 +205,7 @@ namespace SourceGit.Views
}
var menu = vm.CreateContextMenuForUnstagedChanges(selected);
if (menu != null)
menu.Open(datagrid);
datagrid.OpenContextMenu(menu);
}
e.Handled = true;
@ -225,8 +224,7 @@ namespace SourceGit.Views
}
var menu = vm.CreateContextMenuForUnstagedChanges(selected);
if (menu != null)
menu.Open(tree);
tree.OpenContextMenu(menu);
}
e.Handled = true;
@ -245,8 +243,7 @@ namespace SourceGit.Views
}
var menu = vm.CreateContextMenuForStagedChanges(selected);
if (menu != null)
menu.Open(datagrid);
datagrid.OpenContextMenu(menu);
}
e.Handled = true;
@ -265,8 +262,7 @@ namespace SourceGit.Views
}
var menu = vm.CreateContextMenuForStagedChanges(selected);
if (menu != null)
menu.Open(tree);
tree.OpenContextMenu(menu);
}
e.Handled = true;
@ -331,7 +327,7 @@ namespace SourceGit.Views
{
var menu = vm.CreateContextMenuForCommitMessages();
menu.Placement = PlacementMode.TopEdgeAlignedLeft;
menu.Open(button);
button.OpenContextMenu(menu);
e.Handled = true;
}
}