Skip to content

Commit 24349d5

Browse files
Merge remote-tracking branch 'upstream/dev' into LazyLoadPreview
2 parents e625bf1 + 9027a20 commit 24349d5

File tree

7 files changed

+60
-74
lines changed

7 files changed

+60
-74
lines changed

Flow.Launcher/CustomShortcutSetting.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
<TextBlock
6565
Grid.Column="0"
6666
Margin="0,0,0,0"
67-
FontFamily="Segoe UI"
6867
FontSize="20"
6968
FontWeight="SemiBold"
7069
Text="{DynamicResource customQueryShortcut}"

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Infrastructure.Hotkey;
1+
using Flow.Launcher.Infrastructure.Hotkey;
22
using Flow.Launcher.Infrastructure.UserSettings;
33
using System;
44
using NHotkey;
@@ -25,7 +25,7 @@ internal static void Initialize(MainViewModel mainVM)
2525

2626
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
2727
{
28-
if (!mainViewModel.ShouldIgnoreHotkeys() && !mainViewModel.GameModeStatus)
28+
if (!mainViewModel.ShouldIgnoreHotkeys())
2929
mainViewModel.ToggleFlowLauncher();
3030
}
3131

@@ -74,7 +74,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
7474
{
7575
SetHotkey(hotkey.Hotkey, (s, e) =>
7676
{
77-
if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.GameModeStatus)
77+
if (mainViewModel.ShouldIgnoreHotkeys())
7878
return;
7979

8080
mainViewModel.Show();

Flow.Launcher/MainWindow.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,10 @@
8585
Key="O"
8686
Command="{Binding LoadContextMenuCommand}"
8787
Modifiers="Ctrl" />
88-
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
89-
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
9088
<KeyBinding
9189
Key="H"
9290
Command="{Binding LoadHistoryCommand}"
9391
Modifiers="Ctrl" />
94-
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
95-
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
9692
<KeyBinding
9793
Key="OemCloseBrackets"
9894
Command="{Binding IncreaseWidthCommand}"
@@ -180,6 +176,10 @@
180176
Command="{Binding OpenResultCommand}"
181177
CommandParameter="9"
182178
Modifiers="{Binding OpenResultCommandModifiers}" />
179+
<KeyBinding
180+
Key="F12"
181+
Command="{Binding ToggleGameModeCommand}"
182+
Modifiers="Ctrl"/>
183183
<KeyBinding
184184
Key="{Binding TogglePreviewHotkey}"
185185
Command="{Binding TogglePreviewCommand}"/>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private void OnCopy(object sender, ExecutedRoutedEventArgs e)
7070
_viewModel.ResultCopy(QueryTextBox.SelectedText);
7171
}
7272
}
73+
7374
private async void OnClosing(object sender, CancelEventArgs e)
7475
{
7576
_settings.WindowTop = Top;
@@ -100,6 +101,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
100101
// since the default main window visibility is visible
101102
// so we need set focus during startup
102103
QueryTextBox.Focus();
104+
103105
_viewModel.PropertyChanged += (o, e) =>
104106
{
105107
switch (e.PropertyName)
@@ -168,9 +170,12 @@ private void OnLoaded(object sender, RoutedEventArgs _)
168170
_viewModel.QueryTextCursorMovedToEnd = false;
169171
}
170172
break;
171-
173+
case nameof(MainViewModel.GameModeStatus):
174+
_notifyIcon.Icon = _viewModel.GameModeStatus ? Properties.Resources.gamemode : Properties.Resources.app;
175+
break;
172176
}
173177
};
178+
174179
_settings.PropertyChanged += (o, e) =>
175180
{
176181
switch (e.PropertyName)
@@ -285,7 +290,7 @@ private void InitializeNotifyIcon()
285290
};
286291

287292
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
288-
gamemode.Click += (o, e) => ToggleGameMode();
293+
gamemode.Click += (o, e) => _viewModel.ToggleGameMode();
289294
positionreset.Click += (o, e) => PositionReset();
290295
settings.Click += (o, e) => App.API.OpenSettingDialog();
291296
exit.Click += (o, e) => Close();
@@ -324,31 +329,21 @@ private void CheckFirstLaunch()
324329
OpenWelcomeWindow();
325330
}
326331
}
332+
327333
private void OpenWelcomeWindow()
328334
{
329335
var WelcomeWindow = new WelcomeWindow(_settings);
330336
WelcomeWindow.Show();
331337
}
332-
private void ToggleGameMode()
333-
{
334-
if (_viewModel.GameModeStatus)
335-
{
336-
_notifyIcon.Icon = Properties.Resources.app;
337-
_viewModel.GameModeStatus = false;
338-
}
339-
else
340-
{
341-
_notifyIcon.Icon = Properties.Resources.gamemode;
342-
_viewModel.GameModeStatus = true;
343-
}
344-
}
338+
345339
private async void PositionReset()
346340
{
347341
_viewModel.Show();
348342
await Task.Delay(300); // If don't give a time, Positioning will be weird.
349343
Left = HorizonCenter();
350344
Top = VerticalCenter();
351345
}
346+
352347
private void InitProgressbarAnimation()
353348
{
354349
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
@@ -361,6 +356,7 @@ private void InitProgressbarAnimation()
361356
_viewModel.ProgressBarVisibility = Visibility.Hidden;
362357
isProgressBarStoryboardPaused = true;
363358
}
359+
364360
public void WindowAnimator()
365361
{
366362
if (_animating)
@@ -475,7 +471,6 @@ private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs
475471
App.API.OpenSettingDialog();
476472
}
477473

478-
479474
private async void OnDeactivated(object sender, EventArgs e)
480475
{
481476
_settings.WindowLeft = Left;
@@ -596,12 +591,6 @@ private void OnKeyDown(object sender, KeyEventArgs e)
596591
e.Handled = true;
597592
}
598593
break;
599-
case Key.F12:
600-
if (specialKeyState.CtrlPressed)
601-
{
602-
ToggleGameMode();
603-
}
604-
break;
605594
case Key.Back:
606595
if (specialKeyState.CtrlPressed)
607596
{

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Threading;
55
using System.Threading.Tasks;
66
using System.Windows;
7-
using System.Windows.Input;
87
using Flow.Launcher.Core.Plugin;
98
using Flow.Launcher.Core.Resource;
109
using Flow.Launcher.Helper;
@@ -24,16 +23,13 @@
2423
using System.Collections.Specialized;
2524
using CommunityToolkit.Mvvm.Input;
2625
using System.Globalization;
27-
using System.Windows.Threading;
2826

2927
namespace Flow.Launcher.ViewModel
3028
{
3129
public partial class MainViewModel : BaseModel, ISavable
3230
{
3331
#region Private Fields
3432

35-
private const string DefaultOpenResultModifiers = "Alt";
36-
3733
private bool _isQueryRunning;
3834
private Query _lastQuery;
3935
private string _queryTextBeforeLeaveResults;
@@ -74,6 +70,9 @@ public MainViewModel(Settings settings)
7470
case nameof(Settings.AlwaysStartEn):
7571
OnPropertyChanged(nameof(StartWithEnglishMode));
7672
break;
73+
case nameof(Settings.OpenResultModifiers):
74+
OnPropertyChanged(nameof(OpenResultCommandModifiers));
75+
break;
7776
case nameof(Settings.PreviewHotkey):
7877
OnPropertyChanged(nameof(TogglePreviewHotkey));
7978
break;
@@ -114,9 +113,7 @@ public MainViewModel(Settings settings)
114113

115114
RegisterViewUpdate();
116115
RegisterResultsUpdatedEvent();
117-
RegisterClockAndDateUpdateAsync();
118-
119-
SetOpenResultModifiers(); // TODO?
116+
_ = RegisterClockAndDateUpdateAsync();
120117
}
121118

122119
private void RegisterViewUpdate()
@@ -148,8 +145,6 @@ async Task updateAction()
148145
Log.Error("MainViewModel", "Unexpected ResultViewUpdate ends");
149146
}
150147

151-
;
152-
153148
void continueAction(Task t)
154149
{
155150
#if DEBUG
@@ -193,6 +188,7 @@ private async Task ReloadPluginDataAsync()
193188
await PluginManager.ReloadDataAsync().ConfigureAwait(false);
194189
Notification.Show(InternationalizationManager.Instance.GetTranslation("success"), InternationalizationManager.Instance.GetTranslation("completedSuccessfully"));
195190
}
191+
196192
[RelayCommand]
197193
private void LoadHistory()
198194
{
@@ -206,6 +202,7 @@ private void LoadHistory()
206202
SelectedResults = Results;
207203
}
208204
}
205+
209206
[RelayCommand]
210207
private void LoadContextMenu()
211208
{
@@ -221,6 +218,7 @@ private void LoadContextMenu()
221218
SelectedResults = Results;
222219
}
223220
}
221+
224222
[RelayCommand]
225223
private void Backspace(object index)
226224
{
@@ -233,6 +231,7 @@ private void Backspace(object index)
233231

234232
ChangeQueryText($"{actionKeyword}{path}");
235233
}
234+
236235
[RelayCommand]
237236
private void AutocompleteQuery()
238237
{
@@ -259,6 +258,7 @@ private void AutocompleteQuery()
259258
ChangeQueryText(autoCompleteText);
260259
}
261260
}
261+
262262
[RelayCommand]
263263
private async Task OpenResultAsync(string index)
264264
{
@@ -293,6 +293,7 @@ private async Task OpenResultAsync(string index)
293293
SelectedResults = Results;
294294
}
295295
}
296+
296297
[RelayCommand]
297298
private void OpenSetting()
298299
{
@@ -310,6 +311,7 @@ private void SelectFirstResult()
310311
{
311312
SelectedResults.SelectFirstResult();
312313
}
314+
313315
[RelayCommand]
314316
private void SelectPrevPage()
315317
{
@@ -321,11 +323,13 @@ private void SelectNextPage()
321323
{
322324
SelectedResults.SelectNextPage();
323325
}
326+
324327
[RelayCommand]
325328
private void SelectPrevItem()
326329
{
327330
SelectedResults.SelectPrevResult();
328331
}
332+
329333
[RelayCommand]
330334
private void SelectNextItem()
331335
{
@@ -345,6 +349,12 @@ private void Esc()
345349
}
346350
}
347351

352+
[RelayCommand]
353+
public void ToggleGameMode()
354+
{
355+
GameModeStatus = !GameModeStatus;
356+
}
357+
348358
#endregion
349359

350360
#region ViewModel Properties
@@ -373,7 +383,7 @@ private async Task RegisterClockAndDateUpdateAsync()
373383

374384
public ResultsViewModel History { get; private set; }
375385

376-
public bool GameModeStatus { get; set; }
386+
public bool GameModeStatus { get; set; } = false;
377387

378388
private string _queryText;
379389
public string QueryText
@@ -387,7 +397,6 @@ public string QueryText
387397
}
388398
}
389399

390-
391400
[RelayCommand]
392401
private void IncreaseWidth()
393402
{
@@ -571,7 +580,7 @@ public double MainWindowWidth
571580

572581
public string PluginIconPath { get; set; } = null;
573582

574-
public string OpenResultCommandModifiers { get; private set; }
583+
public string OpenResultCommandModifiers => Settings.OpenResultModifiers;
575584

576585
public string TogglePreviewHotkey => Settings.PreviewHotkey; // TODO: is hotkey combo possible?
577586

@@ -585,6 +594,8 @@ public double MainWindowWidth
585594

586595
#endregion
587596

597+
#region Query
598+
588599
public void Query()
589600
{
590601
if (SelectedIsFromQueryResults())
@@ -938,12 +949,9 @@ private bool HistorySelected()
938949
return selected;
939950
}
940951

941-
#region Hotkey
952+
#endregion
942953

943-
private void SetOpenResultModifiers()
944-
{
945-
OpenResultCommandModifiers = Settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
946-
}
954+
#region Hotkey
947955

948956
public void ToggleFlowLauncher()
949957
{
@@ -998,18 +1006,15 @@ public async void Hide()
9981006
MainWindowVisibility = Visibility.Collapsed;
9991007
}
10001008

1001-
#endregion
1002-
1003-
10041009
/// <summary>
10051010
/// Checks if Flow Launcher should ignore any hotkeys
10061011
/// </summary>
10071012
public bool ShouldIgnoreHotkeys()
10081013
{
1009-
return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
1014+
return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen() || GameModeStatus;
10101015
}
10111016

1012-
1017+
#endregion
10131018

10141019
#region Public Methods
10151020

0 commit comments

Comments
 (0)