refactor: workspace/page switcher (#1330)

- add `Switch Tab` popup
- change hotkey to open `Preferences` to `Ctrl+,/⌘+,`
- change hotkey to open `Switch Workspace` to `Ctrl+Shift+P/⌘+⇧+P`
- change hotkey to open `Switch Tab` to `Ctrl+P/⌘+P`

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-18 19:36:17 +08:00
parent 36c2e083cc
commit 9614b995d8
No known key found for this signature in database
17 changed files with 418 additions and 180 deletions

View file

@ -133,8 +133,8 @@ namespace SourceGit.Views
return;
}
// Ctrl+Shift+P opens preference dialog (macOS use hotkeys in system menu bar)
if (!OperatingSystem.IsMacOS() && e is { KeyModifiers: (KeyModifiers.Control | KeyModifiers.Shift), Key: Key.P })
// Ctrl+, opens preference dialog (macOS use hotkeys in system menu bar)
if (!OperatingSystem.IsMacOS() && e is { KeyModifiers: KeyModifiers.Control, Key: Key.OemComma })
{
App.ShowWindow(new Preferences(), true);
e.Handled = true;
@ -149,7 +149,7 @@ namespace SourceGit.Views
}
// Ctrl+Q quits the application (macOS use hotkeys in system menu bar)
if (!OperatingSystem.IsMacOS() && e.KeyModifiers == KeyModifiers.Control && e.Key == Key.Q)
if (!OperatingSystem.IsMacOS() && e is { KeyModifiers: KeyModifiers.Control, Key: Key.Q })
{
App.Quit(0);
return;
@ -157,10 +157,18 @@ namespace SourceGit.Views
if (e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
{
if (e.Key == Key.P)
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift) && e.Key == Key.P)
{
vm.OpenWorkspaceSwitcher();
e.Handled = true;
return;
}
if (e.Key == Key.P)
{
vm.OpenTabSwitcher();
e.Handled = true;
return;
}
if (e.Key == Key.W)
@ -257,7 +265,7 @@ namespace SourceGit.Views
else if (e.Key == Key.Escape)
{
vm.ActivePage.CancelPopup();
vm.CancelWorkspaceSwitcher();
vm.CancelSwitcher();
e.Handled = true;
return;
}