Skip to content

Commit f42f87c

Browse files
Merge pull request #1709 from VictoriousRaptor/LazyLoadPreview
Lazy load preview image
2 parents 944e0f1 + 4513f24 commit f42f87c

35 files changed

+258
-90
lines changed

Flow.Launcher.Infrastructure/Image/ImageCache.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ public bool ContainsKey(string key, bool isFullImage)
8787
return key is not null && Data.ContainsKey((key, isFullImage)) && Data[(key, isFullImage)].imageSource != null;
8888
}
8989

90+
public bool TryGetValue(string key, bool isFullImage, out ImageSource image)
91+
{
92+
if (key is not null)
93+
{
94+
bool hasKey = Data.TryGetValue((key, isFullImage), out var imageUsage);
95+
image = hasKey ? imageUsage.imageSource : null;
96+
return hasKey;
97+
}
98+
else
99+
{
100+
image = null;
101+
return false;
102+
}
103+
}
104+
90105
public int CacheSize()
91106
{
92107
return Data.Count;

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ public static bool CacheContainImage(string path, bool loadFullImage = false)
251251
return ImageCache.ContainsKey(path, false) && ImageCache[path, loadFullImage] != null;
252252
}
253253

254+
public static bool TryGetValue(string path, bool loadFullImage, out ImageSource image)
255+
{
256+
return ImageCache.TryGetValue(path, loadFullImage, out image);
257+
}
258+
254259
public static async ValueTask<ImageSource> LoadAsync(string path, bool loadFullImage = false)
255260
{
256261
var imageResult = await LoadInternalAsync(path, loadFullImage);

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Settings : BaseModel
1818
public string ColorScheme { get; set; } = "System";
1919
public bool ShowOpenResultHotkey { get; set; } = true;
2020
public double WindowSize { get; set; } = 580;
21+
public string PreviewHotkey { get; set; } = $"F1";
2122

2223
public string Language
2324
{

Flow.Launcher.Plugin/Result.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,14 @@ public record PreviewInfo
246246
/// </summary>
247247
public bool IsMedia { get; set; }
248248
public string Description { get; set; }
249+
public IconDelegate PreviewDelegate { get; set; }
249250

250251
public static PreviewInfo Default { get; } = new()
251252
{
252253
PreviewImagePath = null,
253254
Description = null,
254255
IsMedia = false,
256+
PreviewDelegate = null,
255257
};
256258
}
257259
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows.Data;
4+
using System.Windows.Input;
5+
6+
namespace Flow.Launcher.Converters
7+
{
8+
class StringToKeyBindingConverter : IValueConverter
9+
{
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
var mode = parameter as string;
13+
var hotkeyStr = value as string;
14+
var converter = new KeyGestureConverter();
15+
var key = (KeyGesture)converter.ConvertFromString(hotkeyStr);
16+
if (mode == "key")
17+
{
18+
return key.Key;
19+
}
20+
else if (mode == "modifiers")
21+
{
22+
return key.Modifiers;
23+
}
24+
return null;
25+
}
26+
27+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28+
{
29+
throw new NotImplementedException();
30+
}
31+
}
32+
}

Flow.Launcher/Languages/da.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<system:String x:Key="ShouldUsePinyin">Search with Pinyin</system:String>
6464
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese.</system:String>
6565
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
66-
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow starts. Press F1 to toggle preview. </system:String>
66+
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
6767
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
6868

6969
<!-- Setting Plugin -->

Flow.Launcher/Languages/de.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<system:String x:Key="ShouldUsePinyin">Pinyin aktivieren</system:String>
6464
<system:String x:Key="ShouldUsePinyinToolTip">Ermöglicht die Verwendung von Pinyin für die Suche. Pinyin ist das Standardsystem der romanisierten Schreibweise für die Übersetzung von chinesischen Texten.</system:String>
6565
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
66-
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow starts. Press F1 to toggle preview. </system:String>
66+
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
6767
<system:String x:Key="shadowEffectNotAllowed">Der Schatteneffekt ist nicht zulässig, wenn das aktuelle Thema den Weichzeichneffekt aktiviert hat</system:String>
6868

6969
<!-- Setting Plugin -->

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<system:String x:Key="ShouldUsePinyin">Search with Pinyin</system:String>
7474
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese.</system:String>
7575
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
76-
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow starts. Press F1 to toggle preview.</system:String>
76+
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
7777
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
7878

7979
<!-- Setting Plugin -->
@@ -156,6 +156,8 @@
156156
<system:String x:Key="hotkey">Hotkey</system:String>
157157
<system:String x:Key="flowlauncherHotkey">Flow Launcher Hotkey</system:String>
158158
<system:String x:Key="flowlauncherHotkeyToolTip">Enter shortcut to show/hide Flow Launcher.</system:String>
159+
<system:String x:Key="previewHotkey">Preview Hotkey</system:String>
160+
<system:String x:Key="previewHotkeyToolTip">Enter shortcut to show/hide preview in search window.</system:String>
159161
<system:String x:Key="openResultModifiers">Open Result Modifier Key</system:String>
160162
<system:String x:Key="openResultModifiersToolTip">Select a modifier key to open selected result via keyboard.</system:String>
161163
<system:String x:Key="showOpenResultHotkey">Show Hotkey</system:String>

Flow.Launcher/Languages/es-419.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<system:String x:Key="ShouldUsePinyin">Search with Pinyin</system:String>
6464
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese.</system:String>
6565
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
66-
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow starts. Press F1 to toggle preview. </system:String>
66+
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
6767
<system:String x:Key="shadowEffectNotAllowed">El efecto de sombra no está permitido mientras el tema actual tenga el efecto de desenfoque habilitado</system:String>
6868

6969
<!-- Setting Plugin -->

Flow.Launcher/Languages/es.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<system:String x:Key="ShouldUsePinyin">Buscar con Pinyin</system:String>
6464
<system:String x:Key="ShouldUsePinyinToolTip">Permite utilizar Pinyin para la búsqueda. Pinyin es el sistema estándar de ortografía romanizado para traducir chino.</system:String>
6565
<system:String x:Key="AlwaysPreview">Mostrar siempre vista previa</system:String>
66-
<system:String x:Key="AlwaysPreviewToolTip">Muestra siempre el panel de vista previa al iniciar Flow. Pulse F1 para mostrar/ocultar la vista previa. </system:String>
66+
<system:String x:Key="AlwaysPreviewToolTip">Muestra siempre el panel de vista previa al iniciar Flow. Pulse {0} para mostrar/ocultar la vista previa. </system:String>
6767
<system:String x:Key="shadowEffectNotAllowed">El efecto de sombra no está permitido mientras el tema actual tenga el efecto de desenfoque activado</system:String>
6868

6969
<!-- Setting Plugin -->

0 commit comments

Comments
 (0)