diff --git a/Flow.Launcher/Helper/QuickLookHelper.cs b/Flow.Launcher/Helper/QuickLookHelper.cs
index f5023cfc7..85682b1d6 100644
--- a/Flow.Launcher/Helper/QuickLookHelper.cs
+++ b/Flow.Launcher/Helper/QuickLookHelper.cs
@@ -26,37 +26,38 @@ namespace Flow.Launcher.Helper
/// Toggle QuickLook
///
/// File path to preview
+ /// Send toast when fails.
///
- public static async Task ToggleQuickLookAsync(string path)
+ public static async Task ToggleQuickLookAsync(string path, bool sendFailToast = true)
{
if (string.IsNullOrEmpty(path))
return false;
bool success = await SendQuickLookPipeMsgAsync(pipeMessageToggle, path);
- if (!success)
+ if (sendFailToast && !success)
{
ShowQuickLookUnavailableToast();
}
return success;
}
- public static async Task CloseQuickLookAsync()
+ public static async Task CloseQuickLookAsync(bool sendFailToast = true)
{
bool success = await SendQuickLookPipeMsgAsync(pipeMessageClose);
- if (!success)
+ if (sendFailToast && !success)
{
ShowQuickLookUnavailableToast();
}
return success;
}
- public static async Task OpenQuickLookAsync(string path)
+ public static async Task OpenQuickLookAsync(string path, bool sendFailToast = true)
{
if (string.IsNullOrEmpty(path))
return false;
bool success = await SendQuickLookPipeMsgAsync(pipeMessageInvoke, path);
- if (!success)
+ if (sendFailToast && !success)
{
ShowQuickLookUnavailableToast();
}
@@ -69,7 +70,7 @@ namespace Flow.Launcher.Helper
/// File path to preview
/// Send notification if fail
///
- public static async Task SwitchQuickLookAsync(string path, bool sendFailToast = false)
+ public static async Task SwitchQuickLookAsync(string path, bool sendFailToast = true)
{
if (string.IsNullOrEmpty(path))
return false;
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 69cbd33d4..7df2ff038 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -612,29 +612,29 @@ namespace Flow.Launcher.ViewModel
}
}
- private async Task OpenExternalPreviewAsync(string path)
+ private async Task OpenExternalPreviewAsync(string path, bool sendFailToast = true)
{
- bool success = await QuickLookHelper.OpenQuickLookAsync(path).ConfigureAwait(false);
- if (success)
- {
- ExternalPreviewOpen = true;
- }
- }
-
- private async Task CloseExternalPreviewAsync()
- {
- bool success = await QuickLookHelper.CloseQuickLookAsync().ConfigureAwait(false);
+ bool success = await QuickLookHelper.OpenQuickLookAsync(path, sendFailToast).ConfigureAwait(false);
if (success)
{
ExternalPreviewOpen = false;
}
}
-
- private async Task SwitchExternalPreviewAsync(string path)
+
+ private async Task CloseExternalPreviewAsync(bool sendFailToast = true)
+ {
+ bool success = await QuickLookHelper.CloseQuickLookAsync(sendFailToast).ConfigureAwait(false);
+ if (success)
+ {
+ ExternalPreviewOpen = false;
+ }
+ }
+
+ private async Task SwitchExternalPreviewAsync(string path, bool sendFailToast = true)
{
// Switches preview content
// When external is off, do nothing
- _ = QuickLookHelper.SwitchQuickLookAsync(path).ConfigureAwait(false);
+ _ = QuickLookHelper.SwitchQuickLookAsync(path, sendFailToast).ConfigureAwait(false);
}
private void ShowInternalPreview()
@@ -672,7 +672,7 @@ namespace Flow.Launcher.ViewModel
{
if (CanExternalPreviewSelectedResult(out var path))
{
- _ = SwitchExternalPreviewAsync(path);
+ _ = SwitchExternalPreviewAsync(path, false);
}
else
{
@@ -1090,7 +1090,8 @@ namespace Flow.Launcher.ViewModel
// Trick for no delay
MainWindowOpacity = 0;
- _ = CloseExternalPreviewAsync();
+ if (Settings.UseExternalPreview)
+ _ = CloseExternalPreviewAsync(false);
if (!SelectedIsFromQueryResults())
{