feature<PopupPanel>: add hotkey ESC to close current popup panel

This commit is contained in:
leo 2021-09-17 18:00:18 +08:00
parent b134876f8b
commit 468d0e6f25
5 changed files with 20 additions and 0 deletions

View file

@ -466,6 +466,7 @@
<sys:String x:Key="Text.Hotkeys.Search">Toggle search bar if possible</sys:String> <sys:String x:Key="Text.Hotkeys.Search">Toggle search bar if possible</sys:String>
<sys:String x:Key="Text.Hotkeys.Refresh">Reload current repository if possible</sys:String> <sys:String x:Key="Text.Hotkeys.Refresh">Reload current repository if possible</sys:String>
<sys:String x:Key="Text.Hotkeys.ToggleStage">Stage or unstage selected files</sys:String> <sys:String x:Key="Text.Hotkeys.ToggleStage">Stage or unstage selected files</sys:String>
<sys:String x:Key="Text.Hotkeys.CancelPopup">Close current popup panel</sys:String>
<sys:String x:Key="Text.Reword">Reword Commit Message</sys:String> <sys:String x:Key="Text.Reword">Reword Commit Message</sys:String>
<sys:String x:Key="Text.Reword.On">On :</sys:String> <sys:String x:Key="Text.Reword.On">On :</sys:String>

View file

@ -465,6 +465,7 @@
<sys:String x:Key="Text.Hotkeys.Search">打开/隐藏搜索框(仅在仓库页起效)</sys:String> <sys:String x:Key="Text.Hotkeys.Search">打开/隐藏搜索框(仅在仓库页起效)</sys:String>
<sys:String x:Key="Text.Hotkeys.Refresh">重新加载当前仓库信息(仅在仓库页起效)</sys:String> <sys:String x:Key="Text.Hotkeys.Refresh">重新加载当前仓库信息(仅在仓库页起效)</sys:String>
<sys:String x:Key="Text.Hotkeys.ToggleStage">暂存或从暂存中移除当前选中</sys:String> <sys:String x:Key="Text.Hotkeys.ToggleStage">暂存或从暂存中移除当前选中</sys:String>
<sys:String x:Key="Text.Hotkeys.CancelPopup">关闭当前弹出面板</sys:String>
<sys:String x:Key="Text.Reword">编辑提交信息</sys:String> <sys:String x:Key="Text.Reword">编辑提交信息</sys:String>
<sys:String x:Key="Text.Reword.On">提交:</sys:String> <sys:String x:Key="Text.Reword.On">提交:</sys:String>

View file

@ -34,6 +34,7 @@ namespace SourceGit.Views {
new Keymap("CTRL + F", "Search"), new Keymap("CTRL + F", "Search"),
new Keymap("F5", "Refresh"), new Keymap("F5", "Refresh"),
new Keymap("SPACE", "ToggleStage"), new Keymap("SPACE", "ToggleStage"),
new Keymap("ESC", "CancelPopup"),
}; };
} }

View file

@ -170,6 +170,19 @@ namespace SourceGit.Views {
e.Handled = true; e.Handled = true;
return; 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 #endregion
} }

View file

@ -51,6 +51,10 @@ namespace SourceGit.Views.Widgets {
Dispatcher.Invoke(() => txtMsg.Text = message); Dispatcher.Invoke(() => txtMsg.Text = message);
} }
public void CancelDirectly() {
if (Visibility == Visibility.Visible) Cancel(this, null);
}
public void Close() { public void Close() {
if (Visibility != Visibility.Visible) return; if (Visibility != Visibility.Visible) return;