mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 03:34:59 +00:00
Compare commits
4 commits
ea320d2cdf
...
d429a6426a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d429a6426a | ||
![]() |
4c1ba717a7 | ||
![]() |
bd553405c2 | ||
![]() |
f121975a28 |
12 changed files with 377 additions and 165 deletions
|
@ -13,10 +13,10 @@ This document shows the translation status of each locale file in the repository
|
|||
|
||||
- Text.GitFlow.FinishWithPush
|
||||
- Text.GitFlow.FinishWithSquash
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Hotkeys.TextEditor.OpenExternalMergeTool
|
||||
- Text.Repository.ShowSubmodulesAsTree
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
- Text.Submodule.Status
|
||||
- Text.Submodule.Status.Modified
|
||||
- Text.Submodule.Status.NotInited
|
||||
|
@ -31,8 +31,8 @@ This document shows the translation status of each locale file in the repository
|
|||
<details>
|
||||
<summary>Missing keys in es_ES.axaml</summary>
|
||||
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
|
||||
</details>
|
||||
|
||||
|
@ -60,8 +60,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.ConfirmEmptyCommit.WithLocalChanges
|
||||
- Text.GitFlow.FinishWithPush
|
||||
- Text.GitFlow.FinishWithSquash
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Hotkeys.TextEditor.OpenExternalMergeTool
|
||||
- Text.Preferences.Git.IgnoreCRAtEOLInDiff
|
||||
- Text.Repository.BranchSort
|
||||
|
@ -71,6 +70,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.Repository.ShowSubmodulesAsTree
|
||||
- Text.Repository.ViewLogs
|
||||
- Text.Repository.Visit
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
- Text.Submodule.Status
|
||||
- Text.Submodule.Status.Modified
|
||||
- Text.Submodule.Status.NotInited
|
||||
|
@ -94,8 +94,8 @@ This document shows the translation status of each locale file in the repository
|
|||
<details>
|
||||
<summary>Missing keys in it_IT.axaml</summary>
|
||||
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
|
||||
</details>
|
||||
|
||||
|
@ -123,8 +123,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.ConfirmEmptyCommit.WithLocalChanges
|
||||
- Text.GitFlow.FinishWithPush
|
||||
- Text.GitFlow.FinishWithSquash
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Hotkeys.TextEditor.OpenExternalMergeTool
|
||||
- Text.Preferences.Git.IgnoreCRAtEOLInDiff
|
||||
- Text.Repository.BranchSort
|
||||
|
@ -136,6 +135,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.Repository.Tags.OrderByNameDes
|
||||
- Text.Repository.ViewLogs
|
||||
- Text.Repository.Visit
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
- Text.Submodule.Status
|
||||
- Text.Submodule.Status.Modified
|
||||
- Text.Submodule.Status.NotInited
|
||||
|
@ -207,8 +207,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.GitFlow.FinishWithPush
|
||||
- Text.GitFlow.FinishWithSquash
|
||||
- Text.Hotkeys.Global.Clone
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Hotkeys.TextEditor.OpenExternalMergeTool
|
||||
- Text.InProgress.CherryPick.Head
|
||||
- Text.InProgress.Merge.Operating
|
||||
|
@ -246,6 +245,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.Repository.UseRelativeTimeInHistories
|
||||
- Text.Repository.ViewLogs
|
||||
- Text.Repository.Visit
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
- Text.SetUpstream
|
||||
- Text.SetUpstream.Local
|
||||
- Text.SetUpstream.Unset
|
||||
|
@ -279,9 +279,9 @@ This document shows the translation status of each locale file in the repository
|
|||
<details>
|
||||
<summary>Missing keys in ru_RU.axaml</summary>
|
||||
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Repository.ShowSubmodulesAsTree
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
|
||||
</details>
|
||||
|
||||
|
@ -309,8 +309,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.ConfirmEmptyCommit.WithLocalChanges
|
||||
- Text.GitFlow.FinishWithPush
|
||||
- Text.GitFlow.FinishWithSquash
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Hotkeys.TextEditor.OpenExternalMergeTool
|
||||
- Text.Preferences.Git.IgnoreCRAtEOLInDiff
|
||||
- Text.Repository.BranchSort
|
||||
|
@ -320,6 +319,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.Repository.ShowSubmodulesAsTree
|
||||
- Text.Repository.ViewLogs
|
||||
- Text.Repository.Visit
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
- Text.Submodule.Status
|
||||
- Text.Submodule.Status.Modified
|
||||
- Text.Submodule.Status.NotInited
|
||||
|
@ -358,8 +358,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.ConfigureWorkspace.Name
|
||||
- Text.GitFlow.FinishWithPush
|
||||
- Text.GitFlow.FinishWithSquash
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
- Text.Hotkeys.Global.SwitchWorkspace
|
||||
- Text.Hotkeys.TextEditor.OpenExternalMergeTool
|
||||
- Text.Preferences.Git.IgnoreCRAtEOLInDiff
|
||||
- Text.Repository.BranchSort
|
||||
|
@ -369,6 +368,7 @@ This document shows the translation status of each locale file in the repository
|
|||
- Text.Repository.ShowSubmodulesAsTree
|
||||
- Text.Repository.ViewLogs
|
||||
- Text.Repository.Visit
|
||||
- Text.Repository.WorkspaceSwitcher
|
||||
- Text.Submodule.Status
|
||||
- Text.Submodule.Status.Modified
|
||||
- Text.Submodule.Status.NotInited
|
||||
|
@ -382,22 +382,6 @@ This document shows the translation status of each locale file in the repository
|
|||
|
||||
</details>
|
||||
|
||||
### 
|
||||
### 
|
||||
|
||||
<details>
|
||||
<summary>Missing keys in zh_CN.axaml</summary>
|
||||
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
|
||||
</details>
|
||||
|
||||
### 
|
||||
|
||||
<details>
|
||||
<summary>Missing keys in zh_TW.axaml</summary>
|
||||
|
||||
- Text.Hotkeys.Global.OpenWorkspaces
|
||||
- Text.Hotkeys.Global.OpenWorkspaceAtIndex
|
||||
|
||||
</details>
|
||||
### 
|
|
@ -386,8 +386,7 @@
|
|||
<x:String x:Key="Text.Hotkeys.Global.GotoPrevTab" xml:space="preserve">Go to previous page</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.NewTab" xml:space="preserve">Create new page</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenPreferences" xml:space="preserve">Open Preferences dialog</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenWorkspaces" xml:space="preserve">Open Workspaces dialog</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenWorkspaceAtIndex" xml:space="preserve">Switch to corresponding workspace</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.SwitchWorkspace" xml:space="preserve">Switch active workspace</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">REPOSITORY</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">Commit staged changes</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">Commit and push staged changes</x:String>
|
||||
|
@ -636,6 +635,7 @@
|
|||
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">Use relative time in histories</x:String>
|
||||
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">View Logs</x:String>
|
||||
<x:String x:Key="Text.Repository.Visit" xml:space="preserve">Visit '{0}' in Browser</x:String>
|
||||
<x:String x:Key="Text.Repository.WorkspaceSwitcher" xml:space="preserve">Switch Workspace</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">WORKTREES</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">Add Worktree</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">Prune</x:String>
|
||||
|
|
|
@ -390,6 +390,7 @@
|
|||
<x:String x:Key="Text.Hotkeys.Global.GotoPrevTab" xml:space="preserve">切换到上一个页面</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.NewTab" xml:space="preserve">新建页面</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenPreferences" xml:space="preserve">打开偏好设置面板</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.SwitchWorkspace" xml:space="preserve">切换工作区</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">仓库页面快捷键</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">提交暂存区更改</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">提交暂存区更改并推送</x:String>
|
||||
|
@ -638,6 +639,7 @@
|
|||
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">在提交列表中使用相对时间</x:String>
|
||||
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">查看命令日志</x:String>
|
||||
<x:String x:Key="Text.Repository.Visit" xml:space="preserve">访问远程仓库 '{0}'</x:String>
|
||||
<x:String x:Key="Text.Repository.WorkspaceSwitcher" xml:space="preserve">切换工作区</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">工作树列表</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">新增工作树</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">清理</x:String>
|
||||
|
|
|
@ -390,6 +390,7 @@
|
|||
<x:String x:Key="Text.Hotkeys.Global.GotoPrevTab" xml:space="preserve">切換到上一個頁面</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.NewTab" xml:space="preserve">新增頁面</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.OpenPreferences" xml:space="preserve">開啟偏好設定面板</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Global.SwitchWorkspace" xml:space="preserve">切換工作區</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">存放庫頁面快速鍵</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">提交暫存區變更</x:String>
|
||||
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">提交暫存區變更並推送</x:String>
|
||||
|
@ -638,6 +639,7 @@
|
|||
<x:String x:Key="Text.Repository.UseRelativeTimeInHistories" xml:space="preserve">在提交列表中使用相對時間</x:String>
|
||||
<x:String x:Key="Text.Repository.ViewLogs" xml:space="preserve">檢視 Git 指令記錄</x:String>
|
||||
<x:String x:Key="Text.Repository.Visit" xml:space="preserve">檢視遠端存放庫 '{0}'</x:String>
|
||||
<x:String x:Key="Text.Repository.WorkspaceSwitcher" xml:space="preserve">切換工作區</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees" xml:space="preserve">工作區列表</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees.Add" xml:space="preserve">新增工作區</x:String>
|
||||
<x:String x:Key="Text.Repository.Worktrees.Prune" xml:space="preserve">清理</x:String>
|
||||
|
|
|
@ -23,6 +23,12 @@ namespace SourceGit.ViewModels
|
|||
private set;
|
||||
}
|
||||
|
||||
public WorkspaceSwitcher WorkspaceSwitcher
|
||||
{
|
||||
get => _workspaceSwitcher;
|
||||
set => SetProperty(ref _workspaceSwitcher, value);
|
||||
}
|
||||
|
||||
public Workspace ActiveWorkspace
|
||||
{
|
||||
get => _activeWorkspace;
|
||||
|
@ -130,6 +136,79 @@ namespace SourceGit.ViewModels
|
|||
_ignoreIndexChange = false;
|
||||
}
|
||||
|
||||
public void OpenWorkspaceSwitcher()
|
||||
{
|
||||
WorkspaceSwitcher = new WorkspaceSwitcher(this);
|
||||
}
|
||||
|
||||
public void CancelWorkspaceSwitcher()
|
||||
{
|
||||
WorkspaceSwitcher = null;
|
||||
}
|
||||
|
||||
public void SwitchWorkspace(Workspace to)
|
||||
{
|
||||
if (to.IsActive)
|
||||
return;
|
||||
|
||||
foreach (var one in Pages)
|
||||
{
|
||||
if (!one.CanCreatePopup() || one.Data is Repository { IsAutoFetching: true })
|
||||
{
|
||||
App.RaiseException(null, "You have unfinished task(s) in opened pages. Please wait!!!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_ignoreIndexChange = true;
|
||||
|
||||
var pref = Preferences.Instance;
|
||||
foreach (var w in pref.Workspaces)
|
||||
w.IsActive = false;
|
||||
|
||||
ActiveWorkspace = to;
|
||||
to.IsActive = true;
|
||||
|
||||
foreach (var one in Pages)
|
||||
CloseRepositoryInTab(one, false);
|
||||
|
||||
Pages.Clear();
|
||||
AddNewTab();
|
||||
|
||||
var repos = to.Repositories.ToArray();
|
||||
foreach (var repo in repos)
|
||||
{
|
||||
var node = pref.FindNode(repo);
|
||||
if (node == null)
|
||||
{
|
||||
node = new RepositoryNode()
|
||||
{
|
||||
Id = repo,
|
||||
Name = Path.GetFileName(repo),
|
||||
Bookmark = 0,
|
||||
IsRepository = true,
|
||||
};
|
||||
}
|
||||
|
||||
OpenRepositoryInTab(node, null);
|
||||
}
|
||||
|
||||
var activeIdx = to.ActiveIdx;
|
||||
if (activeIdx >= 0 && activeIdx < Pages.Count)
|
||||
{
|
||||
ActivePage = Pages[activeIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivePage = Pages[0];
|
||||
to.ActiveIdx = 0;
|
||||
}
|
||||
|
||||
_ignoreIndexChange = false;
|
||||
Preferences.Instance.Save();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
public void AddNewTab()
|
||||
{
|
||||
var page = new LauncherPage();
|
||||
|
@ -463,14 +542,6 @@ namespace SourceGit.ViewModels
|
|||
return menu;
|
||||
}
|
||||
|
||||
public void SwitchWorkspace(int idx)
|
||||
{
|
||||
var pref = Preferences.Instance;
|
||||
if (idx >= pref.Workspaces.Count || pref.Workspaces[idx].IsActive) return;
|
||||
|
||||
SwitchWorkspace(pref.Workspaces[idx]);
|
||||
}
|
||||
|
||||
private string GetRepositoryGitDir(string repo)
|
||||
{
|
||||
var fullpath = Path.Combine(repo, ".git");
|
||||
|
@ -501,66 +572,6 @@ namespace SourceGit.ViewModels
|
|||
|
||||
return new Commands.QueryGitDir(repo).Result();
|
||||
}
|
||||
|
||||
private void SwitchWorkspace(Workspace to)
|
||||
{
|
||||
foreach (var one in Pages)
|
||||
{
|
||||
if (!one.CanCreatePopup() || one.Data is Repository { IsAutoFetching: true })
|
||||
{
|
||||
App.RaiseException(null, "You have unfinished task(s) in opened pages. Please wait!!!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_ignoreIndexChange = true;
|
||||
|
||||
var pref = Preferences.Instance;
|
||||
foreach (var w in pref.Workspaces)
|
||||
w.IsActive = false;
|
||||
|
||||
ActiveWorkspace = to;
|
||||
to.IsActive = true;
|
||||
|
||||
foreach (var one in Pages)
|
||||
CloseRepositoryInTab(one, false);
|
||||
|
||||
Pages.Clear();
|
||||
AddNewTab();
|
||||
|
||||
var repos = to.Repositories.ToArray();
|
||||
foreach (var repo in repos)
|
||||
{
|
||||
var node = pref.FindNode(repo);
|
||||
if (node == null)
|
||||
{
|
||||
node = new RepositoryNode()
|
||||
{
|
||||
Id = repo,
|
||||
Name = Path.GetFileName(repo),
|
||||
Bookmark = 0,
|
||||
IsRepository = true,
|
||||
};
|
||||
}
|
||||
|
||||
OpenRepositoryInTab(node, null);
|
||||
}
|
||||
|
||||
var activeIdx = to.ActiveIdx;
|
||||
if (activeIdx >= 0 && activeIdx < Pages.Count)
|
||||
{
|
||||
ActivePage = Pages[activeIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivePage = Pages[0];
|
||||
to.ActiveIdx = 0;
|
||||
}
|
||||
|
||||
_ignoreIndexChange = false;
|
||||
Preferences.Instance.Save();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
private void CloseRepositoryInTab(LauncherPage page, bool removeFromWorkspace = true)
|
||||
{
|
||||
|
@ -581,7 +592,7 @@ namespace SourceGit.ViewModels
|
|||
return;
|
||||
|
||||
var workspace = _activeWorkspace.Name;
|
||||
if (_activePage is { Data: Repository repo })
|
||||
if (_activePage is { Data: Repository })
|
||||
{
|
||||
var node = _activePage.Node;
|
||||
var name = node.Name;
|
||||
|
@ -607,5 +618,6 @@ namespace SourceGit.ViewModels
|
|||
private LauncherPage _activePage = null;
|
||||
private bool _ignoreIndexChange = false;
|
||||
private string _title = string.Empty;
|
||||
private WorkspaceSwitcher _workspaceSwitcher = null;
|
||||
}
|
||||
}
|
||||
|
|
75
src/ViewModels/WorkspaceSwitcher.cs
Normal file
75
src/ViewModels/WorkspaceSwitcher.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class WorkspaceSwitcher : ObservableObject
|
||||
{
|
||||
public List<Workspace> VisibleWorkspaces
|
||||
{
|
||||
get => _visibleWorkspaces;
|
||||
private set => SetProperty(ref _visibleWorkspaces, value);
|
||||
}
|
||||
|
||||
public string SearchFilter
|
||||
{
|
||||
get => _searchFilter;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _searchFilter, value))
|
||||
UpdateVisibleWorkspaces();
|
||||
}
|
||||
}
|
||||
|
||||
public Workspace SelectedWorkspace
|
||||
{
|
||||
get => _selectedWorkspace;
|
||||
set => SetProperty(ref _selectedWorkspace, value);
|
||||
}
|
||||
|
||||
public WorkspaceSwitcher(Launcher launcher)
|
||||
{
|
||||
_launcher = launcher;
|
||||
UpdateVisibleWorkspaces();
|
||||
}
|
||||
|
||||
public void ClearFilter()
|
||||
{
|
||||
SearchFilter = string.Empty;
|
||||
}
|
||||
|
||||
public void Switch()
|
||||
{
|
||||
if (_selectedWorkspace is { })
|
||||
_launcher.SwitchWorkspace(_selectedWorkspace);
|
||||
|
||||
_launcher.CancelWorkspaceSwitcher();
|
||||
}
|
||||
|
||||
private void UpdateVisibleWorkspaces()
|
||||
{
|
||||
var visible = new List<Workspace>();
|
||||
if (string.IsNullOrEmpty(_searchFilter))
|
||||
{
|
||||
visible.AddRange(Preferences.Instance.Workspaces);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var workspace in Preferences.Instance.Workspaces)
|
||||
{
|
||||
if (workspace.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase))
|
||||
visible.Add(workspace);
|
||||
}
|
||||
}
|
||||
|
||||
VisibleWorkspaces = visible;
|
||||
SelectedWorkspace = visible.Count == 0 ? null : visible[0];
|
||||
}
|
||||
|
||||
private Launcher _launcher = null;
|
||||
private List<Workspace> _visibleWorkspaces = null;
|
||||
private string _searchFilter = string.Empty;
|
||||
private Workspace _selectedWorkspace = null;
|
||||
}
|
||||
}
|
|
@ -78,10 +78,10 @@ namespace SourceGit.Views
|
|||
if (switches[idx])
|
||||
context.FillRectangle(brush, new Rect(x, y, stepX, stepY));
|
||||
|
||||
if (switches[idx+1])
|
||||
if (switches[idx + 1])
|
||||
context.FillRectangle(brush, new Rect(x + stepX, y, stepX, stepY));
|
||||
|
||||
if (switches[idx+2])
|
||||
if (switches[idx + 2])
|
||||
context.FillRectangle(brush, new Rect(x + stepX * 2, y, stepX, stepY));
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace SourceGit.Views
|
|||
if (switches[idx])
|
||||
context.FillRectangle(brush, new Rect(x, y, stepX, stepY));
|
||||
|
||||
if (switches[idx-1])
|
||||
if (switches[idx - 1])
|
||||
context.FillRectangle(brush, new Rect(x + stepX, y, stepX, stepY));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
|
||||
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+P, macOS=⌘+\,}"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.OpenPreferences}"/>
|
||||
|
||||
|
@ -70,11 +70,8 @@
|
|||
<TextBlock Grid.Row="7" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Q, macOS=⌘+Q}"/>
|
||||
<TextBlock Grid.Row="7" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Quit}" />
|
||||
|
||||
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+Space, macOS=⌥+␣}"/>
|
||||
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.OpenWorkspaces}" />
|
||||
|
||||
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+1 - Alt+9, macOS=⌥+1 - ⌥+9}"/>
|
||||
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.OpenWorkspaceAtIndex}" />
|
||||
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+P, macOS=⌘+P}"/>
|
||||
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Global.SwitchWorkspace}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="{DynamicResource Text.Hotkeys.Repo}"
|
||||
|
|
|
@ -72,8 +72,8 @@
|
|||
<Path Width="12" Height="12" Data="{StaticResource Icons.Menu}"/>
|
||||
</Button>
|
||||
|
||||
<!-- Workspace Switcher -->
|
||||
<Button Grid.Column="1" Classes="icon_button" Name="WorkspacesButton" VerticalAlignment="Bottom" Margin="0,0,0,1" Click="OnOpenWorkspaceMenu">
|
||||
<!-- Workspace Dropdown Menu -->
|
||||
<Button Grid.Column="1" Classes="icon_button" VerticalAlignment="Bottom" Margin="0,0,0,1" Click="OnOpenWorkspaceMenu">
|
||||
<ToolTip.Tip>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{DynamicResource Text.Workspace}" FontWeight="Bold" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
|
@ -85,10 +85,10 @@
|
|||
Fill="{Binding ActiveWorkspace.Brush}"/>
|
||||
</Button>
|
||||
|
||||
<!-- Pages Tabs-->
|
||||
<!-- Pages Tabs -->
|
||||
<v:LauncherTabBar Grid.Column="2" Height="30" Margin="0,0,16,0" VerticalAlignment="Bottom"/>
|
||||
|
||||
<!-- Caption Buttons (Windows/Linux)-->
|
||||
<!-- Caption Buttons (Windows/Linux) -->
|
||||
<Border Grid.Column="3" Margin="16,0,0,0" IsVisible="{Binding #ThisControl.HasRightCaptionButton}">
|
||||
<v:CaptionButtons Height="30" VerticalAlignment="Top"/>
|
||||
</Border>
|
||||
|
@ -102,5 +102,22 @@
|
|||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
<!-- Workspace Switcher -->
|
||||
<Border Grid.Row="1"
|
||||
Background="Transparent"
|
||||
IsVisible="{Binding WorkspaceSwitcher, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Effect="drop-shadow(0 0 12 #A0000000)">
|
||||
<Border Background="{DynamicResource Brush.Popup}" CornerRadius="8">
|
||||
<ContentControl Margin="16" Content="{Binding WorkspaceSwitcher}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:WorkspaceSwitcher">
|
||||
<v:WorkspaceSwitcher/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</v:ChromelessWindow>
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace SourceGit.Views
|
|||
|
||||
if (change.Property == WindowStateProperty)
|
||||
{
|
||||
_lastWindowState = (WindowState)change.OldValue;
|
||||
_lastWindowState = (WindowState)change.OldValue!;
|
||||
|
||||
var state = (WindowState)change.NewValue!;
|
||||
if (!OperatingSystem.IsMacOS() && !UseSystemWindowFrame)
|
||||
|
@ -157,6 +157,12 @@ namespace SourceGit.Views
|
|||
|
||||
if (e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
|
||||
{
|
||||
if (e.Key == Key.P)
|
||||
{
|
||||
vm.OpenWorkspaceSwitcher();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
if (e.Key == Key.W)
|
||||
{
|
||||
vm.CloseTab(null);
|
||||
|
@ -248,30 +254,10 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (e.KeyModifiers.HasFlag(KeyModifiers.Alt))
|
||||
{
|
||||
if (e.Key == Key.Space && DataContext is ViewModels.Launcher launcher)
|
||||
{
|
||||
var menu = launcher.CreateContextForWorkspace();
|
||||
var workspacesButton = this.FindControl<Button>("WorkspacesButton");
|
||||
if (menu != null)
|
||||
{
|
||||
menu.PlacementTarget = workspacesButton;
|
||||
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
|
||||
menu.Open(workspacesButton);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchToWorkspaceIndex(e.Key);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
vm.ActivePage.CancelPopup();
|
||||
vm.CancelWorkspaceSwitcher();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
@ -303,29 +289,6 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void SwitchToWorkspaceIndex(Key eKey)
|
||||
{
|
||||
int newIndex;
|
||||
switch (eKey)
|
||||
{
|
||||
case Key.D1 or Key.NumPad1: newIndex = 0; break;
|
||||
case Key.D2 or Key.NumPad2: newIndex = 1; break;
|
||||
case Key.D3 or Key.NumPad3: newIndex = 2; break;
|
||||
case Key.D4 or Key.NumPad4: newIndex = 3; break;
|
||||
case Key.D5 or Key.NumPad5: newIndex = 4; break;
|
||||
case Key.D6 or Key.NumPad6: newIndex = 5; break;
|
||||
case Key.D7 or Key.NumPad7: newIndex = 6; break;
|
||||
case Key.D8 or Key.NumPad8: newIndex = 7; break;
|
||||
case Key.D9 or Key.NumPad9: newIndex = 8; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if (DataContext is ViewModels.Launcher launcher)
|
||||
{
|
||||
launcher.SwitchWorkspace(newIndex);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyUp(e);
|
||||
|
|
111
src/Views/WorkspaceSwitcher.axaml
Normal file
111
src/Views/WorkspaceSwitcher.axaml
Normal file
|
@ -0,0 +1,111 @@
|
|||
<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:vm="using:SourceGit.ViewModels"
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.WorkspaceSwitcher"
|
||||
x:DataType="vm:WorkspaceSwitcher">
|
||||
<Grid RowDefinitions="28,Auto,Auto">
|
||||
<TextBlock Grid.Row="0"
|
||||
Text="{DynamicResource Text.Repository.WorkspaceSwitcher}"
|
||||
FontWeight="Bold"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Top"/>
|
||||
|
||||
<TextBox Grid.Row="1"
|
||||
Height="24"
|
||||
Margin="4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding SearchFilter, Mode=TwoWay}"
|
||||
KeyDown="OnSearchBoxKeyDown"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center"
|
||||
v:AutoFocusBehaviour.IsEnabled="True">
|
||||
<TextBox.InnerLeftContent>
|
||||
<Path Width="14" Height="14"
|
||||
Margin="6,0,0,0"
|
||||
Fill="{DynamicResource Brush.FG2}"
|
||||
Data="{StaticResource Icons.Search}"/>
|
||||
</TextBox.InnerLeftContent>
|
||||
|
||||
<TextBox.InnerRightContent>
|
||||
<Button Classes="icon_button"
|
||||
Width="16"
|
||||
Margin="0,0,6,0"
|
||||
Command="{Binding ClearFilter}"
|
||||
IsVisible="{Binding SearchFilter, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||
HorizontalAlignment="Right">
|
||||
<Path Width="14" Height="14"
|
||||
Margin="0,1,0,0"
|
||||
Fill="{DynamicResource Brush.FG1}"
|
||||
Data="{StaticResource Icons.Clear}"/>
|
||||
</Button>
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
|
||||
<ListBox Grid.Row="2"
|
||||
x:Name="WorkspaceListBox"
|
||||
Width="300"
|
||||
MaxHeight="400"
|
||||
Margin="0,8,0,0"
|
||||
BorderThickness="0"
|
||||
SelectionMode="Single"
|
||||
Background="Transparent"
|
||||
Focusable="True"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ItemsSource="{Binding VisibleWorkspaces, Mode=OneWay}"
|
||||
SelectedItem="{Binding SelectedWorkspace, Mode=TwoWay}">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Padding" Value="8,0"/>
|
||||
<Setter Property="MinHeight" Value="26"/>
|
||||
<Setter Property="CornerRadius" Value="4"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox">
|
||||
<Setter Property="FocusAdorner">
|
||||
<FocusAdornerTemplate>
|
||||
<Grid/>
|
||||
</FocusAdornerTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="vm:Workspace">
|
||||
<Grid ColumnDefinitions="Auto,*" VerticalAlignment="Center" Background="Transparent" DoubleTapped="OnItemDoubleTapped">
|
||||
<Path Grid.Column="0"
|
||||
Width="12" Height="12"
|
||||
Fill="{Binding Brush}"
|
||||
Data="{StaticResource Icons.Workspace}"
|
||||
IsVisible="{Binding !IsActive}"
|
||||
IsHitTestVisible="False"/>
|
||||
<Path Grid.Column="0"
|
||||
Width="12" Height="12"
|
||||
Fill="{Binding Brush}"
|
||||
Data="{StaticResource Icons.Check}"
|
||||
IsVisible="{Binding IsActive}"
|
||||
IsHitTestVisible="False"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Margin="8,0,0,0"
|
||||
Classes="primary"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Name}"
|
||||
IsHitTestVisible="False"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
49
src/Views/WorkspaceSwitcher.axaml.cs
Normal file
49
src/Views/WorkspaceSwitcher.axaml.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class WorkspaceSwitcher : UserControl
|
||||
{
|
||||
public WorkspaceSwitcher()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
if (e.Key == Key.Enter && DataContext is ViewModels.WorkspaceSwitcher switcher)
|
||||
{
|
||||
switcher.Switch();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.WorkspaceSwitcher switcher)
|
||||
{
|
||||
switcher.Switch();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchBoxKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Down && WorkspaceListBox.ItemCount > 0)
|
||||
{
|
||||
WorkspaceListBox.Focus(NavigationMethod.Directional);
|
||||
|
||||
if (WorkspaceListBox.SelectedIndex < 0)
|
||||
WorkspaceListBox.SelectedIndex = 0;
|
||||
else if (WorkspaceListBox.SelectedIndex < WorkspaceListBox.ItemCount)
|
||||
WorkspaceListBox.SelectedIndex++;
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue