1
- using System . Collections . ObjectModel ;
1
+ using System . Collections . Generic ;
2
+ using System . Collections . ObjectModel ;
2
3
using System . Windows ;
3
4
using System . Windows . Input ;
4
5
using Flow . Launcher . Core . Resource ;
@@ -16,6 +17,28 @@ public partial class HotkeyControlDialog : ContentDialog
16
17
public HotkeyModel CurrentHotkey { get ; private set ; }
17
18
public ObservableCollection < string > KeysToDisplay { get ; } = new ( ) ;
18
19
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
+
19
42
public enum EResultType
20
43
{
21
44
Cancel ,
@@ -109,11 +132,20 @@ private void SetKeysToDisplay(HotkeyModel? hotkey)
109
132
if ( tbMsg == null )
110
133
return ;
111
134
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
+ }
112
146
if ( ! CheckHotkeyAvailability ( hotkey . Value , true ) )
113
147
{
114
- tbMsg . Text = InternationalizationManager . Instance . GetTranslation ( "hotkeyUnavailable" ) ;
115
- Alert . Visibility = Visibility . Visible ;
116
- SaveBtn . IsEnabled = false ;
148
+ ShowWarningAndDisableSaveButton ( InternationalizationManager . Instance . GetTranslation ( "hotkeyUnavailable" ) ) ;
117
149
}
118
150
else
119
151
{
@@ -122,6 +154,13 @@ private void SetKeysToDisplay(HotkeyModel? hotkey)
122
154
}
123
155
}
124
156
157
+ private void ShowWarningAndDisableSaveButton ( string message )
158
+ {
159
+ tbMsg . Text = message ;
160
+ Alert . Visibility = Visibility . Visible ;
161
+ SaveBtn . IsEnabled = false ;
162
+ }
163
+
125
164
private static bool CheckHotkeyAvailability ( HotkeyModel hotkey , bool validateKeyGesture ) =>
126
165
hotkey . Validate ( validateKeyGesture ) && HotKeyMapper . CheckAvailability ( hotkey ) ;
127
166
}
0 commit comments