mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 21:30:37 +08:00
ux: show tab status icon description in tooltip (#1767)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
28
src/Converters/DirtyStateConverters.cs
Normal file
28
src/Converters/DirtyStateConverters.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class DirtyStateConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<Models.DirtyState, IBrush> ToBrush =
|
||||
new FuncValueConverter<Models.DirtyState, IBrush>(v =>
|
||||
{
|
||||
if (v.HasFlag(Models.DirtyState.HasLocalChanges))
|
||||
return Brushes.Gray;
|
||||
if (v.HasFlag(Models.DirtyState.HasPendingPullOrPush))
|
||||
return Brushes.RoyalBlue;
|
||||
return Brushes.Transparent;
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<Models.DirtyState, string> ToDesc =
|
||||
new FuncValueConverter<Models.DirtyState, string>(v =>
|
||||
{
|
||||
if (v.HasFlag(Models.DirtyState.HasLocalChanges))
|
||||
return " • " + App.Text("DirtyState.HasLocalChanges");
|
||||
if (v.HasFlag(Models.DirtyState.HasPendingPullOrPush))
|
||||
return " • " + App.Text("DirtyState.HasPendingPullOrPush");
|
||||
return " • " + App.Text("DirtyState.UpToDate");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -335,6 +335,9 @@
|
||||
<x:String x:Key="Text.Diff.VisualLines.Incr" xml:space="preserve">Increase Number of Visible Lines</x:String>
|
||||
<x:String x:Key="Text.Diff.Welcome" xml:space="preserve">SELECT FILE TO VIEW CHANGES</x:String>
|
||||
<x:String x:Key="Text.DirHistories" xml:space="preserve">Dir History</x:String>
|
||||
<x:String x:Key="Text.DirtyState.HasLocalChanges" xml:space="preserve">Has Local Changes</x:String>
|
||||
<x:String x:Key="Text.DirtyState.HasPendingPullOrPush" xml:space="preserve">Mismatched with Upstream</x:String>
|
||||
<x:String x:Key="Text.DirtyState.UpToDate" xml:space="preserve">Already Up-To-Date</x:String>
|
||||
<x:String x:Key="Text.Discard" xml:space="preserve">Discard Changes</x:String>
|
||||
<x:String x:Key="Text.Discard.All" xml:space="preserve">All local changes in working copy.</x:String>
|
||||
<x:String x:Key="Text.Discard.Changes" xml:space="preserve">Changes:</x:String>
|
||||
|
||||
@@ -339,6 +339,9 @@
|
||||
<x:String x:Key="Text.Diff.VisualLines.Incr" xml:space="preserve">增加可见的行数</x:String>
|
||||
<x:String x:Key="Text.Diff.Welcome" xml:space="preserve">请选择需要对比的文件</x:String>
|
||||
<x:String x:Key="Text.DirHistories" xml:space="preserve">目录内容变更历史</x:String>
|
||||
<x:String x:Key="Text.DirtyState.HasLocalChanges" xml:space="preserve">未提交的本地变更</x:String>
|
||||
<x:String x:Key="Text.DirtyState.HasPendingPullOrPush" xml:space="preserve">当前分支HEAD与远端不一致</x:String>
|
||||
<x:String x:Key="Text.DirtyState.UpToDate" xml:space="preserve">已是最新</x:String>
|
||||
<x:String x:Key="Text.Discard" xml:space="preserve">放弃更改确认</x:String>
|
||||
<x:String x:Key="Text.Discard.All" xml:space="preserve">所有本仓库未提交的修改。</x:String>
|
||||
<x:String x:Key="Text.Discard.Changes" xml:space="preserve">变更 :</x:String>
|
||||
|
||||
@@ -339,6 +339,9 @@
|
||||
<x:String x:Key="Text.Diff.VisualLines.Incr" xml:space="preserve">增加可見的行數</x:String>
|
||||
<x:String x:Key="Text.Diff.Welcome" xml:space="preserve">請選擇需要對比的檔案</x:String>
|
||||
<x:String x:Key="Text.DirHistories" xml:space="preserve">目錄内容變更歷史</x:String>
|
||||
<x:String x:Key="Text.DirtyState.HasLocalChanges" xml:space="preserve">未提交的本地變更</x:String>
|
||||
<x:String x:Key="Text.DirtyState.HasPendingPullOrPush" xml:space="preserve">當前分支的 HEAD 與上游不匹配</x:String>
|
||||
<x:String x:Key="Text.DirtyState.UpToDate" xml:space="preserve">已更新至最新</x:String>
|
||||
<x:String x:Key="Text.Discard" xml:space="preserve">捨棄變更</x:String>
|
||||
<x:String x:Key="Text.Discard.All" xml:space="preserve">所有本機未提交的變更。</x:String>
|
||||
<x:String x:Key="Text.Discard.Changes" xml:space="preserve">變更:</x:String>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Media;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
@@ -20,10 +22,10 @@ namespace SourceGit.ViewModels
|
||||
set => SetProperty(ref _data, value);
|
||||
}
|
||||
|
||||
public IBrush DirtyBrush
|
||||
public Models.DirtyState DirtyState
|
||||
{
|
||||
get => _dirtyBrush;
|
||||
private set => SetProperty(ref _dirtyBrush, value);
|
||||
get => _dirtyState;
|
||||
private set => SetProperty(ref _dirtyState, value);
|
||||
}
|
||||
|
||||
public Popup Popup
|
||||
@@ -66,22 +68,18 @@ namespace SourceGit.ViewModels
|
||||
|
||||
public void ChangeDirtyState(Models.DirtyState flag, bool remove)
|
||||
{
|
||||
var state = _dirtyState;
|
||||
if (remove)
|
||||
{
|
||||
if (_dirtyState.HasFlag(flag))
|
||||
_dirtyState -= flag;
|
||||
if (state.HasFlag(flag))
|
||||
state -= flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dirtyState |= flag;
|
||||
state |= flag;
|
||||
}
|
||||
|
||||
if (_dirtyState.HasFlag(Models.DirtyState.HasLocalChanges))
|
||||
DirtyBrush = Brushes.Gray;
|
||||
else if (_dirtyState.HasFlag(Models.DirtyState.HasPendingPullOrPush))
|
||||
DirtyBrush = Brushes.RoyalBlue;
|
||||
else
|
||||
DirtyBrush = null;
|
||||
DirtyState = state;
|
||||
}
|
||||
|
||||
public bool CanCreatePopup()
|
||||
@@ -127,7 +125,6 @@ namespace SourceGit.ViewModels
|
||||
|
||||
private RepositoryNode _node = null;
|
||||
private object _data = null;
|
||||
private IBrush _dirtyBrush = null;
|
||||
private Models.DirtyState _dirtyState = Models.DirtyState.None;
|
||||
private Popup _popup = null;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
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:c="using:SourceGit.Converters"
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
@@ -51,7 +52,11 @@
|
||||
<ToolTip.Tip>
|
||||
<Grid>
|
||||
<TextBlock Text="{DynamicResource Text.Welcome}" IsVisible="{Binding !Node.IsRepository}"/>
|
||||
<TextBlock Text="{Binding Node.Id}" IsVisible="{Binding Node.IsRepository}"/>
|
||||
<StackPanel Orientation="Horizontal" IsVisible="{Binding Node.IsRepository}">
|
||||
<TextBlock Text="{Binding Node.Id}"/>
|
||||
<TextBlock Text="{Binding DirtyState, Converter={x:Static c:DirtyStateConverters.ToDesc}}"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ToolTip.Tip>
|
||||
|
||||
@@ -78,8 +83,8 @@
|
||||
Width="8" Height="8"
|
||||
Margin="0,0,6,0"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding DirtyBrush, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Fill="{Binding DirtyBrush}"/>
|
||||
IsVisible="{Binding DirtyState, Converter={x:Static ObjectConverters.IsNotNull}, ConverterParameter={x:Static m:DirtyState.None}}"
|
||||
Fill="{Binding DirtyState, Converter={x:Static c:DirtyStateConverters.ToBrush}}"/>
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Classes="primary"
|
||||
|
||||
Reference in New Issue
Block a user