diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs
index b9ac6afb3cd..27c044c66bd 100644
--- a/Flow.Launcher/Helper/HotKeyMapper.cs
+++ b/Flow.Launcher/Helper/HotKeyMapper.cs
@@ -1,4 +1,4 @@
-using Flow.Launcher.Infrastructure.Hotkey;
+using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using System;
using NHotkey;
@@ -25,7 +25,7 @@ internal static void Initialize(MainViewModel mainVM)
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
{
- if (!mainViewModel.ShouldIgnoreHotkeys() && !mainViewModel.GameModeStatus)
+ if (!mainViewModel.ShouldIgnoreHotkeys())
mainViewModel.ToggleFlowLauncher();
}
@@ -74,7 +74,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
{
SetHotkey(hotkey.Hotkey, (s, e) =>
{
- if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.GameModeStatus)
+ if (mainViewModel.ShouldIgnoreHotkeys())
return;
mainViewModel.Show();
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 095382e76fc..5ed9ba8026f 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -86,14 +86,10 @@
Key="O"
Command="{Binding LoadContextMenuCommand}"
Modifiers="Ctrl" />
-
-
-
-
+
diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs
index a645a702ce7..544958284b9 100644
--- a/Flow.Launcher/MainWindow.xaml.cs
+++ b/Flow.Launcher/MainWindow.xaml.cs
@@ -70,6 +70,7 @@ private void OnCopy(object sender, ExecutedRoutedEventArgs e)
_viewModel.ResultCopy(QueryTextBox.SelectedText);
}
}
+
private async void OnClosing(object sender, CancelEventArgs e)
{
_settings.WindowTop = Top;
@@ -100,6 +101,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
// since the default main window visibility is visible
// so we need set focus during startup
QueryTextBox.Focus();
+
_viewModel.PropertyChanged += (o, e) =>
{
switch (e.PropertyName)
@@ -168,9 +170,12 @@ private void OnLoaded(object sender, RoutedEventArgs _)
_viewModel.QueryTextCursorMovedToEnd = false;
}
break;
-
+ case nameof(MainViewModel.GameModeStatus):
+ _notifyIcon.Icon = _viewModel.GameModeStatus ? Properties.Resources.gamemode : Properties.Resources.app;
+ break;
}
};
+
_settings.PropertyChanged += (o, e) =>
{
switch (e.PropertyName)
@@ -285,7 +290,7 @@ private void InitializeNotifyIcon()
};
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
- gamemode.Click += (o, e) => ToggleGameMode();
+ gamemode.Click += (o, e) => _viewModel.ToggleGameMode();
positionreset.Click += (o, e) => PositionReset();
settings.Click += (o, e) => App.API.OpenSettingDialog();
exit.Click += (o, e) => Close();
@@ -324,24 +329,13 @@ private void CheckFirstLaunch()
OpenWelcomeWindow();
}
}
+
private void OpenWelcomeWindow()
{
var WelcomeWindow = new WelcomeWindow(_settings);
WelcomeWindow.Show();
}
- private void ToggleGameMode()
- {
- if (_viewModel.GameModeStatus)
- {
- _notifyIcon.Icon = Properties.Resources.app;
- _viewModel.GameModeStatus = false;
- }
- else
- {
- _notifyIcon.Icon = Properties.Resources.gamemode;
- _viewModel.GameModeStatus = true;
- }
- }
+
private async void PositionReset()
{
_viewModel.Show();
@@ -349,6 +343,7 @@ private async void PositionReset()
Left = HorizonCenter();
Top = VerticalCenter();
}
+
private void InitProgressbarAnimation()
{
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
@@ -361,6 +356,7 @@ private void InitProgressbarAnimation()
_viewModel.ProgressBarVisibility = Visibility.Hidden;
isProgressBarStoryboardPaused = true;
}
+
public void WindowAnimator()
{
if (_animating)
@@ -475,7 +471,6 @@ private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs
App.API.OpenSettingDialog();
}
-
private async void OnDeactivated(object sender, EventArgs e)
{
_settings.WindowLeft = Left;
@@ -596,12 +591,6 @@ private void OnKeyDown(object sender, KeyEventArgs e)
e.Handled = true;
}
break;
- case Key.F12:
- if (specialKeyState.CtrlPressed)
- {
- ToggleGameMode();
- }
- break;
case Key.Back:
if (specialKeyState.CtrlPressed)
{
@@ -644,6 +633,7 @@ public void PreviewReset()
Preview.Visibility = Visibility.Collapsed;
}
}
+
public void PreviewToggle()
{
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 09bba6e5c5e..c474e2a156f 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -4,7 +4,6 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Input;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Helper;
@@ -24,7 +23,6 @@
using System.Collections.Specialized;
using CommunityToolkit.Mvvm.Input;
using System.Globalization;
-using System.Windows.Threading;
namespace Flow.Launcher.ViewModel
{
@@ -32,8 +30,6 @@ public partial class MainViewModel : BaseModel, ISavable
{
#region Private Fields
- private const string DefaultOpenResultModifiers = "Alt";
-
private bool _isQueryRunning;
private Query _lastQuery;
private string _queryTextBeforeLeaveResults;
@@ -74,6 +70,9 @@ public MainViewModel(Settings settings)
case nameof(Settings.AlwaysStartEn):
OnPropertyChanged(nameof(StartWithEnglishMode));
break;
+ case nameof(Settings.OpenResultModifiers):
+ OnPropertyChanged(nameof(OpenResultCommandModifiers));
+ break;
}
};
@@ -102,9 +101,7 @@ public MainViewModel(Settings settings)
RegisterViewUpdate();
RegisterResultsUpdatedEvent();
- RegisterClockAndDateUpdateAsync();
-
- SetOpenResultModifiers();
+ _ = RegisterClockAndDateUpdateAsync();
}
private void RegisterViewUpdate()
@@ -136,8 +133,6 @@ async Task updateAction()
Log.Error("MainViewModel", "Unexpected ResultViewUpdate ends");
}
- ;
-
void continueAction(Task t)
{
#if DEBUG
@@ -181,6 +176,7 @@ private async Task ReloadPluginDataAsync()
await PluginManager.ReloadDataAsync().ConfigureAwait(false);
Notification.Show(InternationalizationManager.Instance.GetTranslation("success"), InternationalizationManager.Instance.GetTranslation("completedSuccessfully"));
}
+
[RelayCommand]
private void LoadHistory()
{
@@ -194,6 +190,7 @@ private void LoadHistory()
SelectedResults = Results;
}
}
+
[RelayCommand]
private void LoadContextMenu()
{
@@ -209,6 +206,7 @@ private void LoadContextMenu()
SelectedResults = Results;
}
}
+
[RelayCommand]
private void Backspace(object index)
{
@@ -221,6 +219,7 @@ private void Backspace(object index)
ChangeQueryText($"{actionKeyword}{path}");
}
+
[RelayCommand]
private void AutocompleteQuery()
{
@@ -247,6 +246,7 @@ private void AutocompleteQuery()
ChangeQueryText(autoCompleteText);
}
}
+
[RelayCommand]
private async Task OpenResultAsync(string index)
{
@@ -281,6 +281,7 @@ private async Task OpenResultAsync(string index)
SelectedResults = Results;
}
}
+
[RelayCommand]
private void OpenSetting()
{
@@ -298,6 +299,7 @@ private void SelectFirstResult()
{
SelectedResults.SelectFirstResult();
}
+
[RelayCommand]
private void SelectPrevPage()
{
@@ -309,11 +311,13 @@ private void SelectNextPage()
{
SelectedResults.SelectNextPage();
}
+
[RelayCommand]
private void SelectPrevItem()
{
SelectedResults.SelectPrevResult();
}
+
[RelayCommand]
private void SelectNextItem()
{
@@ -333,6 +337,12 @@ private void Esc()
}
}
+ [RelayCommand]
+ public void ToggleGameMode()
+ {
+ GameModeStatus = !GameModeStatus;
+ }
+
#endregion
#region ViewModel Properties
@@ -361,7 +371,7 @@ private async Task RegisterClockAndDateUpdateAsync()
public ResultsViewModel History { get; private set; }
- public bool GameModeStatus { get; set; }
+ public bool GameModeStatus { get; set; } = false;
private string _queryText;
public string QueryText
@@ -375,7 +385,6 @@ public string QueryText
}
}
-
[RelayCommand]
private void IncreaseWidth()
{
@@ -513,7 +522,7 @@ public double MainWindowWidth
public string PluginIconPath { get; set; } = null;
- public string OpenResultCommandModifiers { get; private set; }
+ public string OpenResultCommandModifiers => Settings.OpenResultModifiers;
public string Image => Constant.QueryTextBoxIconImagePath;
@@ -521,6 +530,8 @@ public double MainWindowWidth
#endregion
+ #region Query
+
public void Query()
{
if (SelectedIsFromQueryResults())
@@ -874,12 +885,9 @@ private bool HistorySelected()
return selected;
}
- #region Hotkey
+ #endregion
- private void SetOpenResultModifiers()
- {
- OpenResultCommandModifiers = Settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
- }
+ #region Hotkey
public void ToggleFlowLauncher()
{
@@ -934,18 +942,15 @@ public async void Hide()
MainWindowVisibility = Visibility.Collapsed;
}
- #endregion
-
-
///
/// Checks if Flow Launcher should ignore any hotkeys
///
public bool ShouldIgnoreHotkeys()
{
- return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
+ return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen() || GameModeStatus;
}
-
+ #endregion
#region Public Methods