44using System . Drawing ;
55using System . Text . Json . Serialization ;
66using System . Windows ;
7+ using Flow . Launcher . Infrastructure . Hotkey ;
78using Flow . Launcher . Plugin ;
89using Flow . Launcher . Plugin . SharedModels ;
910using Flow . Launcher . ViewModel ;
1011
1112namespace Flow . Launcher . Infrastructure . UserSettings
1213{
13- public class Settings : BaseModel
14+ public class Settings : BaseModel , IHotkeySettings
1415 {
1516 private string language = "en" ;
1617 private string _theme = Constant . DefaultTheme ;
@@ -207,17 +208,17 @@ public string QuerySearchPrecisionString
207208
208209 public double WindowLeft { get ; set ; }
209210 public double WindowTop { get ; set ; }
210-
211+
211212 /// <summary>
212213 /// Custom left position on selected monitor
213214 /// </summary>
214215 public double CustomWindowLeft { get ; set ; } = 0 ;
215-
216+
216217 /// <summary>
217218 /// Custom top position on selected monitor
218219 /// </summary>
219220 public double CustomWindowTop { get ; set ; } = 0 ;
220-
221+
221222 public int MaxResultsToShow { get ; set ; } = 5 ;
222223 public int ActivateTimes { get ; set ; }
223224
@@ -229,7 +230,7 @@ public string QuerySearchPrecisionString
229230 [ JsonIgnore ]
230231 public ObservableCollection < BuiltinShortcutModel > BuiltinShortcuts { get ; set ; } = new ( )
231232 {
232- new BuiltinShortcutModel ( "{clipboard}" , "shortcut_clipboard_description" , Clipboard . GetText ) ,
233+ new BuiltinShortcutModel ( "{clipboard}" , "shortcut_clipboard_description" , Clipboard . GetText ) ,
233234 new BuiltinShortcutModel ( "{active_explorer_path}" , "shortcut_active_explorer_path" , FileExplorerHelper . GetActiveExplorerPath )
234235 } ;
235236
@@ -253,7 +254,7 @@ public bool HideNotifyIcon
253254
254255 [ JsonConverter ( typeof ( JsonStringEnumConverter ) ) ]
255256 public SearchWindowScreens SearchWindowScreen { get ; set ; } = SearchWindowScreens . Cursor ;
256-
257+
257258 [ JsonConverter ( typeof ( JsonStringEnumConverter ) ) ]
258259 public SearchWindowAligns SearchWindowAlign { get ; set ; } = SearchWindowAligns . Center ;
259260
@@ -273,6 +274,82 @@ public bool HideNotifyIcon
273274
274275 // This needs to be loaded last by staying at the bottom
275276 public PluginsSettings PluginSettings { get ; set ; } = new PluginsSettings ( ) ;
277+
278+ [ JsonIgnore ]
279+ public List < RegisteredHotkeyData > RegisteredHotkeys
280+ {
281+ get
282+ {
283+ var list = new List < RegisteredHotkeyData >
284+ {
285+ new ( "Up" , "HotkeyLeftRightDesc" ) ,
286+ new ( "Down" , "HotkeyLeftRightDesc" ) ,
287+ new ( "Left" , "HotkeyUpDownDesc" ) ,
288+ new ( "Right" , "HotkeyUpDownDesc" ) ,
289+ new ( "Escape" , "HotkeyESCDesc" ) ,
290+ new ( "F5" , "ReloadPluginHotkey" ) ,
291+ new ( "Alt+Home" , "HotkeySelectFirstResult" ) ,
292+ new ( "Alt+End" , "HotkeySelectLastResult" ) ,
293+ new ( "Ctrl+R" , "HotkeyRequery" ) ,
294+ new ( "Ctrl+H" , "ToggleHistoryHotkey" ) ,
295+ new ( "Ctrl+OemCloseBrackets" , "QuickWidthHotkey" ) ,
296+ new ( "Ctrl+OemOpenBrackets" , "QuickWidthHotkey" ) ,
297+ new ( "Ctrl+OemPlus" , "QuickHeightHotkey" ) ,
298+ new ( "Ctrl+OemMinus" , "QuickHeightHotkey" ) ,
299+ new ( "Ctrl+Shift+Enter" , "HotkeyCtrlShiftEnterDesc" ) ,
300+ new ( "Shift+Enter" , "OpenContextMenuHotkey" ) ,
301+ new ( "Enter" , "HotkeyRunDesc" ) ,
302+ new ( "Ctrl+Enter" , "OpenContainFolderHotkey" ) ,
303+ new ( "Alt+Enter" , "HotkeyOpenResult" ) ,
304+ new ( "Ctrl+F12" , "ToggleGameModeHotkey" ) ,
305+ new ( "Ctrl+Shift+C" , "CopyFilePathHotkey" ) ,
306+
307+ new ( $ "{ OpenResultModifiers } +D1", "HotkeyOpenResultN" , 1 ) ,
308+ new ( $ "{ OpenResultModifiers } +D2", "HotkeyOpenResultN" , 2 ) ,
309+ new ( $ "{ OpenResultModifiers } +D3", "HotkeyOpenResultN" , 3 ) ,
310+ new ( $ "{ OpenResultModifiers } +D4", "HotkeyOpenResultN" , 4 ) ,
311+ new ( $ "{ OpenResultModifiers } +D5", "HotkeyOpenResultN" , 5 ) ,
312+ new ( $ "{ OpenResultModifiers } +D6", "HotkeyOpenResultN" , 6 ) ,
313+ new ( $ "{ OpenResultModifiers } +D7", "HotkeyOpenResultN" , 7 ) ,
314+ new ( $ "{ OpenResultModifiers } +D8", "HotkeyOpenResultN" , 8 ) ,
315+ new ( $ "{ OpenResultModifiers } +D9", "HotkeyOpenResultN" , 9 ) ,
316+ new ( $ "{ OpenResultModifiers } +D0", "HotkeyOpenResultN" , 10 )
317+ } ;
318+
319+ if ( ! string . IsNullOrEmpty ( Hotkey ) )
320+ list . Add ( new ( Hotkey , "flowlauncherHotkey" , ( ) => Hotkey = "" ) ) ;
321+ if ( ! string . IsNullOrEmpty ( PreviewHotkey ) )
322+ list . Add ( new ( PreviewHotkey , "previewHotkey" , ( ) => PreviewHotkey = "" ) ) ;
323+ if ( ! string . IsNullOrEmpty ( AutoCompleteHotkey ) )
324+ list . Add ( new ( AutoCompleteHotkey , "autoCompleteHotkey" , ( ) => AutoCompleteHotkey = "" ) ) ;
325+ if ( ! string . IsNullOrEmpty ( AutoCompleteHotkey2 ) )
326+ list . Add ( new ( AutoCompleteHotkey2 , "autoCompleteHotkey" , ( ) => AutoCompleteHotkey2 = "" ) ) ;
327+ if ( ! string . IsNullOrEmpty ( SelectNextItemHotkey ) )
328+ list . Add ( new ( SelectNextItemHotkey , "SelectNextItemHotkey" , ( ) => SelectNextItemHotkey = "" ) ) ;
329+ if ( ! string . IsNullOrEmpty ( SelectNextItemHotkey2 ) )
330+ list . Add ( new ( SelectNextItemHotkey2 , "SelectNextItemHotkey" , ( ) => SelectNextItemHotkey2 = "" ) ) ;
331+ if ( ! string . IsNullOrEmpty ( SelectPrevItemHotkey ) )
332+ list . Add ( new ( SelectPrevItemHotkey , "SelectPrevItemHotkey" , ( ) => SelectPrevItemHotkey = "" ) ) ;
333+ if ( ! string . IsNullOrEmpty ( SelectPrevItemHotkey2 ) )
334+ list . Add ( new ( SelectPrevItemHotkey2 , "SelectPrevItemHotkey" , ( ) => SelectPrevItemHotkey2 = "" ) ) ;
335+ if ( ! string . IsNullOrEmpty ( SettingWindowHotkey ) )
336+ list . Add ( new ( SettingWindowHotkey , "SettingWindowHotkey" , ( ) => SettingWindowHotkey = "" ) ) ;
337+ if ( ! string . IsNullOrEmpty ( OpenContextMenuHotkey ) )
338+ list . Add ( new ( OpenContextMenuHotkey , "OpenContextMenuHotkey" , ( ) => OpenContextMenuHotkey = "" ) ) ;
339+ if ( ! string . IsNullOrEmpty ( SelectNextPageHotkey ) )
340+ list . Add ( new ( SelectNextPageHotkey , "SelectNextPageHotkey" , ( ) => SelectNextPageHotkey = "" ) ) ;
341+ if ( ! string . IsNullOrEmpty ( SelectPrevPageHotkey ) )
342+ list . Add ( new ( SelectPrevPageHotkey , "SelectPrevPageHotkey" , ( ) => SelectPrevPageHotkey = "" ) ) ;
343+
344+ foreach ( var customPluginHotkey in CustomPluginHotkeys )
345+ {
346+ if ( ! string . IsNullOrEmpty ( customPluginHotkey . Hotkey ) )
347+ list . Add ( new ( customPluginHotkey . Hotkey , "customQueryHotkey" , ( ) => customPluginHotkey . Hotkey = "" ) ) ;
348+ }
349+
350+ return list ;
351+ }
352+ }
276353 }
277354
278355 public enum LastQueryMode
@@ -288,7 +365,7 @@ public enum ColorSchemes
288365 Light ,
289366 Dark
290367 }
291-
368+
292369 public enum SearchWindowScreens
293370 {
294371 RememberLastLaunchLocation ,
@@ -297,7 +374,7 @@ public enum SearchWindowScreens
297374 Primary ,
298375 Custom
299376 }
300-
377+
301378 public enum SearchWindowAligns
302379 {
303380 Center ,
0 commit comments