|
1 |
| -using Flow.Launcher.Core.ExternalPlugins; |
| 1 | +using Flow.Launcher.Core.ExternalPlugins; |
2 | 2 | using System;
|
3 | 3 | using System.Collections.Concurrent;
|
4 | 4 | using System.Collections.Generic;
|
@@ -90,6 +90,48 @@ public static async Task ReloadDataAsync()
|
90 | 90 | }).ToArray());
|
91 | 91 | }
|
92 | 92 |
|
| 93 | + public static async Task OpenExternalPreviewAsync(string path, bool sendFailToast = true) |
| 94 | + { |
| 95 | + await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch |
| 96 | + { |
| 97 | + IAsyncExternalPreview p => p.OpenPreviewAsync(path, sendFailToast), |
| 98 | + _ => Task.CompletedTask, |
| 99 | + }).ToArray()); |
| 100 | + } |
| 101 | + |
| 102 | + public static async Task CloseExternalPreviewAsync() |
| 103 | + { |
| 104 | + await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch |
| 105 | + { |
| 106 | + IAsyncExternalPreview p => p.ClosePreviewAsync(), |
| 107 | + _ => Task.CompletedTask, |
| 108 | + }).ToArray()); |
| 109 | + } |
| 110 | + |
| 111 | + public static async Task SwitchExternalPreviewAsync(string path, bool sendFailToast = true) |
| 112 | + { |
| 113 | + await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch |
| 114 | + { |
| 115 | + IAsyncExternalPreview p => p.SwitchPreviewAsync(path, sendFailToast), |
| 116 | + _ => Task.CompletedTask, |
| 117 | + }).ToArray()); |
| 118 | + } |
| 119 | + |
| 120 | + public static bool UseExternalPreview() |
| 121 | + { |
| 122 | + return GetPluginsForInterface<IAsyncExternalPreview>().Any(x => !x.Metadata.Disabled); |
| 123 | + } |
| 124 | + |
| 125 | + public static bool AllowAlwaysPreview() |
| 126 | + { |
| 127 | + var plugin = GetPluginsForInterface<IAsyncExternalPreview>().FirstOrDefault(x => !x.Metadata.Disabled); |
| 128 | + |
| 129 | + if (plugin is null) |
| 130 | + return false; |
| 131 | + |
| 132 | + return ((IAsyncExternalPreview)plugin.Plugin).AllowAlwaysPreview(); |
| 133 | + } |
| 134 | + |
93 | 135 | static PluginManager()
|
94 | 136 | {
|
95 | 137 | // validate user directory
|
|
0 commit comments