Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
04aea73
- Fix ProgressBar (Finally!)
onesounds Oct 7, 2021
3bc09ef
Merge branch 'ModernTheme' of https://github.com/onesounds/Flow.Launc…
onesounds Oct 8, 2021
a4d929b
Merge branch 'ModernTheme' of https://github.com/onesounds/Flow.Launc…
onesounds Oct 8, 2021
5d67019
Add delay
onesounds Oct 12, 2021
abf91dc
add Opacity value
onesounds Oct 12, 2021
7369625
add Opacity value
onesounds Oct 12, 2021
6d20db4
Merge branch 'FixEmptyQuery' of https://github.com/onesounds/Flow.Lau…
onesounds Oct 13, 2021
4a37900
On Load Animation (WIP)
onesounds Oct 13, 2021
ad186a3
On Load Animation (WIP)
onesounds Oct 13, 2021
5102846
Merge branch 'FixEmptyQuery' of https://github.com/onesounds/Flow.Lau…
onesounds Oct 13, 2021
60064ea
Merge branch 'FixEmptyQuery' of https://github.com/onesounds/Flow.Lau…
onesounds Oct 13, 2021
c3353b3
Merge branch 'FixEmptyQuery' of https://github.com/onesounds/Flow.Lau…
onesounds Oct 13, 2021
b96cac4
Merge branch 'FixEmptyQuery' of https://github.com/onesounds/Flow.Lau…
onesounds Oct 13, 2021
c6e2dc8
Merge branch 'FixEmptyQuery' of https://github.com/onesounds/Flow.Lau…
onesounds Oct 13, 2021
8326ba9
- change visibility call structure (like powertoy)
onesounds Oct 14, 2021
f77d450
- change visibility call structure (like powertoy)
onesounds Oct 14, 2021
2cc3a79
Merge
onesounds Oct 14, 2021
c0a94e5
Merge
onesounds Oct 14, 2021
5aa86f3
merge
onesounds Oct 14, 2021
a7ed678
- Remove duplicate method.
onesounds Oct 14, 2021
e225c2b
- Remove duplicate method.
onesounds Oct 14, 2021
364845a
Merge branch 'FixEmptyQuery' of https://github.com/onesounds/Flow.Lau…
onesounds Oct 14, 2021
9a53015
Refactor Code (Move all operation for mainviewmodel to ToggleFlowLaun…
taooceros Oct 20, 2021
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
49 changes: 9 additions & 40 deletions Flow.Launcher/Helper/HotKeyMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Flow.Launcher.Core.Resource;
using System.Windows;
using Flow.Launcher.ViewModel;
using System.Threading.Tasks;
using System.Threading;

namespace Flow.Launcher.Helper
{
Expand All @@ -19,10 +21,15 @@ internal static void Initialize(MainViewModel mainVM)
mainViewModel = mainVM;
settings = mainViewModel._settings;

SetHotkey(settings.Hotkey, OnHotkey);
SetHotkey(settings.Hotkey, OnToggleHotkey);
LoadCustomPluginHotkey();
}

internal static void OnToggleHotkey(object sender, HotkeyEventArgs args)
{
mainViewModel.ToggleFlowLauncher();
}

private static void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
{
var hotkey = new HotkeyModel(hotkeyStr);
Expand Down Expand Up @@ -53,44 +60,6 @@ internal static void RemoveHotkey(string hotkeyStr)
}
}

internal static void OnHotkey(object sender, HotkeyEventArgs e)
{
if (!ShouldIgnoreHotkeys())
{
UpdateLastQUeryMode();

mainViewModel.ToggleFlowLauncher();
e.Handled = true;
}
}

/// <summary>
/// Checks if Flow Launcher should ignore any hotkeys
/// </summary>
private static bool ShouldIgnoreHotkeys()
{
return settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
}

private static void UpdateLastQUeryMode()
{
switch(settings.LastQueryMode)
{
case LastQueryMode.Empty:
mainViewModel.ChangeQueryText(string.Empty);
break;
case LastQueryMode.Preserved:
mainViewModel.LastQuerySelected = true;
break;
case LastQueryMode.Selected:
mainViewModel.LastQuerySelected = false;
break;
default:
throw new ArgumentException($"wrong LastQueryMode: <{settings.LastQueryMode}>");

}
}

internal static void LoadCustomPluginHotkey()
{
if (settings.CustomPluginHotkeys == null)
Expand All @@ -106,7 +75,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
{
SetHotkey(hotkey.Hotkey, (s, e) =>
{
if (ShouldIgnoreHotkeys())
if (mainViewModel.ShouldIgnoreHotkeys())
return;

mainViewModel.MainWindowVisibility = Visibility.Visible;
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private void OnDeactivated(object sender, EventArgs e)
{
if (_settings.HideWhenDeactive)
{
Hide();
_viewModel.Hide();
}
}

Expand Down
3 changes: 2 additions & 1 deletion Flow.Launcher/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class SettingWindow
public readonly IPublicAPI API;
private Settings settings;
private SettingWindowViewModel viewModel;
private static MainViewModel mainViewModel;

public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
{
Expand Down Expand Up @@ -126,7 +127,7 @@ void OnHotkeyChanged(object sender, EventArgs e)
if (HotkeyControl.CurrentHotkeyAvailable)
{

HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnHotkey);
HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnToggleHotkey);
HotKeyMapper.RemoveHotkey(settings.Hotkey);
settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
}
Expand Down
81 changes: 75 additions & 6 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using System.Threading.Channels;
using ISavable = Flow.Launcher.Plugin.ISavable;
using System.Windows.Threading;
using NHotkey;


namespace Flow.Launcher.ViewModel
{
Expand Down Expand Up @@ -108,7 +110,9 @@ async Task updateAction()
}

Log.Error("MainViewModel", "Unexpected ResultViewUpdate ends");
};
}

;

void continueAction(Task t)
{
Expand Down Expand Up @@ -145,6 +149,24 @@ private void RegisterResultsUpdatedEvent()
}
}

private void UpdateLastQUeryMode()
{
switch (_settings.LastQueryMode)
{
case LastQueryMode.Empty:
ChangeQueryText(string.Empty);
break;
case LastQueryMode.Preserved:
LastQuerySelected = true;
break;
case LastQueryMode.Selected:
LastQuerySelected = false;
break;
default:
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");

}
}

private void InitializeKeyCommands()
{
Expand All @@ -156,7 +178,18 @@ private void InitializeKeyCommands()
}
else
{
MainWindowVisibility = Visibility.Collapsed;
Hide();
}
});

ClearQueryCommand = new RelayCommand(_ =>
{
if (!string.IsNullOrEmpty(QueryText))
{
ChangeQueryText(string.Empty);

// Push Event to UI SystemQuery has changed
//OnPropertyChanged(nameof(SystemQueryText));
}
});

Expand Down Expand Up @@ -194,7 +227,7 @@ private void InitializeKeyCommands()

if (hideWindow)
{
MainWindowVisibility = Visibility.Collapsed;
Hide();
}

if (SelectedIsFromQueryResults())
Expand Down Expand Up @@ -244,7 +277,7 @@ private void InitializeKeyCommands()
Owner = Application.Current.MainWindow
};

MainWindowVisibility = Visibility.Collapsed;
Hide();

PluginManager
.ReloadData()
Expand Down Expand Up @@ -335,7 +368,6 @@ private ResultsViewModel SelectedResults
}

public Visibility ProgressBarVisibility { get; set; }

public Visibility MainWindowVisibility { get; set; }

public ICommand EscCommand { get; set; }
Expand All @@ -349,6 +381,7 @@ private ResultsViewModel SelectedResults
public ICommand LoadHistoryCommand { get; set; }
public ICommand OpenResultCommand { get; set; }
public ICommand ReloadPluginDataCommand { get; set; }
public ICommand ClearQueryCommand { get; private set; }

public string OpenResultCommandModifiers { get; private set; }

Expand Down Expand Up @@ -660,20 +693,56 @@ private void SetOpenResultModifiers()
OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
}

internal void ToggleFlowLauncher()
public async void ToggleFlowLauncher()
{
if (MainWindowVisibility != Visibility.Visible)
{
MainWindowVisibility = Visibility.Visible;
}
else
{
switch (_settings.LastQueryMode)
{
case LastQueryMode.Empty:
ChangeQueryText(string.Empty);
Application.Current.MainWindow.Opacity = 0; // Trick for no delay
await Task.Delay(100);
Application.Current.MainWindow.Opacity = 1;
break;
case LastQueryMode.Preserved:
LastQuerySelected = true;
break;
case LastQueryMode.Selected:
LastQuerySelected = false;
break;
default:
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
}
MainWindowVisibility = Visibility.Collapsed;
}
}

public void Hide()
{
if (MainWindowVisibility != Visibility.Collapsed)
{
ToggleFlowLauncher();
}
}

#endregion


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



#region Public Methods

public void Save()
Expand Down