From 468d0e6f25c29c76709f6953508a71c4aec2d9a4 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 17 Sep 2021 18:00:18 +0800 Subject: [PATCH] feature: add hotkey ESC to close current popup panel --- src/Resources/Locales/en_US.xaml | 1 + src/Resources/Locales/zh_CN.xaml | 1 + src/Views/About.xaml.cs | 1 + src/Views/Launcher.xaml.cs | 13 +++++++++++++ src/Views/Widgets/PopupPanel.xaml.cs | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml index 7d49337c..82c827ac 100644 --- a/src/Resources/Locales/en_US.xaml +++ b/src/Resources/Locales/en_US.xaml @@ -466,6 +466,7 @@ Toggle search bar if possible Reload current repository if possible Stage or unstage selected files + Close current popup panel Reword Commit Message On : diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml index 22688414..3adbf3cc 100644 --- a/src/Resources/Locales/zh_CN.xaml +++ b/src/Resources/Locales/zh_CN.xaml @@ -465,6 +465,7 @@ 打开/隐藏搜索框(仅在仓库页起效) 重新加载当前仓库信息(仅在仓库页起效) 暂存或从暂存中移除当前选中 + 关闭当前弹出面板 编辑提交信息 提交: diff --git a/src/Views/About.xaml.cs b/src/Views/About.xaml.cs index 4cdc72cf..c533ae2b 100644 --- a/src/Views/About.xaml.cs +++ b/src/Views/About.xaml.cs @@ -34,6 +34,7 @@ namespace SourceGit.Views { new Keymap("CTRL + F", "Search"), new Keymap("F5", "Refresh"), new Keymap("SPACE", "ToggleStage"), + new Keymap("ESC", "CancelPopup"), }; } diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs index fb11b2e9..1b4a787a 100644 --- a/src/Views/Launcher.xaml.cs +++ b/src/Views/Launcher.xaml.cs @@ -170,6 +170,19 @@ namespace SourceGit.Views { e.Handled = true; return; } + + if (Keyboard.IsKeyDown(Key.Escape)) { + var page = container.Get(tabs.Current); + + var popup = null as Widgets.PopupPanel; + if (page is Widgets.Dashboard) { + popup = (page as Widgets.Dashboard).popup; + } else if (page is Widgets.Welcome) { + popup = (page as Widgets.Welcome).popup; + } + + popup?.CancelDirectly(); + } } #endregion } diff --git a/src/Views/Widgets/PopupPanel.xaml.cs b/src/Views/Widgets/PopupPanel.xaml.cs index e6ede10b..2918fbab 100644 --- a/src/Views/Widgets/PopupPanel.xaml.cs +++ b/src/Views/Widgets/PopupPanel.xaml.cs @@ -51,6 +51,10 @@ namespace SourceGit.Views.Widgets { Dispatcher.Invoke(() => txtMsg.Text = message); } + public void CancelDirectly() { + if (Visibility == Visibility.Visible) Cancel(this, null); + } + public void Close() { if (Visibility != Visibility.Visible) return;