1- using System . Collections . ObjectModel ;
1+ using System . Collections . Generic ;
2+ using System . Collections . ObjectModel ;
23using System . Windows ;
34using System . Windows . Input ;
45using Flow . Launcher . Core . Resource ;
@@ -16,6 +17,28 @@ public partial class HotkeyControlDialog : ContentDialog
1617 public HotkeyModel CurrentHotkey { get ; private set ; }
1718 public ObservableCollection < string > KeysToDisplay { get ; } = new ( ) ;
1819
20+ private readonly Dictionary < HotkeyModel , string > StaticHotkeys = new ( )
21+ {
22+ [ new HotkeyModel ( "Escape" ) ] = "" , // TODO
23+ [ new HotkeyModel ( "F5" ) ] = "ReloadPluginHotkey" ,
24+ [ new HotkeyModel ( "Alt+Home" ) ] = "Select first result" , // TODO
25+ [ new HotkeyModel ( "Alt+End" ) ] = "Select last result" , // TODO
26+ [ new HotkeyModel ( "Ctrl+R" ) ] = "Requery" , // TODO
27+ [ new HotkeyModel ( "Ctrl+H" ) ] = "ToggleHistoryHotkey" ,
28+ [ new HotkeyModel ( "Ctrl+OemCloseBrackets" ) ] = "QuickWidthHotkey" ,
29+ [ new HotkeyModel ( "Ctrl+OemOpenBrackets" ) ] = "QuickWidthHotkey" ,
30+ [ new HotkeyModel ( "Ctrl+OemPlus" ) ] = "QuickHeightHotkey" ,
31+ [ new HotkeyModel ( "Ctrl+OemMinus" ) ] = "QuickHeightHotkey" ,
32+ [ new HotkeyModel ( "Ctrl+Shift+Enter" ) ] = "HotkeyCtrlShiftEnterDesc" ,
33+ [ new HotkeyModel ( "Shift+Enter" ) ] = "OpenContextMenuHotkey" ,
34+ [ new HotkeyModel ( "Enter" ) ] = "HotkeyRunDesc" ,
35+ [ new HotkeyModel ( "Ctrl+Enter" ) ] = "Open result" , // TODO
36+ [ new HotkeyModel ( "Alt+Enter" ) ] = "Open result" , // TODO
37+ // TODO D0-D9 But not here since they're not completely static, they can be Ctrl+D0-D9, Alt+D0-D9, or Ctrl+Alt+D0-D9
38+ [ new HotkeyModel ( "Ctrl+F12" ) ] = "ToggleGameModeHotkey" ,
39+ [ new HotkeyModel ( "Ctrl+Shift+C" ) ] = "Copy alternative" , // TODO
40+ } ;
41+
1942 public enum EResultType
2043 {
2144 Cancel ,
@@ -109,11 +132,20 @@ private void SetKeysToDisplay(HotkeyModel? hotkey)
109132 if ( tbMsg == null )
110133 return ;
111134
135+
136+ if ( StaticHotkeys . TryGetValue ( ( HotkeyModel ) hotkey , out var staticHotkey ) )
137+ {
138+ ShowWarningAndDisableSaveButton (
139+ string . Format (
140+ InternationalizationManager . Instance . GetTranslation ( "hotkeyUnavailableInUseStatic" ) ,
141+ InternationalizationManager . Instance . GetTranslation ( staticHotkey )
142+ )
143+ ) ;
144+ return ;
145+ }
112146 if ( ! CheckHotkeyAvailability ( hotkey . Value , true ) )
113147 {
114- tbMsg . Text = InternationalizationManager . Instance . GetTranslation ( "hotkeyUnavailable" ) ;
115- Alert . Visibility = Visibility . Visible ;
116- SaveBtn . IsEnabled = false ;
148+ ShowWarningAndDisableSaveButton ( InternationalizationManager . Instance . GetTranslation ( "hotkeyUnavailable" ) ) ;
117149 }
118150 else
119151 {
@@ -122,6 +154,13 @@ private void SetKeysToDisplay(HotkeyModel? hotkey)
122154 }
123155 }
124156
157+ private void ShowWarningAndDisableSaveButton ( string message )
158+ {
159+ tbMsg . Text = message ;
160+ Alert . Visibility = Visibility . Visible ;
161+ SaveBtn . IsEnabled = false ;
162+ }
163+
125164 private static bool CheckHotkeyAvailability ( HotkeyModel hotkey , bool validateKeyGesture ) =>
126165 hotkey . Validate ( validateKeyGesture ) && HotKeyMapper . CheckAvailability ( hotkey ) ;
127166}
0 commit comments