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