mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Refactor toggle game mode logic
This commit is contained in:
parent
33615d1d46
commit
47d109cbe1
4 changed files with 21 additions and 28 deletions
|
|
@ -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 @@ namespace Flow.Launcher.Helper
|
|||
|
||||
internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
|
||||
{
|
||||
if (!mainViewModel.ShouldIgnoreHotkeys() && !mainViewModel.GameModeStatus)
|
||||
if (!mainViewModel.ShouldIgnoreHotkeys())
|
||||
mainViewModel.ToggleFlowLauncher();
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ namespace Flow.Launcher.Helper
|
|||
{
|
||||
SetHotkey(hotkey.Hotkey, (s, e) =>
|
||||
{
|
||||
if (mainViewModel.ShouldIgnoreHotkeys() || mainViewModel.GameModeStatus)
|
||||
if (mainViewModel.ShouldIgnoreHotkeys())
|
||||
return;
|
||||
|
||||
mainViewModel.Show();
|
||||
|
|
|
|||
|
|
@ -177,6 +177,10 @@
|
|||
Command="{Binding OpenResultCommand}"
|
||||
CommandParameter="9"
|
||||
Modifiers="{Binding OpenResultCommandModifiers}" />
|
||||
<KeyBinding
|
||||
Key="F12"
|
||||
Command="{Binding ToggleGameModeCommand}"
|
||||
Modifiers="Ctrl"/>
|
||||
</Window.InputBindings>
|
||||
<Grid>
|
||||
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ namespace Flow.Launcher
|
|||
// since the default main window visibility is visible
|
||||
// so we need set focus during startup
|
||||
QueryTextBox.Focus();
|
||||
|
||||
_viewModel.PropertyChanged += (o, e) =>
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
|
|
@ -169,9 +170,12 @@ namespace Flow.Launcher
|
|||
_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)
|
||||
|
|
@ -286,7 +290,7 @@ namespace Flow.Launcher
|
|||
};
|
||||
|
||||
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();
|
||||
|
|
@ -332,20 +336,6 @@ namespace Flow.Launcher
|
|||
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();
|
||||
|
|
@ -601,12 +591,6 @@ namespace Flow.Launcher
|
|||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Key.F12:
|
||||
if (specialKeyState.CtrlPressed)
|
||||
{
|
||||
ToggleGameMode();
|
||||
}
|
||||
break;
|
||||
case Key.Back:
|
||||
if (specialKeyState.CtrlPressed)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -337,6 +337,12 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public void ToggleGameMode()
|
||||
{
|
||||
GameModeStatus = !GameModeStatus;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ViewModel Properties
|
||||
|
|
@ -365,7 +371,7 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
public ResultsViewModel History { get; private set; }
|
||||
|
||||
public bool GameModeStatus { get; set; }
|
||||
public bool GameModeStatus { get; set; } = false;
|
||||
|
||||
private string _queryText;
|
||||
public string QueryText
|
||||
|
|
@ -379,7 +385,6 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
private void IncreaseWidth()
|
||||
{
|
||||
|
|
@ -942,7 +947,7 @@ namespace Flow.Launcher.ViewModel
|
|||
/// </summary>
|
||||
public bool ShouldIgnoreHotkeys()
|
||||
{
|
||||
return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
|
||||
return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen() || GameModeStatus;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
Loading…
Reference in a new issue