Skip to content

Commit fe66cad

Browse files
Merge remote-tracking branch 'upstream/dev' into FixProgramSource
2 parents 25e4b50 + 4153aa9 commit fe66cad

File tree

99 files changed

+1696
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1696
-391
lines changed

Flow.Launcher.Core/Plugin/JsonRPCConfigurationModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23

34
namespace Flow.Launcher.Core.Plugin
45
{
@@ -26,6 +27,8 @@ public class FieldAttributes
2627
public string Name { get; set; }
2728
public string Label { get; set; }
2829
public string Description { get; set; }
30+
public string urlLabel { get; set; }
31+
public Uri url { get; set; }
2932
public bool Validation { get; set; }
3033
public List<string> Options { get; set; }
3134
public string DefaultValue { get; set; }
@@ -40,4 +43,4 @@ public void Deconstruct(out string Name, out string Label, out string Descriptio
4043
DefaultValue = this.DefaultValue;
4144
}
4245
}
43-
}
46+
}

Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs

Lines changed: 174 additions & 26 deletions
Large diffs are not rendered by default.

Flow.Launcher.Infrastructure/Constant.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static class Constant
2929
public static readonly string DefaultIcon = Path.Combine(ImagesDirectory, "app.png");
3030
public static readonly string ErrorIcon = Path.Combine(ImagesDirectory, "app_error.png");
3131
public static readonly string MissingImgIcon = Path.Combine(ImagesDirectory, "app_missing_img.png");
32+
public static readonly string LoadingImgIcon = Path.Combine(ImagesDirectory, "loading.png");
3233

3334
public static string PythonPath;
3435

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.IO;
56
using System.Linq;
67
using System.Net;
@@ -21,8 +22,10 @@ public static class ImageLoader
2122
private static readonly ConcurrentDictionary<string, string> GuidToKey = new();
2223
private static IImageHashGenerator _hashGenerator;
2324
private static readonly bool EnableImageHash = true;
24-
public static ImageSource DefaultImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon));
25-
public const int SmallIconSize = 32;
25+
public static ImageSource MissingImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon));
26+
public static ImageSource LoadingImage { get; } = new BitmapImage(new Uri(Constant.LoadingImgIcon));
27+
public const int SmallIconSize = 64;
28+
public const int FullIconSize = 256;
2629

2730

2831
private static readonly string[] ImageExtensions =
@@ -99,6 +102,7 @@ private enum ImageType
99102
Folder,
100103
Data,
101104
ImageFile,
105+
FullImageFile,
102106
Error,
103107
Cache
104108
}
@@ -111,7 +115,7 @@ private static async ValueTask<ImageResult> LoadInternalAsync(string path, bool
111115
{
112116
if (string.IsNullOrEmpty(path))
113117
{
114-
return new ImageResult(DefaultImage, ImageType.Error);
118+
return new ImageResult(MissingImage, ImageType.Error);
115119
}
116120

117121
if (ImageCache.ContainsKey(path, loadFullImage))
@@ -201,6 +205,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag
201205
if (loadFullImage)
202206
{
203207
image = LoadFullImage(path);
208+
type = ImageType.FullImageFile;
204209
}
205210
else
206211
{
@@ -215,7 +220,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag
215220
else
216221
{
217222
type = ImageType.File;
218-
image = GetThumbnail(path, ThumbnailOptions.None);
223+
image = GetThumbnail(path, ThumbnailOptions.None, loadFullImage ? FullIconSize : SmallIconSize);
219224
}
220225
}
221226
else
@@ -232,12 +237,12 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag
232237
return new ImageResult(image, type);
233238
}
234239

235-
private static BitmapSource GetThumbnail(string path, ThumbnailOptions option = ThumbnailOptions.ThumbnailOnly)
240+
private static BitmapSource GetThumbnail(string path, ThumbnailOptions option = ThumbnailOptions.ThumbnailOnly, int size = SmallIconSize)
236241
{
237242
return WindowsThumbnailProvider.GetThumbnail(
238243
path,
239-
Constant.ThumbnailSize,
240-
Constant.ThumbnailSize,
244+
size,
245+
size,
241246
option);
242247
}
243248

@@ -254,6 +259,10 @@ public static async ValueTask<ImageSource> LoadAsync(string path, bool loadFullI
254259
if (imageResult.ImageType != ImageType.Error && imageResult.ImageType != ImageType.Cache)
255260
{ // we need to get image hash
256261
string hash = EnableImageHash ? _hashGenerator.GetHashFromImage(img) : null;
262+
if (imageResult.ImageType == ImageType.FullImageFile)
263+
{
264+
path = $"{path}_{ImageType.FullImageFile}";
265+
}
257266
if (hash != null)
258267
{
259268

@@ -263,6 +272,7 @@ public static async ValueTask<ImageSource> LoadAsync(string path, bool loadFullI
263272
}
264273
else
265274
{ // new guid
275+
266276
GuidToKey[hash] = path;
267277
}
268278
}
@@ -279,9 +289,33 @@ private static BitmapImage LoadFullImage(string path)
279289
BitmapImage image = new BitmapImage();
280290
image.BeginInit();
281291
image.CacheOption = BitmapCacheOption.OnLoad;
282-
image.UriSource = new Uri(path);
292+
image.UriSource = new Uri(path);
283293
image.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
284294
image.EndInit();
295+
296+
if (image.PixelWidth > 320)
297+
{
298+
BitmapImage resizedWidth = new BitmapImage();
299+
resizedWidth.BeginInit();
300+
resizedWidth.CacheOption = BitmapCacheOption.OnLoad;
301+
resizedWidth.UriSource = new Uri(path);
302+
resizedWidth.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
303+
resizedWidth.DecodePixelWidth = 320;
304+
resizedWidth.EndInit();
305+
306+
if (resizedWidth.PixelHeight > 320)
307+
{
308+
BitmapImage resizedHeight = new BitmapImage();
309+
resizedHeight.BeginInit();
310+
resizedHeight.CacheOption = BitmapCacheOption.OnLoad;
311+
resizedHeight.UriSource = new Uri(path);
312+
resizedHeight.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
313+
resizedHeight.DecodePixelHeight = 320;
314+
resizedHeight.EndInit();
315+
return resizedHeight;
316+
}
317+
return resizedWidth;
318+
}
285319
return image;
286320
}
287321
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public CustomBrowserViewModel CustomBrowser
146146
/// when false Alphabet static service will always return empty results
147147
/// </summary>
148148
public bool ShouldUsePinyin { get; set; } = false;
149+
public bool AlwaysPreview { get; set; } = false;
149150

150151
[JsonInclude, JsonConverter(typeof(JsonStringEnumConverter))]
151152
public SearchPrecisionScore QuerySearchPrecision { get; private set; } = SearchPrecisionScore.Regular;

Flow.Launcher.Plugin/Result.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Threading.Tasks;
5+
using System.Windows.Controls;
56
using System.Windows.Media;
67

78
namespace Flow.Launcher.Plugin
@@ -203,6 +204,11 @@ public override string ToString()
203204
/// </summary>
204205
public string SubTitleToolTip { get; set; }
205206

207+
/// <summary>
208+
/// Customized Preview Panel
209+
/// </summary>
210+
public Lazy<UserControl> PreviewPanel { get; set; }
211+
206212
/// <summary>
207213
/// Run this result, asynchronously
208214
/// </summary>
@@ -223,5 +229,30 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
223229
/// </summary>
224230
/// <default>#26a0da (blue)</default>
225231
public string ProgressBarColor { get; set; } = "#26a0da";
232+
233+
public PreviewInfo Preview { get; set; } = PreviewInfo.Default;
234+
235+
/// <summary>
236+
/// Info of the preview image.
237+
/// </summary>
238+
public record PreviewInfo
239+
{
240+
/// <summary>
241+
/// Full image used for preview panel
242+
/// </summary>
243+
public string PreviewImagePath { get; set; }
244+
/// <summary>
245+
/// Determines if the preview image should occupy the full width of the preveiw panel.
246+
/// </summary>
247+
public bool IsMedia { get; set; }
248+
public string Description { get; set; }
249+
250+
public static PreviewInfo Default { get; } = new()
251+
{
252+
PreviewImagePath = null,
253+
Description = null,
254+
IsMedia = false,
255+
};
256+
}
226257
}
227258
}

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
@@ -92,7 +92,7 @@
9292
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
9393
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
9494
<PackageReference Include="NHotkey.Wpf" Version="2.1.0" />
95-
<PackageReference Include="NuGet.CommandLine" Version="5.7.2">
95+
<PackageReference Include="NuGet.CommandLine" Version="6.3.1">
9696
<PrivateAssets>all</PrivateAssets>
9797
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
9898
</PackageReference>

Flow.Launcher/Images/Browser.png

3.96 KB
Loading
667 Bytes
Loading

Flow.Launcher/Images/loading.png

274 Bytes
Loading

0 commit comments

Comments
 (0)