Merge pull request #784 from onesounds/FixHIdeStartup

Force Exit & Fix HideonStartup (#783)
This commit is contained in:
Dobin Park 2021-11-08 09:47:13 +09:00 committed by GitHub
commit ad5f34f2dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 25 deletions

View file

@ -55,7 +55,7 @@ namespace Flow.Launcher
_viewModel.Save(); _viewModel.Save();
e.Cancel = true; e.Cancel = true;
await PluginManager.DisposePluginsAsync(); await PluginManager.DisposePluginsAsync();
Application.Current.Shutdown(); Environment.Exit(0);
} }
private void OnInitialized(object sender, EventArgs e) private void OnInitialized(object sender, EventArgs e)

View file

@ -273,7 +273,7 @@ namespace Flow.Launcher.ViewModel
ReloadPluginDataCommand = new RelayCommand(_ => ReloadPluginDataCommand = new RelayCommand(_ =>
{ {
Hide(); Hide();
PluginManager PluginManager
.ReloadData() .ReloadData()
.ContinueWith(_ => .ContinueWith(_ =>
@ -315,7 +315,7 @@ namespace Flow.Launcher.ViewModel
/// <param name="queryText"></param> /// <param name="queryText"></param>
public void ChangeQueryText(string queryText, bool reQuery = false) public void ChangeQueryText(string queryText, bool reQuery = false)
{ {
if (QueryText!=queryText) if (QueryText != queryText)
{ {
// re-query is done in QueryText's setter method // re-query is done in QueryText's setter method
QueryText = queryText; QueryText = queryText;
@ -696,7 +696,7 @@ namespace Flow.Launcher.ViewModel
OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers; OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
} }
public async void ToggleFlowLauncher() public void ToggleFlowLauncher()
{ {
if (MainWindowVisibility != Visibility.Visible) if (MainWindowVisibility != Visibility.Visible)
{ {
@ -704,33 +704,30 @@ namespace Flow.Launcher.ViewModel
} }
else else
{ {
switch (_settings.LastQueryMode) Hide();
{
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() public async void Hide()
{ {
if (MainWindowVisibility != Visibility.Collapsed) switch (_settings.LastQueryMode)
{ {
ToggleFlowLauncher(); 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;
} }
#endregion #endregion