diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index d41e7419a..73b13be8c 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -28,22 +28,6 @@
PreviewKeyDown="OnKeyDown"
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
d:DataContext="{d:DesignInstance vm:MainViewModel}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs
index e84a3148e..057c3f07d 100644
--- a/Flow.Launcher/MainWindow.xaml.cs
+++ b/Flow.Launcher/MainWindow.xaml.cs
@@ -262,7 +262,7 @@ namespace Flow.Launcher
{
if (_settings.HideWhenDeactive)
{
- Hide();
+ _viewModel.Hide();
}
}
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 1a08bd155..19f0ae811 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -176,10 +176,18 @@ namespace Flow.Launcher.ViewModel
}
else
{
- UpdateLastQUeryMode();
- var overlayTask = Task.Delay(50).ContinueWith(_ => {
- MainWindowVisibility = Visibility.Collapsed;
- });
+ Hide();
+ }
+ });
+
+ ClearQueryCommand = new RelayCommand(_ =>
+ {
+ if (!string.IsNullOrEmpty(QueryText))
+ {
+ ChangeQueryText(string.Empty);
+
+ // Push Event to UI SystemQuery has changed
+ //OnPropertyChanged(nameof(SystemQueryText));
}
});
@@ -217,7 +225,8 @@ namespace Flow.Launcher.ViewModel
if (hideWindow)
{
- MainWindowVisibility = Visibility.Collapsed;
+ //MainWindowVisibility = Visibility.Collapsed;
+ Hide();
}
if (SelectedIsFromQueryResults())
@@ -267,7 +276,8 @@ namespace Flow.Launcher.ViewModel
Owner = Application.Current.MainWindow
};
- MainWindowVisibility = Visibility.Collapsed;
+ //MainWindowVisibility = Visibility.Collapsed;
+ Hide();
PluginManager
.ReloadData()
@@ -372,6 +382,7 @@ namespace Flow.Launcher.ViewModel
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; }
@@ -683,7 +694,7 @@ namespace Flow.Launcher.ViewModel
OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
}
- internal void ToggleFlowLauncher()
+ public void ToggleFlowLauncher()
{
if (MainWindowVisibility != Visibility.Visible)
{
@@ -691,12 +702,75 @@ namespace Flow.Launcher.ViewModel
}
else
{
- MainWindowVisibility = Visibility.Collapsed;
+ if (_settings.LastQueryMode == LastQueryMode.Empty)
+ {
+ Application.Current.MainWindow.Opacity = 0; // Trick for no delay
+ ClearQueryCommand.Execute(null);
+ Task.Run(() =>
+ {
+ Thread.Sleep(100);
+ Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
+ {
+ MainWindowVisibility = Visibility.Collapsed;
+ Application.Current.MainWindow.Opacity = 1;
+ }));
+ });
+ }
+ else
+ {
+
+ MainWindowVisibility = Visibility.Collapsed;
+ }
+ }
+ }
+
+ public void Hide()
+ {
+ if (MainWindowVisibility != Visibility.Collapsed)
+ {
+ ToggleFlowLauncher();
}
}
#endregion
+ public void OnHotkey()
+ {
+ if (!ShouldIgnoreHotkeys())
+ {
+
+ if (_settings.LastQueryMode == LastQueryMode.Empty)
+ {
+ ChangeQueryText(string.Empty);
+ }
+ else if (_settings.LastQueryMode == LastQueryMode.Preserved)
+ {
+ LastQuerySelected = true;
+ }
+ else if (_settings.LastQueryMode == LastQueryMode.Selected)
+ {
+ LastQuerySelected = false;
+ }
+ else
+ {
+ throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
+ }
+
+ ToggleFlowLauncher();
+ }
+ }
+
+
+ ///
+ /// Checks if Flow Launcher should ignore any hotkeys
+ ///
+ private bool ShouldIgnoreHotkeys()
+ {
+ return _settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
+ }
+
+
+
#region Public Methods
public void Save()