mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add sendFailToast arg
This commit is contained in:
parent
7033bce433
commit
2bb398d95e
2 changed files with 25 additions and 23 deletions
|
|
@ -26,37 +26,38 @@ namespace Flow.Launcher.Helper
|
|||
/// Toggle QuickLook
|
||||
/// </summary>
|
||||
/// <param name="path">File path to preview</param>
|
||||
/// <param name="sendFailToast">Send toast when fails.</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> ToggleQuickLookAsync(string path)
|
||||
public static async Task<bool> 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<bool> CloseQuickLookAsync()
|
||||
public static async Task<bool> CloseQuickLookAsync(bool sendFailToast = true)
|
||||
{
|
||||
bool success = await SendQuickLookPipeMsgAsync(pipeMessageClose);
|
||||
if (!success)
|
||||
if (sendFailToast && !success)
|
||||
{
|
||||
ShowQuickLookUnavailableToast();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public static async Task<bool> OpenQuickLookAsync(string path)
|
||||
public static async Task<bool> 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
|
|||
/// <param name="path">File path to preview</param>
|
||||
/// <param name="sendFailToast">Send notification if fail</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> SwitchQuickLookAsync(string path, bool sendFailToast = false)
|
||||
public static async Task<bool> SwitchQuickLookAsync(string path, bool sendFailToast = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue