4
4
using System . Threading ;
5
5
using System . Threading . Tasks ;
6
6
using System . Windows ;
7
- using System . Windows . Input ;
8
7
using Flow . Launcher . Core . Plugin ;
9
8
using Flow . Launcher . Core . Resource ;
10
9
using Flow . Launcher . Helper ;
24
23
using System . Collections . Specialized ;
25
24
using CommunityToolkit . Mvvm . Input ;
26
25
using System . Globalization ;
27
- using System . Windows . Threading ;
28
26
29
27
namespace Flow . Launcher . ViewModel
30
28
{
31
29
public partial class MainViewModel : BaseModel , ISavable
32
30
{
33
31
#region Private Fields
34
32
35
- private const string DefaultOpenResultModifiers = "Alt" ;
36
-
37
33
private bool _isQueryRunning ;
38
34
private Query _lastQuery ;
39
35
private string _queryTextBeforeLeaveResults ;
@@ -74,6 +70,9 @@ public MainViewModel(Settings settings)
74
70
case nameof ( Settings . AlwaysStartEn ) :
75
71
OnPropertyChanged ( nameof ( StartWithEnglishMode ) ) ;
76
72
break ;
73
+ case nameof ( Settings . OpenResultModifiers ) :
74
+ OnPropertyChanged ( nameof ( OpenResultCommandModifiers ) ) ;
75
+ break ;
77
76
}
78
77
} ;
79
78
@@ -102,9 +101,7 @@ public MainViewModel(Settings settings)
102
101
103
102
RegisterViewUpdate ( ) ;
104
103
RegisterResultsUpdatedEvent ( ) ;
105
- RegisterClockAndDateUpdateAsync ( ) ;
106
-
107
- SetOpenResultModifiers ( ) ;
104
+ _ = RegisterClockAndDateUpdateAsync ( ) ;
108
105
}
109
106
110
107
private void RegisterViewUpdate ( )
@@ -136,8 +133,6 @@ async Task updateAction()
136
133
Log . Error ( "MainViewModel" , "Unexpected ResultViewUpdate ends" ) ;
137
134
}
138
135
139
- ;
140
-
141
136
void continueAction ( Task t )
142
137
{
143
138
#if DEBUG
@@ -181,6 +176,7 @@ private async Task ReloadPluginDataAsync()
181
176
await PluginManager . ReloadDataAsync ( ) . ConfigureAwait ( false ) ;
182
177
Notification . Show ( InternationalizationManager . Instance . GetTranslation ( "success" ) , InternationalizationManager . Instance . GetTranslation ( "completedSuccessfully" ) ) ;
183
178
}
179
+
184
180
[ RelayCommand ]
185
181
private void LoadHistory ( )
186
182
{
@@ -194,6 +190,7 @@ private void LoadHistory()
194
190
SelectedResults = Results ;
195
191
}
196
192
}
193
+
197
194
[ RelayCommand ]
198
195
private void LoadContextMenu ( )
199
196
{
@@ -209,6 +206,7 @@ private void LoadContextMenu()
209
206
SelectedResults = Results ;
210
207
}
211
208
}
209
+
212
210
[ RelayCommand ]
213
211
private void Backspace ( object index )
214
212
{
@@ -221,6 +219,7 @@ private void Backspace(object index)
221
219
222
220
ChangeQueryText ( $ "{ actionKeyword } { path } ") ;
223
221
}
222
+
224
223
[ RelayCommand ]
225
224
private void AutocompleteQuery ( )
226
225
{
@@ -247,6 +246,7 @@ private void AutocompleteQuery()
247
246
ChangeQueryText ( autoCompleteText ) ;
248
247
}
249
248
}
249
+
250
250
[ RelayCommand ]
251
251
private async Task OpenResultAsync ( string index )
252
252
{
@@ -281,6 +281,7 @@ private async Task OpenResultAsync(string index)
281
281
SelectedResults = Results ;
282
282
}
283
283
}
284
+
284
285
[ RelayCommand ]
285
286
private void OpenSetting ( )
286
287
{
@@ -298,6 +299,7 @@ private void SelectFirstResult()
298
299
{
299
300
SelectedResults . SelectFirstResult ( ) ;
300
301
}
302
+
301
303
[ RelayCommand ]
302
304
private void SelectPrevPage ( )
303
305
{
@@ -309,11 +311,13 @@ private void SelectNextPage()
309
311
{
310
312
SelectedResults . SelectNextPage ( ) ;
311
313
}
314
+
312
315
[ RelayCommand ]
313
316
private void SelectPrevItem ( )
314
317
{
315
318
SelectedResults . SelectPrevResult ( ) ;
316
319
}
320
+
317
321
[ RelayCommand ]
318
322
private void SelectNextItem ( )
319
323
{
@@ -333,6 +337,12 @@ private void Esc()
333
337
}
334
338
}
335
339
340
+ [ RelayCommand ]
341
+ public void ToggleGameMode ( )
342
+ {
343
+ GameModeStatus = ! GameModeStatus ;
344
+ }
345
+
336
346
#endregion
337
347
338
348
#region ViewModel Properties
@@ -361,7 +371,7 @@ private async Task RegisterClockAndDateUpdateAsync()
361
371
362
372
public ResultsViewModel History { get ; private set ; }
363
373
364
- public bool GameModeStatus { get ; set ; }
374
+ public bool GameModeStatus { get ; set ; } = false ;
365
375
366
376
private string _queryText ;
367
377
public string QueryText
@@ -375,7 +385,6 @@ public string QueryText
375
385
}
376
386
}
377
387
378
-
379
388
[ RelayCommand ]
380
389
private void IncreaseWidth ( )
381
390
{
@@ -513,14 +522,16 @@ public double MainWindowWidth
513
522
514
523
public string PluginIconPath { get ; set ; } = null ;
515
524
516
- public string OpenResultCommandModifiers { get ; private set ; }
525
+ public string OpenResultCommandModifiers => Settings . OpenResultModifiers ;
517
526
518
527
public string Image => Constant . QueryTextBoxIconImagePath ;
519
528
520
529
public bool StartWithEnglishMode => Settings . AlwaysStartEn ;
521
530
522
531
#endregion
523
532
533
+ #region Query
534
+
524
535
public void Query ( )
525
536
{
526
537
if ( SelectedIsFromQueryResults ( ) )
@@ -874,12 +885,9 @@ private bool HistorySelected()
874
885
return selected ;
875
886
}
876
887
877
- #region Hotkey
888
+ #endregion
878
889
879
- private void SetOpenResultModifiers ( )
880
- {
881
- OpenResultCommandModifiers = Settings . OpenResultModifiers ?? DefaultOpenResultModifiers ;
882
- }
890
+ #region Hotkey
883
891
884
892
public void ToggleFlowLauncher ( )
885
893
{
@@ -934,18 +942,15 @@ public async void Hide()
934
942
MainWindowVisibility = Visibility . Collapsed ;
935
943
}
936
944
937
- #endregion
938
-
939
-
940
945
/// <summary>
941
946
/// Checks if Flow Launcher should ignore any hotkeys
942
947
/// </summary>
943
948
public bool ShouldIgnoreHotkeys ( )
944
949
{
945
- return Settings . IgnoreHotkeysOnFullscreen && WindowsInteropHelper . IsWindowFullscreen ( ) ;
950
+ return Settings . IgnoreHotkeysOnFullscreen && WindowsInteropHelper . IsWindowFullscreen ( ) || GameModeStatus ;
946
951
}
947
952
948
-
953
+ #endregion
949
954
950
955
#region Public Methods
951
956
0 commit comments