Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Flow.Launcher/Helper/HotKeyMapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.UserSettings;
using System;
using NHotkey;
Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,10 @@
Key="O"
Command="{Binding LoadContextMenuCommand}"
Modifiers="Ctrl" />
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
<KeyBinding
Key="H"
Command="{Binding LoadHistoryCommand}"
Modifiers="Ctrl" />
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
<KeyBinding
Key="OemCloseBrackets"
Command="{Binding IncreaseWidthCommand}"
Expand Down Expand Up @@ -181,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}">
Expand Down
34 changes: 12 additions & 22 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -324,31 +329,21 @@ 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();
await Task.Delay(300); // If don't give a time, Positioning will be weird.
Left = HorizonCenter();
Top = VerticalCenter();
}

private void InitProgressbarAnimation()
{
var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
Expand All @@ -361,6 +356,7 @@ private void InitProgressbarAnimation()
_viewModel.ProgressBarVisibility = Visibility.Hidden;
isProgressBarStoryboardPaused = true;
}

public void WindowAnimator()
{
if (_animating)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -644,6 +633,7 @@ public void PreviewReset()
Preview.Visibility = Visibility.Collapsed;
}
}

public void PreviewToggle()
{

Expand Down
49 changes: 27 additions & 22 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,16 +23,13 @@
using System.Collections.Specialized;
using CommunityToolkit.Mvvm.Input;
using System.Globalization;
using System.Windows.Threading;

namespace Flow.Launcher.ViewModel
{
public partial class MainViewModel : BaseModel, ISavable
{
#region Private Fields

private const string DefaultOpenResultModifiers = "Alt";

private bool _isQueryRunning;
private Query _lastQuery;
private string _queryTextBeforeLeaveResults;
Expand Down Expand Up @@ -74,6 +70,9 @@ public MainViewModel(Settings settings)
case nameof(Settings.AlwaysStartEn):
OnPropertyChanged(nameof(StartWithEnglishMode));
break;
case nameof(Settings.OpenResultModifiers):
OnPropertyChanged(nameof(OpenResultCommandModifiers));
break;
}
};

Expand Down Expand Up @@ -102,9 +101,7 @@ public MainViewModel(Settings settings)

RegisterViewUpdate();
RegisterResultsUpdatedEvent();
RegisterClockAndDateUpdateAsync();

SetOpenResultModifiers();
_ = RegisterClockAndDateUpdateAsync();
}

private void RegisterViewUpdate()
Expand Down Expand Up @@ -136,8 +133,6 @@ async Task updateAction()
Log.Error("MainViewModel", "Unexpected ResultViewUpdate ends");
}

;

void continueAction(Task t)
{
#if DEBUG
Expand Down Expand Up @@ -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()
{
Expand All @@ -194,6 +190,7 @@ private void LoadHistory()
SelectedResults = Results;
}
}

[RelayCommand]
private void LoadContextMenu()
{
Expand All @@ -209,6 +206,7 @@ private void LoadContextMenu()
SelectedResults = Results;
}
}

[RelayCommand]
private void Backspace(object index)
{
Expand All @@ -221,6 +219,7 @@ private void Backspace(object index)

ChangeQueryText($"{actionKeyword}{path}");
}

[RelayCommand]
private void AutocompleteQuery()
{
Expand All @@ -247,6 +246,7 @@ private void AutocompleteQuery()
ChangeQueryText(autoCompleteText);
}
}

[RelayCommand]
private async Task OpenResultAsync(string index)
{
Expand Down Expand Up @@ -281,6 +281,7 @@ private async Task OpenResultAsync(string index)
SelectedResults = Results;
}
}

[RelayCommand]
private void OpenSetting()
{
Expand All @@ -298,6 +299,7 @@ private void SelectFirstResult()
{
SelectedResults.SelectFirstResult();
}

[RelayCommand]
private void SelectPrevPage()
{
Expand All @@ -309,11 +311,13 @@ private void SelectNextPage()
{
SelectedResults.SelectNextPage();
}

[RelayCommand]
private void SelectPrevItem()
{
SelectedResults.SelectPrevResult();
}

[RelayCommand]
private void SelectNextItem()
{
Expand All @@ -333,6 +337,12 @@ private void Esc()
}
}

[RelayCommand]
public void ToggleGameMode()
{
GameModeStatus = !GameModeStatus;
}

#endregion

#region ViewModel Properties
Expand Down Expand Up @@ -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
Expand All @@ -375,7 +385,6 @@ public string QueryText
}
}


[RelayCommand]
private void IncreaseWidth()
{
Expand Down Expand Up @@ -513,14 +522,16 @@ 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;

public bool StartWithEnglishMode => Settings.AlwaysStartEn;

#endregion

#region Query

public void Query()
{
if (SelectedIsFromQueryResults())
Expand Down Expand Up @@ -874,12 +885,9 @@ private bool HistorySelected()
return selected;
}

#region Hotkey
#endregion

private void SetOpenResultModifiers()
{
OpenResultCommandModifiers = Settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
}
#region Hotkey

public void ToggleFlowLauncher()
{
Expand Down Expand Up @@ -934,18 +942,15 @@ public async void Hide()
MainWindowVisibility = Visibility.Collapsed;
}

#endregion


/// <summary>
/// Checks if Flow Launcher should ignore any hotkeys
/// </summary>
public bool ShouldIgnoreHotkeys()
{
return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
return Settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen() || GameModeStatus;
}


#endregion

#region Public Methods

Expand Down