@@ -176,10 +176,18 @@ private void InitializeKeyCommands()
176
176
}
177
177
else
178
178
{
179
- UpdateLastQUeryMode ( ) ;
180
- var overlayTask = Task . Delay ( 50 ) . ContinueWith ( _ => {
181
- MainWindowVisibility = Visibility . Collapsed ;
182
- } ) ;
179
+ Hide ( ) ;
180
+ }
181
+ } ) ;
182
+
183
+ ClearQueryCommand = new RelayCommand ( _ =>
184
+ {
185
+ if ( ! string . IsNullOrEmpty ( QueryText ) )
186
+ {
187
+ ChangeQueryText ( string . Empty ) ;
188
+
189
+ // Push Event to UI SystemQuery has changed
190
+ //OnPropertyChanged(nameof(SystemQueryText));
183
191
}
184
192
} ) ;
185
193
@@ -217,7 +225,8 @@ private void InitializeKeyCommands()
217
225
218
226
if ( hideWindow )
219
227
{
220
- MainWindowVisibility = Visibility . Collapsed ;
228
+ //MainWindowVisibility = Visibility.Collapsed;
229
+ Hide ( ) ;
221
230
}
222
231
223
232
if ( SelectedIsFromQueryResults ( ) )
@@ -267,7 +276,8 @@ private void InitializeKeyCommands()
267
276
Owner = Application . Current . MainWindow
268
277
} ;
269
278
270
- MainWindowVisibility = Visibility . Collapsed ;
279
+ //MainWindowVisibility = Visibility.Collapsed;
280
+ Hide ( ) ;
271
281
272
282
PluginManager
273
283
. ReloadData ( )
@@ -372,6 +382,7 @@ private ResultsViewModel SelectedResults
372
382
public ICommand LoadHistoryCommand { get ; set ; }
373
383
public ICommand OpenResultCommand { get ; set ; }
374
384
public ICommand ReloadPluginDataCommand { get ; set ; }
385
+ public ICommand ClearQueryCommand { get ; private set ; }
375
386
376
387
public string OpenResultCommandModifiers { get ; private set ; }
377
388
@@ -683,20 +694,84 @@ private void SetOpenResultModifiers()
683
694
OpenResultCommandModifiers = _settings . OpenResultModifiers ?? DefaultOpenResultModifiers ;
684
695
}
685
696
686
- internal void ToggleFlowLauncher ( )
697
+ public void ToggleFlowLauncher ( )
687
698
{
688
699
if ( MainWindowVisibility != Visibility . Visible )
689
700
{
690
701
MainWindowVisibility = Visibility . Visible ;
691
702
}
692
703
else
693
704
{
694
- MainWindowVisibility = Visibility . Collapsed ;
705
+ if ( _settings . LastQueryMode == LastQueryMode . Empty )
706
+ {
707
+ Application . Current . MainWindow . Opacity = 0 ; // Trick for no delay
708
+ ClearQueryCommand . Execute ( null ) ;
709
+ Task . Run ( ( ) =>
710
+ {
711
+ Thread . Sleep ( 100 ) ;
712
+ Application . Current . Dispatcher . BeginInvoke ( DispatcherPriority . Normal , new Action ( ( ) =>
713
+ {
714
+ MainWindowVisibility = Visibility . Collapsed ;
715
+ Application . Current . MainWindow . Opacity = 1 ;
716
+ } ) ) ;
717
+ } ) ;
718
+ }
719
+ else
720
+ {
721
+
722
+ MainWindowVisibility = Visibility . Collapsed ;
723
+ }
724
+ }
725
+ }
726
+
727
+ public void Hide ( )
728
+ {
729
+ if ( MainWindowVisibility != Visibility . Collapsed )
730
+ {
731
+ ToggleFlowLauncher ( ) ;
695
732
}
696
733
}
697
734
698
735
#endregion
699
736
737
+ private void OnHotkey ( )
738
+ {
739
+ if ( ! ShouldIgnoreHotkeys ( ) )
740
+ {
741
+ // If launcher window was hidden and the hotkey was pressed, start telemetry event
742
+
743
+ if ( _settings . LastQueryMode == LastQueryMode . Empty )
744
+ {
745
+ ChangeQueryText ( string . Empty ) ;
746
+ }
747
+ else if ( _settings . LastQueryMode == LastQueryMode . Preserved )
748
+ {
749
+ LastQuerySelected = true ;
750
+ }
751
+ else if ( _settings . LastQueryMode == LastQueryMode . Selected )
752
+ {
753
+ LastQuerySelected = false ;
754
+ }
755
+ else
756
+ {
757
+ throw new ArgumentException ( $ "wrong LastQueryMode: <{ _settings . LastQueryMode } >") ;
758
+ }
759
+
760
+ ToggleFlowLauncher ( ) ;
761
+ }
762
+ }
763
+
764
+
765
+ /// <summary>
766
+ /// Checks if Flow Launcher should ignore any hotkeys
767
+ /// </summary>
768
+ private bool ShouldIgnoreHotkeys ( )
769
+ {
770
+ return _settings . IgnoreHotkeysOnFullscreen && WindowsInteropHelper . IsWindowFullscreen ( ) ;
771
+ }
772
+
773
+
774
+
700
775
#region Public Methods
701
776
702
777
public void Save ( )
0 commit comments