11using System ;
2+ using System . Windows . Input ;
3+ using Flow . Launcher . Plugin ;
24
35namespace Flow . Launcher . Infrastructure . Hotkey ;
46
@@ -11,6 +13,16 @@ namespace Flow.Launcher.Infrastructure.Hotkey;
1113/// </summary>
1214public class RegisteredHotkeyData : BaseModel
1315{
16+ /// <summary>
17+ /// Type of this hotkey in the context of the application.
18+ /// </summary>
19+ public RegisteredHotkeyType RegisteredType { get ; }
20+
21+ /// <summary>
22+ /// Type of this hotkey.
23+ /// </summary>
24+ public HotkeyType Type { get ; }
25+
1426 /// <summary>
1527 /// <see cref="HotkeyModel"/> representation of this hotkey.
1628 /// </summary>
@@ -40,6 +52,16 @@ public HotkeyModel Hotkey
4052 /// </summary>
4153 public object ? [ ] DescriptionFormatVariables { get ; } = Array . Empty < object ? > ( ) ;
4254
55+ /// <summary>
56+ /// Command of this hotkey. If it's <c>null</c>, the hotkey is assumed to be registered by system.
57+ /// </summary>
58+ public ICommand ? Command { get ; }
59+
60+ /// <summary>
61+ /// Command parameter of this hotkey.
62+ /// </summary>
63+ public object ? CommandParameter { get ; }
64+
4365 /// <summary>
4466 /// An action that, when called, will unregister this hotkey. If it's <c>null</c>, it's assumed that
4567 /// this hotkey can't be unregistered, and the "Overwrite" option will not appear in the hotkey dialog.
@@ -51,6 +73,12 @@ public HotkeyModel Hotkey
5173 /// <c>descriptionResourceKey</c> doesn't need any arguments for <c>string.Format</c>. If it does,
5274 /// use one of the other constructors.
5375 /// </summary>
76+ /// <param name="registeredType">
77+ /// The type of this hotkey in the context of the application.
78+ /// </param>
79+ /// <param name="type">
80+ /// Whether this hotkey is global or search window specific.
81+ /// </param>
5482 /// <param name="hotkey">
5583 /// The hotkey this class will represent.
5684 /// Example values: <c>F1</c>, <c>Ctrl+Shift+Enter</c>
@@ -59,21 +87,81 @@ public HotkeyModel Hotkey
5987 /// The key in the localization dictionary that represents this hotkey. For example, <c>ReloadPluginHotkey</c>,
6088 /// which represents the string "Reload Plugins Data" in <c>en.xaml</c>
6189 /// </param>
90+ /// <param name="command">
91+ /// The command that will be executed when this hotkey is triggered. If it's <c>null</c>, the hotkey is assumed to be registered by system.
92+ /// </param>
93+ /// <param name="parameter">
94+ /// The command parameter that will be passed to the command when this hotkey is triggered. If it's <c>null</c>, no parameter will be passed.
95+ /// </param>
6296 /// <param name="removeHotkey">
6397 /// An action that, when called, will unregister this hotkey. If it's <c>null</c>, it's assumed that this hotkey
6498 /// can't be unregistered, and the "Overwrite" option will not appear in the hotkey dialog.
6599 /// </param>
66- public RegisteredHotkeyData ( string hotkey , string descriptionResourceKey , Action ? removeHotkey = null )
100+ public RegisteredHotkeyData (
101+ RegisteredHotkeyType registeredType , HotkeyType type , string hotkey , string descriptionResourceKey ,
102+ ICommand ? command , object ? parameter = null , Action ? removeHotkey = null )
67103 {
104+ RegisteredType = registeredType ;
105+ Type = type ;
68106 Hotkey = new HotkeyModel ( hotkey ) ;
69107 DescriptionResourceKey = descriptionResourceKey ;
108+ Command = command ;
109+ CommandParameter = parameter ;
110+ RemoveHotkey = removeHotkey ;
111+ }
112+
113+ /// <summary>
114+ /// Creates an instance of <c>RegisteredHotkeyData</c>. Assumes that the key specified in
115+ /// <c>descriptionResourceKey</c> doesn't need any arguments for <c>string.Format</c>. If it does,
116+ /// use one of the other constructors.
117+ /// </summary>
118+ /// <param name="registeredType">
119+ /// The type of this hotkey in the context of the application.
120+ /// </param>
121+ /// <param name="type">
122+ /// Whether this hotkey is global or search window specific.
123+ /// </param>
124+ /// <param name="hotkey">
125+ /// The hotkey this class will represent.
126+ /// Example values: <c>F1</c>, <c>Ctrl+Shift+Enter</c>
127+ /// </param>
128+ /// <param name="descriptionResourceKey">
129+ /// The key in the localization dictionary that represents this hotkey. For example, <c>ReloadPluginHotkey</c>,
130+ /// which represents the string "Reload Plugins Data" in <c>en.xaml</c>
131+ /// </param>
132+ /// <param name="command">
133+ /// The command that will be executed when this hotkey is triggered. If it's <c>null</c>, the hotkey is assumed to be registered by system.
134+ /// </param>
135+ /// <param name="parameter">
136+ /// The command parameter that will be passed to the command when this hotkey is triggered. If it's <c>null</c>, no parameter will be passed.
137+ /// </param>
138+ /// <param name="removeHotkey">
139+ /// An action that, when called, will unregister this hotkey. If it's <c>null</c>, it's assumed that this hotkey
140+ /// can't be unregistered, and the "Overwrite" option will not appear in the hotkey dialog.
141+ /// </param>
142+ public RegisteredHotkeyData (
143+ RegisteredHotkeyType registeredType , HotkeyType type , HotkeyModel hotkey , string descriptionResourceKey ,
144+ ICommand ? command , object ? parameter = null , Action ? removeHotkey = null )
145+ {
146+ RegisteredType = registeredType ;
147+ Type = type ;
148+ Hotkey = hotkey ;
149+ DescriptionResourceKey = descriptionResourceKey ;
150+ Command = command ;
151+ CommandParameter = parameter ;
70152 RemoveHotkey = removeHotkey ;
71153 }
72154
73155 /// <summary>
74156 /// Creates an instance of <c>RegisteredHotkeyData</c>. Assumes that the key specified in
75157 /// <c>descriptionResourceKey</c> needs exactly one argument for <c>string.Format</c>.
76158 /// </summary>
159+ /// <param name="registeredType">
160+ /// The type of this hotkey in the context of the application.
161+ /// </param>
162+ /// <param name="type">
163+ /// Whether this hotkey is global or search window specific.
164+ /// </param>
77165 /// <param name="hotkey">
78166 /// The hotkey this class will represent.
79167 /// Example values: <c>F1</c>, <c>Ctrl+Shift+Enter</c>
@@ -85,24 +173,41 @@ public RegisteredHotkeyData(string hotkey, string descriptionResourceKey, Action
85173 /// <param name="descriptionFormatVariable">
86174 /// The value that will replace <c>{0}</c> in the localized string found via <c>description</c>.
87175 /// </param>
176+ /// <param name="command">
177+ /// The command that will be executed when this hotkey is triggered. If it's <c>null</c>, the hotkey is assumed to be registered by system.
178+ /// </param>
179+ /// <param name="parameter">
180+ /// The command parameter that will be passed to the command when this hotkey is triggered. If it's <c>null</c>, no parameter will be passed.
181+ /// </param>
88182 /// <param name="removeHotkey">
89183 /// An action that, when called, will unregister this hotkey. If it's <c>null</c>, it's assumed that this hotkey
90184 /// can't be unregistered, and the "Overwrite" option will not appear in the hotkey dialog.
91185 /// </param>
92186 public RegisteredHotkeyData (
93- string hotkey , string descriptionResourceKey , object ? descriptionFormatVariable , Action ? removeHotkey = null
187+ RegisteredHotkeyType registeredType , HotkeyType type , string hotkey , string descriptionResourceKey , object ? descriptionFormatVariable ,
188+ ICommand ? command , object ? parameter = null , Action ? removeHotkey = null
94189 )
95190 {
191+ RegisteredType = registeredType ;
192+ Type = type ;
96193 Hotkey = new HotkeyModel ( hotkey ) ;
97194 DescriptionResourceKey = descriptionResourceKey ;
98195 DescriptionFormatVariables = new [ ] { descriptionFormatVariable } ;
196+ Command = command ;
197+ CommandParameter = parameter ;
99198 RemoveHotkey = removeHotkey ;
100199 }
101200
102201 /// <summary>
103202 /// Creates an instance of <c>RegisteredHotkeyData</c>. Assumes that the key specified in
104203 /// <paramref name="descriptionResourceKey"/> needs multiple arguments for <c>string.Format</c>.
105204 /// </summary>
205+ /// <param name="registeredType">
206+ /// The type of this hotkey in the context of the application.
207+ /// </param>
208+ /// <param name="type">
209+ /// Whether this hotkey is global or search window specific.
210+ /// </param>
106211 /// <param name="hotkey">
107212 /// The hotkey this class will represent.
108213 /// Example values: <c>F1</c>, <c>Ctrl+Shift+Enter</c>
@@ -115,17 +220,87 @@ public RegisteredHotkeyData(
115220 /// Array of values that will replace <c>{0}</c>, <c>{1}</c>, <c>{2}</c>, etc.
116221 /// in the localized string found via <c>description</c>.
117222 /// </param>
223+ /// <param name="command">
224+ /// The command that will be executed when this hotkey is triggered. If it's <c>null</c>, the hotkey is assumed to be registered by system.
225+ /// </param>
226+ /// <param name="parameter">
227+ /// The command parameter that will be passed to the command when this hotkey is triggered. If it's <c>null</c>, no parameter will be passed.
228+ /// </param>
118229 /// <param name="removeHotkey">
119230 /// An action that, when called, will unregister this hotkey. If it's <c>null</c>, it's assumed that this hotkey
120231 /// can't be unregistered, and the "Overwrite" option will not appear in the hotkey dialog.
121232 /// </param>
122233 public RegisteredHotkeyData (
123- string hotkey , string descriptionResourceKey , object ? [ ] descriptionFormatVariables , Action ? removeHotkey = null
234+ RegisteredHotkeyType registeredType , HotkeyType type , string hotkey , string descriptionResourceKey , object ? [ ] descriptionFormatVariables ,
235+ ICommand ? command , object ? parameter = null , Action ? removeHotkey = null
124236 )
125237 {
238+ RegisteredType = registeredType ;
239+ Type = type ;
126240 Hotkey = new HotkeyModel ( hotkey ) ;
127241 DescriptionResourceKey = descriptionResourceKey ;
128242 DescriptionFormatVariables = descriptionFormatVariables ;
243+ Command = command ;
244+ CommandParameter = parameter ;
129245 RemoveHotkey = removeHotkey ;
130246 }
131247}
248+
249+ public enum RegisteredHotkeyType
250+ {
251+ CtrlShiftEnter ,
252+ CtrlEnter ,
253+ AltEnter ,
254+
255+ Up ,
256+ Down ,
257+ Left ,
258+ Right ,
259+
260+ Esc ,
261+ Reload ,
262+ SelectFirstResult ,
263+ SelectLastResult ,
264+ ReQuery ,
265+ IncreaseWidth ,
266+ DecreaseWidth ,
267+ IncreaseMaxResult ,
268+ DecreaseMaxResult ,
269+ ShiftEnter ,
270+ Enter ,
271+ ToggleGameMode ,
272+ CopyFilePath ,
273+ OpenResultN1 ,
274+ OpenResultN2 ,
275+ OpenResultN3 ,
276+ OpenResultN4 ,
277+ OpenResultN5 ,
278+ OpenResultN6 ,
279+ OpenResultN7 ,
280+ OpenResultN8 ,
281+ OpenResultN9 ,
282+ OpenResultN10 ,
283+
284+ Toggle ,
285+
286+ Preview ,
287+ AutoComplete ,
288+ AutoComplete2 ,
289+ SelectNextItem ,
290+ SelectNextItem2 ,
291+ SelectPrevItem ,
292+ SelectPrevItem2 ,
293+ SettingWindow ,
294+ OpenHistory ,
295+ OpenContextMenu ,
296+ SelectNextPage ,
297+ SelectPrevPage ,
298+ CycleHistoryUp ,
299+ CycleHistoryDown ,
300+
301+ CustomQuery ,
302+
303+ PluginGlobalHotkey ,
304+
305+ PluginWindowHotkey ,
306+ }
0 commit comments