mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
allow preview plugin to override the AlwaysPreview setting
This commit is contained in:
parent
e6f0f28ca5
commit
4dbecb1b5a
4 changed files with 36 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using Flow.Launcher.Core.ExternalPlugins;
|
||||
using Flow.Launcher.Core.ExternalPlugins;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -122,6 +122,16 @@ namespace Flow.Launcher.Core.Plugin
|
|||
return GetPluginsForInterface<IAsyncExternalPreview>().Any(x => !x.Metadata.Disabled);
|
||||
}
|
||||
|
||||
public static bool AllowAlwaysPreview()
|
||||
{
|
||||
var plugin = GetPluginsForInterface<IAsyncExternalPreview>().FirstOrDefault(x => !x.Metadata.Disabled);
|
||||
|
||||
if (plugin is null)
|
||||
return false;
|
||||
|
||||
return ((IAsyncExternalPreview)plugin.Plugin).AllowAlwaysPreview();
|
||||
}
|
||||
|
||||
static PluginManager()
|
||||
{
|
||||
// validate user directory
|
||||
|
|
|
|||
|
|
@ -27,5 +27,14 @@ namespace Flow.Launcher.Plugin
|
|||
/// <param name="path">The file path to switch the preview for</param>
|
||||
/// <param name="sendFailToast">Whether to send a toast message notification on failure for the user</param>
|
||||
public Task SwitchPreviewAsync(string path, bool sendFailToast = true);
|
||||
|
||||
/// <summary>
|
||||
/// Allows the preview plugin to override the AlwaysPreview setting. Typically useful if plugin's preview does not
|
||||
/// fully work well with being shown together when the query window appears with results.
|
||||
/// When AlwaysPreview setting is on and this is set to false, the preview will not be shown when query
|
||||
/// window appears with results, instead the internal preview will be shown.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool AllowAlwaysPreview();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
|
@ -869,13 +869,20 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
public void ResetPreview()
|
||||
{
|
||||
if (Settings.AlwaysPreview)
|
||||
switch (Settings.AlwaysPreview)
|
||||
{
|
||||
ShowInternalPreview();
|
||||
}
|
||||
else
|
||||
{
|
||||
HidePreview();
|
||||
case true
|
||||
when PluginManager.AllowAlwaysPreview() && CanExternalPreviewSelectedResult(out var path):
|
||||
OpenExternalPreview(path);
|
||||
break;
|
||||
|
||||
case true:
|
||||
ShowInternalPreview();
|
||||
break;
|
||||
|
||||
case false:
|
||||
HidePreview();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ namespace Flow.Launcher.Plugin.QuickLook
|
|||
|
||||
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token) => new List<Result>();
|
||||
|
||||
public bool AllowAlwaysPreview() => false;
|
||||
|
||||
public string GetTranslatedPluginTitle()
|
||||
{
|
||||
return Context.API.GetTranslation("plugin_name");
|
||||
|
|
|
|||
Loading…
Reference in a new issue