From 9167cba6367867b216c2440ef0f6c0393c1d1b8d Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 22 Mar 2025 23:08:47 +0800
Subject: [PATCH 01/18] Use selected item for binding preview properties & Code
cleanup
---
Flow.Launcher/MainWindow.xaml | 4 ++--
Flow.Launcher/ViewModel/MainViewModel.cs | 21 +++++++++++++----
Flow.Launcher/ViewModel/ResultViewModel.cs | 25 ++++++++++++++-------
Flow.Launcher/ViewModel/ResultsViewModel.cs | 13 ++++++-----
4 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 5b63303acf7..d1f6e7812ef 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -441,7 +441,7 @@
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 46970a6a13f..f06b8aa810e 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -162,6 +162,7 @@ public MainViewModel()
switch (args.PropertyName)
{
case nameof(Results.SelectedItem):
+ SelectedItem = Results.SelectedItem;
UpdatePreview();
break;
}
@@ -786,6 +787,18 @@ private static string VerifyOrSetDefaultHotkey(string hotkey, string defaultHotk
#region Preview
+ private ResultViewModel _selectedItem;
+
+ public ResultViewModel SelectedItem
+ {
+ get => _selectedItem;
+ set
+ {
+ _selectedItem = value;
+ OnPropertyChanged();
+ }
+ }
+
public bool InternalPreviewVisible
{
get
@@ -884,7 +897,7 @@ private static void SwitchExternalPreview(string path, bool sendFailToast = true
private void ShowInternalPreview()
{
ResultAreaColumn = ResultAreaColumnPreviewShown;
- Results.SelectedItem?.LoadPreviewImage();
+ SelectedItem?.LoadPreviewImage();
}
private void HideInternalPreview()
@@ -939,14 +952,14 @@ when CanExternalPreviewSelectedResult(out var path):
case false
when InternalPreviewVisible:
- Results.SelectedItem?.LoadPreviewImage();
+ SelectedItem?.LoadPreviewImage();
break;
}
}
private bool CanExternalPreviewSelectedResult(out string path)
{
- path = Results.SelectedItem?.Result?.Preview.FilePath;
+ path = SelectedItem?.Result?.Preview.FilePath;
return !string.IsNullOrEmpty(path);
}
@@ -976,7 +989,7 @@ private void QueryContextMenu()
var query = QueryText.ToLower().Trim();
ContextMenu.Clear();
- var selected = Results.SelectedItem?.Result;
+ var selected = SelectedItem?.Result;
if (selected != null) // SelectedItem returns null if selection is empty.
{
diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs
index 5130e7ebafc..172eca50294 100644
--- a/Flow.Launcher/ViewModel/ResultViewModel.cs
+++ b/Flow.Launcher/ViewModel/ResultViewModel.cs
@@ -1,4 +1,7 @@
using System;
+using System.Collections.Generic;
+using System.Drawing.Text;
+using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
@@ -6,16 +9,13 @@
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
-using System.IO;
-using System.Drawing.Text;
-using System.Collections.Generic;
namespace Flow.Launcher.ViewModel
{
public class ResultViewModel : BaseModel
{
- private static PrivateFontCollection fontCollection = new();
- private static Dictionary fonts = new();
+ private static readonly PrivateFontCollection fontCollection = new();
+ private static readonly Dictionary fonts = new();
public ResultViewModel(Result result, Settings settings)
{
@@ -39,11 +39,11 @@ public ResultViewModel(Result result, Settings settings)
fontFamilyPath = Path.Combine(Result.PluginDirectory, fontFamilyPath);
}
- if (fonts.ContainsKey(fontFamilyPath))
+ if (fonts.TryGetValue(fontFamilyPath, out var value))
{
Glyph = glyph with
{
- FontFamily = fonts[fontFamilyPath]
+ FontFamily = value
};
}
else
@@ -171,7 +171,16 @@ public ImageSource Image
public ImageSource PreviewImage
{
- get => previewImage;
+ get
+ {
+ if (!PreviewImageLoaded)
+ {
+ PreviewImageLoaded = true;
+ _ = LoadPreviewImageAsync();
+ }
+
+ return previewImage;
+ }
private set => previewImage = value;
}
diff --git a/Flow.Launcher/ViewModel/ResultsViewModel.cs b/Flow.Launcher/ViewModel/ResultsViewModel.cs
index 7d2b5bc9348..512f5c1509f 100644
--- a/Flow.Launcher/ViewModel/ResultsViewModel.cs
+++ b/Flow.Launcher/ViewModel/ResultsViewModel.cs
@@ -1,6 +1,4 @@
using System;
-using Flow.Launcher.Infrastructure.UserSettings;
-using Flow.Launcher.Plugin;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
@@ -10,6 +8,8 @@
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
+using Flow.Launcher.Infrastructure.UserSettings;
+using Flow.Launcher.Plugin;
namespace Flow.Launcher.ViewModel
{
@@ -219,7 +219,6 @@ private List NewResults(List newRawResults, string resu
if (newRawResults.Count == 0)
return Results;
-
var newResults = newRawResults.Select(r => new ResultViewModel(r, _settings));
return Results.Where(r => r.Result.PluginID != resultId)
@@ -241,6 +240,7 @@ private List NewResults(ICollection resultsFo
#endregion
#region FormattedText Dependency Property
+
public static readonly DependencyProperty FormattedTextProperty = DependencyProperty.RegisterAttached(
"FormattedText",
typeof(Inline),
@@ -259,8 +259,7 @@ public static Inline GetFormattedText(DependencyObject textBlock)
private static void FormattedTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
- var textBlock = d as TextBlock;
- if (textBlock == null) return;
+ if (d is not TextBlock textBlock) return;
var inline = (Inline)e.NewValue;
@@ -269,6 +268,7 @@ private static void FormattedTextPropertyChanged(DependencyObject d, DependencyP
textBlock.Inlines.Add(inline);
}
+
#endregion
public class ResultCollection : List, INotifyCollectionChanged
@@ -279,7 +279,6 @@ public class ResultCollection : List, INotifyCollectionChanged
public event NotifyCollectionChangedEventHandler CollectionChanged;
-
protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
CollectionChanged?.Invoke(this, e);
@@ -297,6 +296,7 @@ public void BulkAddAll(List resultViews)
// wpf use DirectX / double buffered already, so just reset all won't cause ui flickering
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
+
private void AddAll(List Items)
{
for (int i = 0; i < Items.Count; i++)
@@ -308,6 +308,7 @@ private void AddAll(List Items)
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, i));
}
}
+
public void RemoveAll(int Capacity = 512)
{
Clear();
From b93faffdc0d0fc2141cbd0738d1606b3eff5a56a Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 22 Mar 2025 23:12:20 +0800
Subject: [PATCH 02/18] Code cleanup
---
Flow.Launcher/ViewModel/ResultViewModel.cs | 7 ++-----
Flow.Launcher/ViewModel/ResultsViewModel.cs | 1 +
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs
index 172eca50294..73b380394f5 100644
--- a/Flow.Launcher/ViewModel/ResultViewModel.cs
+++ b/Flow.Launcher/ViewModel/ResultViewModel.cs
@@ -21,10 +21,8 @@ public ResultViewModel(Result result, Settings settings)
{
Settings = settings;
- if (result == null)
- {
- return;
- }
+ if (result == null) return;
+
Result = result;
if (Result.Glyph is { FontFamily: not null } glyph)
@@ -61,7 +59,6 @@ public ResultViewModel(Result result, Settings settings)
Glyph = glyph;
}
}
-
}
public Settings Settings { get; }
diff --git a/Flow.Launcher/ViewModel/ResultsViewModel.cs b/Flow.Launcher/ViewModel/ResultsViewModel.cs
index 512f5c1509f..61566b41571 100644
--- a/Flow.Launcher/ViewModel/ResultsViewModel.cs
+++ b/Flow.Launcher/ViewModel/ResultsViewModel.cs
@@ -28,6 +28,7 @@ public ResultsViewModel()
Results = new ResultCollection();
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
}
+
public ResultsViewModel(Settings settings) : this()
{
_settings = settings;
From 26ab2aecef33771913af596079959d419aab550b Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 22 Mar 2025 23:19:42 +0800
Subject: [PATCH 03/18] Revert to results selected item
---
Flow.Launcher/ViewModel/MainViewModel.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index f06b8aa810e..9b42ae613ce 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -989,7 +989,7 @@ private void QueryContextMenu()
var query = QueryText.ToLower().Trim();
ContextMenu.Clear();
- var selected = SelectedItem?.Result;
+ var selected = Results.SelectedItem?.Result;
if (selected != null) // SelectedItem returns null if selection is empty.
{
From f1bcfc1933e25901165a72c63279b9aa6ea241c9 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 22 Mar 2025 23:33:04 +0800
Subject: [PATCH 04/18] Support preview panel for history
---
Flow.Launcher/MainWindow.xaml | 4 +-
Flow.Launcher/ViewModel/MainViewModel.cs | 47 +++++++++++++++++++++---
2 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index d1f6e7812ef..20e4b20d976 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -441,7 +441,7 @@
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 9b42ae613ce..6b307864e2e 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -162,7 +162,20 @@ public MainViewModel()
switch (args.PropertyName)
{
case nameof(Results.SelectedItem):
- SelectedItem = Results.SelectedItem;
+ _selectedItemFromQueryResults = true;
+ PreviewSelectedItem = Results.SelectedItem;
+ UpdatePreview();
+ break;
+ }
+ };
+
+ History.PropertyChanged += (_, args) =>
+ {
+ switch (args.PropertyName)
+ {
+ case nameof(History.SelectedItem):
+ _selectedItemFromQueryResults = false;
+ PreviewSelectedItem = History.SelectedItem;
UpdatePreview();
break;
}
@@ -646,10 +659,12 @@ public void ChangeQueryText(string queryText, bool isReQuery = false)
private ResultsViewModel SelectedResults
{
- get { return _selectedResults; }
+ get => _selectedResults;
set
{
+ var isReturningFromQueryResults = SelectedIsFromQueryResults();
var isReturningFromContextMenu = ContextMenuSelected();
+ var isReturningFromHistory = HistorySelected();
_selectedResults = value;
if (SelectedIsFromQueryResults())
{
@@ -670,12 +685,30 @@ private ResultsViewModel SelectedResults
{
ChangeQueryText(_queryTextBeforeLeaveResults);
}
+
+ // If we are returning from history and we have not set select item yet,
+ // we need to clear the preview selected item
+ if (isReturningFromHistory && _selectedItemFromQueryResults.HasValue && (!_selectedItemFromQueryResults.Value))
+ {
+ PreviewSelectedItem = null;
+ }
}
else
{
Results.Visibility = Visibility.Collapsed;
+ History.Visibility = Visibility.Collapsed;
_queryTextBeforeLeaveResults = QueryText;
+ if(HistorySelected())
+ {
+ // If we are returning from query results and we have not set select item yet,
+ // we need to clear the preview selected item
+ if (isReturningFromQueryResults && _selectedItemFromQueryResults.HasValue && _selectedItemFromQueryResults.Value)
+ {
+ PreviewSelectedItem = null;
+ }
+ }
+
// Because of Fody's optimization
// setter won't be called when property value is not changed.
// so we need manually call Query()
@@ -787,9 +820,11 @@ private static string VerifyOrSetDefaultHotkey(string hotkey, string defaultHotk
#region Preview
+ private bool? _selectedItemFromQueryResults;
+
private ResultViewModel _selectedItem;
- public ResultViewModel SelectedItem
+ public ResultViewModel PreviewSelectedItem
{
get => _selectedItem;
set
@@ -897,7 +932,7 @@ private static void SwitchExternalPreview(string path, bool sendFailToast = true
private void ShowInternalPreview()
{
ResultAreaColumn = ResultAreaColumnPreviewShown;
- SelectedItem?.LoadPreviewImage();
+ PreviewSelectedItem?.LoadPreviewImage();
}
private void HideInternalPreview()
@@ -952,14 +987,14 @@ when CanExternalPreviewSelectedResult(out var path):
case false
when InternalPreviewVisible:
- SelectedItem?.LoadPreviewImage();
+ PreviewSelectedItem?.LoadPreviewImage();
break;
}
}
private bool CanExternalPreviewSelectedResult(out string path)
{
- path = SelectedItem?.Result?.Preview.FilePath;
+ path = PreviewSelectedItem == Results.SelectedItem ? Results.SelectedItem?.Result?.Preview.FilePath : string.Empty;
return !string.IsNullOrEmpty(path);
}
From 3c7b8cf827dcabfad5c70b713c22d21ae25f7a08 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 22 Mar 2025 23:37:24 +0800
Subject: [PATCH 05/18] Force preview panel height
---
Flow.Launcher/MainWindow.xaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 20e4b20d976..b9e5af1178a 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -432,9 +432,13 @@
+
+
+
From 00ac32708c043cf9b1e52a56894c12f726bef8d9 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 22 Mar 2025 23:41:20 +0800
Subject: [PATCH 06/18] Fix history visibility issue
---
Flow.Launcher/ViewModel/MainViewModel.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 6b307864e2e..797e3c53316 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -696,7 +696,6 @@ private ResultsViewModel SelectedResults
else
{
Results.Visibility = Visibility.Collapsed;
- History.Visibility = Visibility.Collapsed;
_queryTextBeforeLeaveResults = QueryText;
if(HistorySelected())
From 655b017e9e5f7dbf5b50f607054c834a88b85788 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 22 Mar 2025 23:42:14 +0800
Subject: [PATCH 07/18] Code quality
---
Flow.Launcher/ViewModel/MainViewModel.cs | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 797e3c53316..905855d883a 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -698,16 +698,6 @@ private ResultsViewModel SelectedResults
Results.Visibility = Visibility.Collapsed;
_queryTextBeforeLeaveResults = QueryText;
- if(HistorySelected())
- {
- // If we are returning from query results and we have not set select item yet,
- // we need to clear the preview selected item
- if (isReturningFromQueryResults && _selectedItemFromQueryResults.HasValue && _selectedItemFromQueryResults.Value)
- {
- PreviewSelectedItem = null;
- }
- }
-
// Because of Fody's optimization
// setter won't be called when property value is not changed.
// so we need manually call Query()
@@ -720,6 +710,16 @@ private ResultsViewModel SelectedResults
{
QueryText = string.Empty;
}
+
+ if (HistorySelected())
+ {
+ // If we are returning from query results and we have not set select item yet,
+ // we need to clear the preview selected item
+ if (isReturningFromQueryResults && _selectedItemFromQueryResults.HasValue && _selectedItemFromQueryResults.Value)
+ {
+ PreviewSelectedItem = null;
+ }
+ }
}
_selectedResults.Visibility = Visibility.Visible;
From e9f317f6a2531abaf54a73f9519ce55058ef42c7 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sun, 23 Mar 2025 11:02:23 +0800
Subject: [PATCH 08/18] Change variable names
---
Flow.Launcher/ViewModel/ResultViewModel.cs | 65 ++++++++++------------
1 file changed, 28 insertions(+), 37 deletions(-)
diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs
index 73b380394f5..db124e0788a 100644
--- a/Flow.Launcher/ViewModel/ResultViewModel.cs
+++ b/Flow.Launcher/ViewModel/ResultViewModel.cs
@@ -14,8 +14,8 @@ namespace Flow.Launcher.ViewModel
{
public class ResultViewModel : BaseModel
{
- private static readonly PrivateFontCollection fontCollection = new();
- private static readonly Dictionary fonts = new();
+ private static readonly PrivateFontCollection FontCollection = new();
+ private static readonly Dictionary Fonts = new();
public ResultViewModel(Result result, Settings settings)
{
@@ -37,7 +37,7 @@ public ResultViewModel(Result result, Settings settings)
fontFamilyPath = Path.Combine(Result.PluginDirectory, fontFamilyPath);
}
- if (fonts.TryGetValue(fontFamilyPath, out var value))
+ if (Fonts.TryGetValue(fontFamilyPath, out var value))
{
Glyph = glyph with
{
@@ -46,11 +46,11 @@ public ResultViewModel(Result result, Settings settings)
}
else
{
- fontCollection.AddFontFile(fontFamilyPath);
- fonts[fontFamilyPath] = $"{Path.GetDirectoryName(fontFamilyPath)}/#{fontCollection.Families[^1].Name}";
+ FontCollection.AddFontFile(fontFamilyPath);
+ Fonts[fontFamilyPath] = $"{Path.GetDirectoryName(fontFamilyPath)}/#{FontCollection.Families[^1].Name}";
Glyph = glyph with
{
- FontFamily = fonts[fontFamilyPath]
+ FontFamily = Fonts[fontFamilyPath]
};
}
}
@@ -92,14 +92,10 @@ public Visibility ShowPreviewImage
get
{
if (PreviewImageAvailable)
- {
return Visibility.Visible;
- }
- else
- {
- // Fall back to icon
- return ShowIcon;
- }
+
+ // Fall back to icon
+ return ShowIcon;
}
}
@@ -108,9 +104,8 @@ public double IconRadius
get
{
if (Result.RoundedIcon)
- {
return IconXY / 2;
- }
+
return IconXY;
}
@@ -145,40 +140,40 @@ public Visibility ShowGlyph
? Result.SubTitle
: Result.SubTitleToolTip;
- private volatile bool ImageLoaded;
- private volatile bool PreviewImageLoaded;
+ private volatile bool _imageLoaded;
+ private volatile bool _previewImageLoaded;
- private ImageSource image = ImageLoader.LoadingImage;
- private ImageSource previewImage = ImageLoader.LoadingImage;
+ private ImageSource _image = ImageLoader.LoadingImage;
+ private ImageSource _previewImage = ImageLoader.LoadingImage;
public ImageSource Image
{
get
{
- if (!ImageLoaded)
+ if (!_imageLoaded)
{
- ImageLoaded = true;
+ _imageLoaded = true;
_ = LoadImageAsync();
}
- return image;
+ return _image;
}
- private set => image = value;
+ private set => _image = value;
}
public ImageSource PreviewImage
{
get
{
- if (!PreviewImageLoaded)
+ if (!_previewImageLoaded)
{
- PreviewImageLoaded = true;
+ _previewImageLoaded = true;
_ = LoadPreviewImageAsync();
}
- return previewImage;
+ return _previewImage;
}
- private set => previewImage = value;
+ private set => _previewImage = value;
}
///
@@ -194,8 +189,7 @@ private async Task LoadImageInternalAsync(string imagePath, Result.
{
try
{
- var image = icon();
- return image;
+ return icon();
}
catch (Exception e)
{
@@ -214,7 +208,7 @@ private async Task LoadImageAsync()
var iconDelegate = Result.Icon;
if (ImageLoader.TryGetValue(imagePath, false, out ImageSource img))
{
- image = img;
+ _image = img;
}
else
{
@@ -229,7 +223,7 @@ private async Task LoadPreviewImageAsync()
var iconDelegate = Result.Preview.PreviewDelegate ?? Result.Icon;
if (ImageLoader.TryGetValue(imagePath, true, out ImageSource img))
{
- previewImage = img;
+ _previewImage = img;
}
else
{
@@ -240,13 +234,10 @@ private async Task LoadPreviewImageAsync()
public void LoadPreviewImage()
{
- if (ShowDefaultPreview == Visibility.Visible)
+ if (ShowDefaultPreview == Visibility.Visible && !_previewImageLoaded && ShowPreviewImage == Visibility.Visible)
{
- if (!PreviewImageLoaded && ShowPreviewImage == Visibility.Visible)
- {
- PreviewImageLoaded = true;
- _ = LoadPreviewImageAsync();
- }
+ _previewImageLoaded = true;
+ _ = LoadPreviewImageAsync();
}
}
From 07b73db445581052a7f5858973af16ea058e7c03 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 25 Mar 2025 17:42:24 +0800
Subject: [PATCH 09/18] Add preview info for history results
---
Flow.Launcher.Infrastructure/Constant.cs | 1 +
Flow.Launcher/ViewModel/MainViewModel.cs | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/Flow.Launcher.Infrastructure/Constant.cs b/Flow.Launcher.Infrastructure/Constant.cs
index c86ed432467..b4b2485c94c 100644
--- a/Flow.Launcher.Infrastructure/Constant.cs
+++ b/Flow.Launcher.Infrastructure/Constant.cs
@@ -32,6 +32,7 @@ public static class Constant
public static readonly string MissingImgIcon = Path.Combine(ImagesDirectory, "app_missing_img.png");
public static readonly string LoadingImgIcon = Path.Combine(ImagesDirectory, "loading.png");
public static readonly string ImageIcon = Path.Combine(ImagesDirectory, "image.png");
+ public static readonly string HistoryIcon = Path.Combine(ImagesDirectory, "history.png");
public static string PythonPath;
public static string NodePath;
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 905855d883a..d2207be9e5e 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -1075,6 +1075,11 @@ private void QueryHistory()
Title = string.Format(title, h.Query),
SubTitle = string.Format(time, h.ExecutedDateTime),
IcoPath = "Images\\history.png",
+ Preview = new Result.PreviewInfo
+ {
+ PreviewImagePath = Constant.HistoryIcon,
+ Description = string.Format(time, h.ExecutedDateTime)
+ },
OriginQuery = new Query { RawQuery = h.Query },
Action = _ =>
{
From 835457d6f00689cf4eea61885d3e35b6e775c10c Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 25 Mar 2025 17:47:41 +0800
Subject: [PATCH 10/18] Remove debug codes
---
Flow.Launcher/MainWindow.xaml | 1 -
1 file changed, 1 deletion(-)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index b9e5af1178a..6da3614b78e 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -438,7 +438,6 @@
From 3acfebc185ba35f6a414d77a763f092cf346cee9 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 25 Mar 2025 19:36:39 +0800
Subject: [PATCH 11/18] Fix possible visibility issue
---
Flow.Launcher/ViewModel/MainViewModel.cs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index d2207be9e5e..cf8b594538a 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -668,6 +668,7 @@ private ResultsViewModel SelectedResults
_selectedResults = value;
if (SelectedIsFromQueryResults())
{
+ Results.Visibility = Visibility.Visible;
ContextMenu.Visibility = Visibility.Collapsed;
History.Visibility = Visibility.Collapsed;
@@ -696,6 +697,16 @@ private ResultsViewModel SelectedResults
else
{
Results.Visibility = Visibility.Collapsed;
+ if (HistorySelected())
+ {
+ ContextMenu.Visibility = Visibility.Collapsed;
+ History.Visibility = Visibility.Visible;
+ }
+ else
+ {
+ ContextMenu.Visibility = Visibility.Visible;
+ History.Visibility = Visibility.Collapsed;
+ }
_queryTextBeforeLeaveResults = QueryText;
// Because of Fody's optimization
From 0d740484186ea423ed2fab23485de866e289be0f Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Tue, 25 Mar 2025 22:43:02 +0800
Subject: [PATCH 12/18] Add control names
---
Flow.Launcher/MainWindow.xaml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 6da3614b78e..b09b9be0ec2 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -215,7 +215,7 @@
-
+
-
+
+