mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Show toast when QL unavailable
This commit is contained in:
parent
45a42a5e54
commit
cda587fb58
2 changed files with 31 additions and 17 deletions
|
|
@ -6,6 +6,7 @@ using System.IO;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Flow.Launcher.Infrastructure.Logger;
|
using Flow.Launcher.Infrastructure.Logger;
|
||||||
|
using Flow.Launcher.Core.Resource;
|
||||||
|
|
||||||
namespace Flow.Launcher.Helper
|
namespace Flow.Launcher.Helper
|
||||||
{
|
{
|
||||||
|
|
@ -26,33 +27,38 @@ namespace Flow.Launcher.Helper
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<bool> ToggleQuickLookAsync(string path, bool switchPreview = false)
|
public static async Task<bool> ToggleQuickLookAsync(string path, bool switchPreview = false)
|
||||||
{
|
{
|
||||||
//bool isQuickLookAvailable = await DetectQuickLookAvailabilityAsync();
|
|
||||||
|
|
||||||
//if (!isQuickLookAvailable)
|
|
||||||
//{
|
|
||||||
// if (!switchPreview)
|
|
||||||
// {
|
|
||||||
// Log.Warn($"{nameof(QuickLookHelper)}", "QuickLook not detected");
|
|
||||||
// }
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return await SendQuickLookPipeMsgAsync(switchPreview ? pipeMessageSwitch : pipeMessageToggle, path);
|
bool success = await SendQuickLookPipeMsgAsync(switchPreview ? pipeMessageSwitch : pipeMessageToggle, path);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
ShowQuickLookUnavailableToast();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> CloseQuickLookAsync()
|
public static async Task<bool> CloseQuickLookAsync()
|
||||||
{
|
{
|
||||||
return await SendQuickLookPipeMsgAsync(pipeMessageClose);
|
bool success = await SendQuickLookPipeMsgAsync(pipeMessageClose);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
ShowQuickLookUnavailableToast();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> OpenQuickLookAsync(string path)
|
public static async Task<bool> OpenQuickLookAsync(string path)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
return false;
|
return false;
|
||||||
return await SendQuickLookPipeMsgAsync(pipeMessageInvoke, path);
|
|
||||||
|
bool success = await SendQuickLookPipeMsgAsync(pipeMessageInvoke, path);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
ShowQuickLookUnavailableToast();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<bool> SendQuickLookPipeMsgAsync(string message, string arg = "")
|
private static async Task<bool> SendQuickLookPipeMsgAsync(string message, string arg = "")
|
||||||
|
|
@ -80,7 +86,7 @@ namespace Flow.Launcher.Helper
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<bool> DetectQuickLookAvailabilityAsync()
|
public static async Task<bool> DetectQuickLookAvailabilityAsync()
|
||||||
{
|
{
|
||||||
static async Task<int> QuickLookServerAvailable()
|
static async Task<int> QuickLookServerAvailable()
|
||||||
{
|
{
|
||||||
|
|
@ -115,5 +121,11 @@ namespace Flow.Launcher.Helper
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ShowQuickLookUnavailableToast()
|
||||||
|
{
|
||||||
|
Notification.Show(InternationalizationManager.Instance.GetTranslation("QuickLookFail"),
|
||||||
|
InternationalizationManager.Instance.GetTranslation("QuickLookFailTips"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,8 @@
|
||||||
|
|
||||||
<!-- General Notice -->
|
<!-- General Notice -->
|
||||||
<system:String x:Key="pleaseWait">Please wait...</system:String>
|
<system:String x:Key="pleaseWait">Please wait...</system:String>
|
||||||
|
<system:String x:Key="QuickLookFail">Failed to launch QuickLook</system:String>
|
||||||
|
<system:String x:Key="QuickLookFailTips">Please check if QuickLook is running.</system:String>
|
||||||
|
|
||||||
<!-- Update -->
|
<!-- Update -->
|
||||||
<system:String x:Key="update_flowlauncher_update_check">Checking for new update</system:String>
|
<system:String x:Key="update_flowlauncher_update_check">Checking for new update</system:String>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue