diff --git a/src/Resources/Styles/ListBox.xaml b/src/Resources/Styles/ListBox.xaml index ee55ea0d..2fda7c79 100644 --- a/src/Resources/Styles/ListBox.xaml +++ b/src/Resources/Styles/ListBox.xaml @@ -4,6 +4,7 @@ + diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs index 2f2d3964..6aff44de 100644 --- a/src/Views/Launcher.xaml.cs +++ b/src/Views/Launcher.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using System.Windows; +using System.Windows.Input; namespace SourceGit.Views { @@ -94,5 +95,54 @@ namespace SourceGit.Views { GC.Collect(); } #endregion + + #region HOTKEYS + protected override void OnPreviewKeyDown(KeyEventArgs e) { + if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { + if (Keyboard.IsKeyDown(Key.Tab)) { + tabs.Next(); + e.Handled = true; + return; + } + + if (Keyboard.IsKeyDown(Key.W)) { + tabs.CloseCurrent(); + e.Handled = true; + return; + } + + if (Keyboard.IsKeyDown(Key.T)) { + OnTabAdding(null, null); + e.Handled = true; + return; + } + + if (Keyboard.IsKeyDown(Key.F)) { + var dashboard = container.Get(tabs.Current) as Widgets.Dashboard; + if (dashboard != null) { + dashboard.OpenSearch(null, null); + e.Handled = true; + return; + } + } + + for (int i = 0; i < 10; i++) { + if (Keyboard.IsKeyDown(Key.D1 + i)) { + if (tabs.Tabs.Count > i) { + tabs.Goto(tabs.Tabs[i].Id); + e.Handled = true; + return; + } + } + } + } + + if (Keyboard.IsKeyDown(Key.F5)) { + Models.Watcher.Get(tabs.Current)?.Refresh(); + e.Handled = true; + return; + } + } + #endregion } } diff --git a/src/Views/Widgets/Dashboard.xaml.cs b/src/Views/Widgets/Dashboard.xaml.cs index 0ed1c376..5a12e642 100644 --- a/src/Views/Widgets/Dashboard.xaml.cs +++ b/src/Views/Widgets/Dashboard.xaml.cs @@ -319,7 +319,7 @@ namespace SourceGit.Views.Widgets { e.Handled = true; } - private void OpenSearch(object sender, RoutedEventArgs e) { + public void OpenSearch(object sender, RoutedEventArgs e) { if (popup.IsLocked) return; popup.Close(); diff --git a/src/Views/Widgets/PageTabBar.xaml b/src/Views/Widgets/PageTabBar.xaml index c180eee3..55773d47 100644 --- a/src/Views/Widgets/PageTabBar.xaml +++ b/src/Views/Widgets/PageTabBar.xaml @@ -49,6 +49,7 @@