From 01945f231ed8f98e49cdd3de848c922c157c1053 Mon Sep 17 00:00:00 2001 From: popara <31167073+popara96@users.noreply.github.com> Date: Sat, 17 May 2025 07:17:10 +0200 Subject: [PATCH] Added workspaces shortcuts (#1328) - added Alt+Space for opening Workspaces context menu (which can then be navigated normally with arrows) - added Alt+1 through Alt+9 for switching to corresponding workspace --- src/Resources/Locales/en_US.axaml | 2 ++ src/ViewModels/Launcher.cs | 10 ++++++- src/Views/Hotkeys.axaml | 8 +++++- src/Views/Launcher.axaml | 2 +- src/Views/Launcher.axaml.cs | 44 +++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 2f7c5c43..63c9815d 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -386,6 +386,8 @@ Go to previous page Create new page Open Preferences dialog + Open Workspaces dialog + Switch to corresponding workspace REPOSITORY Commit staged changes Commit and push staged changes diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index d9425059..5eaca763 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -463,6 +463,14 @@ 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"); @@ -493,7 +501,7 @@ namespace SourceGit.ViewModels return new Commands.QueryGitDir(repo).Result(); } - + private void SwitchWorkspace(Workspace to) { foreach (var one in Pages) diff --git a/src/Views/Hotkeys.axaml b/src/Views/Hotkeys.axaml index 87242793..b1d436a4 100644 --- a/src/Views/Hotkeys.axaml +++ b/src/Views/Hotkeys.axaml @@ -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"/> - + @@ -69,6 +69,12 @@ + + + + + + -