@@ -52,8 +52,6 @@ public class MainViewModel : BaseModel, ISavable
52
52
private ChannelWriter < ResultsForUpdate > _resultsUpdateChannelWriter ;
53
53
private Task _resultsViewUpdateTask ;
54
54
55
-
56
-
57
55
#endregion
58
56
59
57
#region Constructor
@@ -112,7 +110,9 @@ async Task updateAction()
112
110
}
113
111
114
112
Log . Error ( "MainViewModel" , "Unexpected ResultViewUpdate ends" ) ;
115
- } ;
113
+ }
114
+
115
+ ;
116
116
117
117
void continueAction ( Task t )
118
118
{
@@ -693,33 +693,32 @@ private void SetOpenResultModifiers()
693
693
OpenResultCommandModifiers = _settings . OpenResultModifiers ?? DefaultOpenResultModifiers ;
694
694
}
695
695
696
- public void ToggleFlowLauncher ( )
696
+ public async void ToggleFlowLauncher ( )
697
697
{
698
698
if ( MainWindowVisibility != Visibility . Visible )
699
699
{
700
700
MainWindowVisibility = Visibility . Visible ;
701
701
}
702
702
else
703
703
{
704
- if ( _settings . LastQueryMode == LastQueryMode . Empty )
704
+ switch ( _settings . LastQueryMode )
705
705
{
706
- Application . Current . MainWindow . Opacity = 0 ; // Trick for no delay
707
- ClearQueryCommand . Execute ( null ) ;
708
- Task . Run ( ( ) =>
709
- {
710
- Thread . Sleep ( 100 ) ;
711
- Application . Current . Dispatcher . BeginInvoke ( DispatcherPriority . Normal , new Action ( ( ) =>
712
- {
713
- MainWindowVisibility = Visibility . Collapsed ;
714
- Application . Current . MainWindow . Opacity = 1 ;
715
- } ) ) ;
716
- } ) ;
717
- }
718
- else
719
- {
720
-
721
- MainWindowVisibility = Visibility . Collapsed ;
706
+ case LastQueryMode . Empty :
707
+ ChangeQueryText ( string . Empty ) ;
708
+ Application . Current . MainWindow . Opacity = 0 ; // Trick for no delay
709
+ await Task . Delay ( 100 ) ;
710
+ Application . Current . MainWindow . Opacity = 1 ;
711
+ break ;
712
+ case LastQueryMode . Preserved :
713
+ LastQuerySelected = true ;
714
+ break ;
715
+ case LastQueryMode . Selected :
716
+ LastQuerySelected = false ;
717
+ break ;
718
+ default :
719
+ throw new ArgumentException ( $ "wrong LastQueryMode: <{ _settings . LastQueryMode } >") ;
722
720
}
721
+ MainWindowVisibility = Visibility . Collapsed ;
723
722
}
724
723
}
725
724
@@ -731,40 +730,13 @@ public void Hide()
731
730
}
732
731
}
733
732
734
-
735
733
#endregion
736
734
737
- public void OnHotkey ( object sender , HotkeyEventArgs e )
738
- {
739
- if ( ! ShouldIgnoreHotkeys ( ) )
740
- {
741
-
742
- if ( _settings . LastQueryMode == LastQueryMode . Empty )
743
- {
744
- ChangeQueryText ( string . Empty ) ;
745
- }
746
- else if ( _settings . LastQueryMode == LastQueryMode . Preserved )
747
- {
748
- LastQuerySelected = true ;
749
- }
750
- else if ( _settings . LastQueryMode == LastQueryMode . Selected )
751
- {
752
- LastQuerySelected = false ;
753
- }
754
- else
755
- {
756
- throw new ArgumentException ( $ "wrong LastQueryMode: <{ _settings . LastQueryMode } >") ;
757
- }
758
-
759
- ToggleFlowLauncher ( ) ;
760
- }
761
- }
762
-
763
735
764
736
/// <summary>
765
737
/// Checks if Flow Launcher should ignore any hotkeys
766
738
/// </summary>
767
- public bool ShouldIgnoreHotkeys ( )
739
+ public bool ShouldIgnoreHotkeys ( )
768
740
{
769
741
return _settings . IgnoreHotkeysOnFullscreen && WindowsInteropHelper . IsWindowFullscreen ( ) ;
770
742
}
0 commit comments