Skip to content

Commit 53188c3

Browse files
authored
Merge branch 'dev' into explorer-plugin-integrated-context-menu
2 parents d701bca + ca5ce61 commit 53188c3

File tree

24 files changed

+763
-124
lines changed

24 files changed

+763
-124
lines changed

.cm/gitstream.cm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ changes:
7272
# Sum all the line removed in the PR
7373
deletions: {{ branch.diff.files_metadata | map(attr='deletions') | sum }}
7474
# Calculate the ratio of new code
75-
ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
75+
ratio: {{ (changes.additions / (changes.additions + changes.deletions)) * 100 | round(2) }}
76+
77+
has:
78+
screenshot_link: {{ pr.description | includes(regex=r/!\[.*\]\(.*(jpg|svg|png|gif|psd).*\)/) }}
79+
image_uploaded: {{ pr.description | includes(regex=r/<img.*src.*(jpg|svg|png|gif|psd).*>/) }}

.github/actions/spelling/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Português
9898
Português (Brasil)
9999
Italiano
100100
Slovenský
101+
quicklook
101102
Tiếng Việt
102103
Droplex
103104
Preinstalled

.github/workflows/pr_assignee.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Assign PR to creator
2+
3+
# Due to GitHub token limitation, only able to assign org members not authors from forks.
4+
# https://github.com/thomaseizinger/assign-pr-creator-action/issues/3
5+
6+
on:
7+
pull_request:
8+
types: [opened]
9+
branches-ignore:
10+
- l10n_dev
11+
12+
jobs:
13+
automation:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Assign PR to creator
17+
uses: thomaseizinger/[email protected]
18+
with:
19+
repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr_milestone.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Set Milestone
2+
3+
# Assigns the earliest created milestone that matches the below glob pattern.
4+
5+
on:
6+
pull_request:
7+
types: [opened]
8+
9+
jobs:
10+
automation:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: set-milestone
15+
uses: andrefcdias/[email protected]
16+
with:
17+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
18+
milestone: "+([0-9]).+([0-9]).+([0-9])"
19+
use-expression: true

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Core.ExternalPlugins;
1+
using Flow.Launcher.Core.ExternalPlugins;
22
using System;
33
using System.Collections.Concurrent;
44
using System.Collections.Generic;
@@ -90,6 +90,48 @@ public static async Task ReloadDataAsync()
9090
}).ToArray());
9191
}
9292

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+
93135
static PluginManager()
94136
{
95137
// validate user directory

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ public CustomBrowserViewModel CustomBrowser
185185
/// when false Alphabet static service will always return empty results
186186
/// </summary>
187187
public bool ShouldUsePinyin { get; set; } = false;
188+
188189
public bool AlwaysPreview { get; set; } = false;
190+
189191
public bool AlwaysStartEn { get; set; } = false;
190192

191193
private SearchPrecisionScore _querySearchPrecision = SearchPrecisionScore.Regular;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Threading.Tasks;
2+
3+
namespace Flow.Launcher.Plugin
4+
{
5+
/// <summary>
6+
/// This interface is for plugins that wish to provide file preview (external preview)
7+
/// via a third party app instead of the default preview.
8+
/// </summary>
9+
public interface IAsyncExternalPreview : IFeatures
10+
{
11+
/// <summary>
12+
/// Method for opening/showing the preview.
13+
/// </summary>
14+
/// <param name="path">The file path to open the preview for</param>
15+
/// <param name="sendFailToast">Whether to send a toast message notification on failure for the user</param>
16+
public Task OpenPreviewAsync(string path, bool sendFailToast = true);
17+
18+
/// <summary>
19+
/// Method for closing/hiding the preview.
20+
/// </summary>
21+
public Task ClosePreviewAsync();
22+
23+
/// <summary>
24+
/// Method for switching the preview to the next file result.
25+
/// This requires the external preview be already open/showing
26+
/// </summary>
27+
/// <param name="path">The file path to switch the preview for</param>
28+
/// <param name="sendFailToast">Whether to send a toast message notification on failure for the user</param>
29+
public Task SwitchPreviewAsync(string path, bool sendFailToast = true);
30+
31+
/// <summary>
32+
/// Allows the preview plugin to override the AlwaysPreview setting. Typically useful if plugin's preview does not
33+
/// fully work well with being shown together when the query window appears with results.
34+
/// When AlwaysPreview setting is on and this is set to false, the preview will not be shown when query
35+
/// window appears with results, instead the internal preview will be shown.
36+
/// </summary>
37+
/// <returns></returns>
38+
public bool AllowAlwaysPreview();
39+
}
40+
}

Flow.Launcher.Plugin/Result.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,25 +275,30 @@ public record PreviewInfo
275275
/// <summary>
276276
/// Full image used for preview panel
277277
/// </summary>
278-
public string PreviewImagePath { get; set; }
278+
public string PreviewImagePath { get; set; } = null;
279279

280280
/// <summary>
281281
/// Determines if the preview image should occupy the full width of the preview panel.
282282
/// </summary>
283-
public bool IsMedia { get; set; }
283+
public bool IsMedia { get; set; } = false;
284284

285285
/// <summary>
286286
/// Result description text that is shown at the bottom of the preview panel.
287287
/// </summary>
288288
/// <remarks>
289289
/// When a value is not set, the <see cref="SubTitle"/> will be used.
290290
/// </remarks>
291-
public string Description { get; set; }
291+
public string Description { get; set; } = null;
292292

293293
/// <summary>
294294
/// Delegate to get the preview panel's image
295295
/// </summary>
296-
public IconDelegate PreviewDelegate { get; set; }
296+
public IconDelegate PreviewDelegate { get; set; } = null;
297+
298+
/// <summary>
299+
/// File path of the result. For third-party programs providing external preview.
300+
/// </summary>
301+
public string FilePath { get; set; } = null;
297302

298303
/// <summary>
299304
/// Default instance of <see cref="PreviewInfo"/>
@@ -304,6 +309,7 @@ public record PreviewInfo
304309
Description = null,
305310
IsMedia = false,
306311
PreviewDelegate = null,
312+
FilePath = null,
307313
};
308314
}
309315
}

Flow.Launcher/Images/Error.png

4.91 KB
Loading

Flow.Launcher/Images/Exclamation.png

3.3 KB
Loading

0 commit comments

Comments
 (0)