enhance: workspace tooltip (#445)

This commit is contained in:
leo 2024-09-09 18:47:53 +08:00
parent ebc112a627
commit 0190c2111d
No known key found for this signature in database
6 changed files with 17 additions and 5 deletions

View file

@ -626,6 +626,7 @@
<x:String x:Key="Text.WorkingCopy.Unstaged.ViewAssumeUnchaged" xml:space="preserve">VIEW ASSUME UNCHANGED</x:String> <x:String x:Key="Text.WorkingCopy.Unstaged.ViewAssumeUnchaged" xml:space="preserve">VIEW ASSUME UNCHANGED</x:String>
<x:String x:Key="Text.WorkingCopy.UseCommitTemplate" xml:space="preserve">Template: ${0}$</x:String> <x:String x:Key="Text.WorkingCopy.UseCommitTemplate" xml:space="preserve">Template: ${0}$</x:String>
<x:String x:Key="Text.WorkingCopy.ResolveTip" xml:space="preserve">Right-click the selected file(s), and make your choice to resolve conflicts.</x:String> <x:String x:Key="Text.WorkingCopy.ResolveTip" xml:space="preserve">Right-click the selected file(s), and make your choice to resolve conflicts.</x:String>
<x:String x:Key="Text.Workspace" xml:space="preserve">WORKSPACE: </x:String>
<x:String x:Key="Text.Workspace.Configure" xml:space="preserve">Configure...</x:String> <x:String x:Key="Text.Workspace.Configure" xml:space="preserve">Configure...</x:String>
<x:String x:Key="Text.Worktree" xml:space="preserve">WORKTREE</x:String> <x:String x:Key="Text.Worktree" xml:space="preserve">WORKTREE</x:String>
<x:String x:Key="Text.Worktree.CopyPath" xml:space="preserve">Copy Path</x:String> <x:String x:Key="Text.Worktree.CopyPath" xml:space="preserve">Copy Path</x:String>

View file

@ -628,6 +628,7 @@
<x:String x:Key="Text.WorkingCopy.Unstaged.ViewAssumeUnchaged" xml:space="preserve">查看忽略变更文件</x:String> <x:String x:Key="Text.WorkingCopy.Unstaged.ViewAssumeUnchaged" xml:space="preserve">查看忽略变更文件</x:String>
<x:String x:Key="Text.WorkingCopy.UseCommitTemplate" xml:space="preserve">模板:${0}$</x:String> <x:String x:Key="Text.WorkingCopy.UseCommitTemplate" xml:space="preserve">模板:${0}$</x:String>
<x:String x:Key="Text.WorkingCopy.ResolveTip" xml:space="preserve">请选中冲突文件,打开右键菜单,选择合适的解决方式</x:String> <x:String x:Key="Text.WorkingCopy.ResolveTip" xml:space="preserve">请选中冲突文件,打开右键菜单,选择合适的解决方式</x:String>
<x:String x:Key="Text.Workspace" xml:space="preserve">工作区:</x:String>
<x:String x:Key="Text.Workspace.Configure" xml:space="preserve">配置工作区...</x:String> <x:String x:Key="Text.Workspace.Configure" xml:space="preserve">配置工作区...</x:String>
<x:String x:Key="Text.Worktree" xml:space="preserve">本地工作树</x:String> <x:String x:Key="Text.Worktree" xml:space="preserve">本地工作树</x:String>
<x:String x:Key="Text.Worktree.CopyPath" xml:space="preserve">复制工作树路径</x:String> <x:String x:Key="Text.Worktree.CopyPath" xml:space="preserve">复制工作树路径</x:String>

View file

@ -629,6 +629,7 @@
<x:String x:Key="Text.WorkingCopy.Unstaged.ViewAssumeUnchaged" xml:space="preserve">檢視不追蹤變更的檔案</x:String> <x:String x:Key="Text.WorkingCopy.Unstaged.ViewAssumeUnchaged" xml:space="preserve">檢視不追蹤變更的檔案</x:String>
<x:String x:Key="Text.WorkingCopy.UseCommitTemplate" xml:space="preserve">範本: ${0}$</x:String> <x:String x:Key="Text.WorkingCopy.UseCommitTemplate" xml:space="preserve">範本: ${0}$</x:String>
<x:String x:Key="Text.WorkingCopy.ResolveTip" xml:space="preserve">請選擇發生衝突的檔案,開啟右鍵選單,選擇合適的解決方式</x:String> <x:String x:Key="Text.WorkingCopy.ResolveTip" xml:space="preserve">請選擇發生衝突的檔案,開啟右鍵選單,選擇合適的解決方式</x:String>
<x:String x:Key="Text.Workspace" xml:space="preserve">工作區:</x:String>
<x:String x:Key="Text.Workspace.Configure" xml:space="preserve">配置工作區...</x:String> <x:String x:Key="Text.Workspace.Configure" xml:space="preserve">配置工作區...</x:String>
<x:String x:Key="Text.Worktree" xml:space="preserve">本機工作區</x:String> <x:String x:Key="Text.Worktree" xml:space="preserve">本機工作區</x:String>
<x:String x:Key="Text.Worktree.CopyPath" xml:space="preserve">複製工作區路徑</x:String> <x:String x:Key="Text.Worktree.CopyPath" xml:space="preserve">複製工作區路徑</x:String>

View file

@ -125,6 +125,7 @@ namespace SourceGit.ViewModels
var last = Pages[0]; var last = Pages[0];
if (last.Data is Repository repo) if (last.Data is Repository repo)
{ {
ActiveWorkspace.Repositories.Remove(repo.FullPath);
Models.AutoFetchManager.Instance.RemoveRepository(repo.FullPath); Models.AutoFetchManager.Instance.RemoveRepository(repo.FullPath);
repo.Close(); repo.Close();

View file

@ -18,7 +18,9 @@ namespace SourceGit.ViewModels
if (_instance == null) if (_instance == null)
{ {
_isLoading = true; _isLoading = true;
if (!File.Exists(_savePath))
var path = Path.Combine(Native.OS.DataDir, "preference.json");
if (!File.Exists(path))
{ {
_instance = new Preference(); _instance = new Preference();
} }
@ -26,7 +28,7 @@ namespace SourceGit.ViewModels
{ {
try try
{ {
_instance = JsonSerializer.Deserialize(File.ReadAllText(_savePath), JsonCodeGen.Default.Preference); _instance = JsonSerializer.Deserialize(File.ReadAllText(path), JsonCodeGen.Default.Preference);
} }
catch catch
{ {
@ -429,8 +431,9 @@ namespace SourceGit.ViewModels
public void Save() public void Save()
{ {
var file = Path.Combine(Native.OS.DataDir, "preference.json");
var data = JsonSerializer.Serialize(this, JsonCodeGen.Default.Preference); var data = JsonSerializer.Serialize(this, JsonCodeGen.Default.Preference);
File.WriteAllText(_savePath, data); File.WriteAllText(file, data);
} }
private RepositoryNode FindNodeRecursive(string id, List<RepositoryNode> collection) private RepositoryNode FindNodeRecursive(string id, List<RepositoryNode> collection)
@ -482,7 +485,6 @@ namespace SourceGit.ViewModels
private static Preference _instance = null; private static Preference _instance = null;
private static bool _isLoading = false; private static bool _isLoading = false;
private static readonly string _savePath = Path.Combine(Native.OS.DataDir, "preference.json");
private string _locale = "en_US"; private string _locale = "en_US";
private string _theme = "Default"; private string _theme = "Default";

View file

@ -70,7 +70,13 @@
</Button> </Button>
<!-- Workspace Switcher --> <!-- Workspace Switcher -->
<Button Grid.Column="1" Classes="icon_button" VerticalAlignment="Bottom" Click="OnOpenWorkspaceMenu" ToolTip.Tip="{Binding ActiveWorkspace.Name}"> <Button Grid.Column="1" Classes="icon_button" VerticalAlignment="Bottom" Click="OnOpenWorkspaceMenu">
<ToolTip.Tip>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{DynamicResource Text.Workspace}" FontWeight="Bold" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Text="{Binding ActiveWorkspace.Name}"/>
</StackPanel>
</ToolTip.Tip>
<Path Width="14" Height="14" <Path Width="14" Height="14"
Data="{StaticResource Icons.Workspace}" Data="{StaticResource Icons.Workspace}"
Fill="{Binding ActiveWorkspace.Brush}"/> Fill="{Binding ActiveWorkspace.Brush}"/>