From 0709daf1499f2cfa8b3b7ca7487fe9e6c815f6ed Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:51:13 -0500 Subject: [PATCH 1/2] Feature: Use correct DPI settings for search suggestions --- src/Files.App/UserControls/SearchBox.xaml | 14 ++++++++++---- src/Files.App/Utils/Storage/Search/FolderSearch.cs | 14 +++++++++++--- src/Files.App/Views/Layouts/BaseLayoutPage.cs | 1 - src/Files.App/Views/Shells/BaseShellPage.cs | 1 - 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Files.App/UserControls/SearchBox.xaml b/src/Files.App/UserControls/SearchBox.xaml index 034c48b15b3d..174b49bca712 100644 --- a/src/Files.App/UserControls/SearchBox.xaml +++ b/src/Files.App/UserControls/SearchBox.xaml @@ -48,8 +48,8 @@ Spacing="8" Tag="{x:Bind ItemPath}"> @@ -98,6 +98,12 @@ + + + + diff --git a/src/Files.App/Utils/Storage/Search/FolderSearch.cs b/src/Files.App/Utils/Storage/Search/FolderSearch.cs index 79762fa16f29..08df6e230def 100644 --- a/src/Files.App/Utils/Storage/Search/FolderSearch.cs +++ b/src/Files.App/Utils/Storage/Search/FolderSearch.cs @@ -21,10 +21,10 @@ public sealed class FolderSearch private const uint defaultStepSize = 500; public string? Query { get; set; } + public string? Folder { get; set; } public uint MaxItemCount { get; set; } = 0; // 0: no limit - public uint ThumbnailSize { get; set; } = 24; private uint UsedMaxItemCount => MaxItemCount > 0 ? MaxItemCount : uint.MaxValue; @@ -392,20 +392,28 @@ private ListedItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData) }; } } + if (listedItem is not null && MaxItemCount > 0) // Only load icon for searchbox suggestions { - _ = FileThumbnailHelper.LoadIconFromPathAsync(listedItem.ItemPath, ThumbnailSize, ThumbnailMode.ListView, ThumbnailOptions.ResizeThumbnail, isFolder) + _ = FileThumbnailHelper.GetIconAsync( + listedItem.ItemPath, + Constants.ShellIconSizes.Small, + isFolder, + IconOptions.ReturnIconOnly | IconOptions.UseCurrentScale) .ContinueWith((t) => { if (t.IsCompletedSuccessfully && t.Result is not null) { _ = FilesystemTasks.Wrap(() => MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () => { - listedItem.FileImage = await t.Result.ToBitmapAsync(); + var bitmapImage = await t.Result.ToBitmapAsync(); + if (bitmapImage is not null) + listedItem.FileImage = bitmapImage; }, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low)); } }); } + return listedItem; } diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index 8013e40ffcbb..c38181d24653 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -482,7 +482,6 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) { Query = navigationArguments.SearchQuery, Folder = navigationArguments.SearchPathParam, - ThumbnailSize = InstanceViewModel!.FolderSettings.GetRoundedIconSize(), }; _ = ParentShellPageInstance.ShellViewModel.SearchAsync(searchInstance); diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 305c8d211aa4..e7dbc45c0882 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -553,7 +553,6 @@ public async Task Refresh_Click() { Query = InstanceViewModel.CurrentSearchQuery ?? (string)TabBarItemParameter.NavigationParameter, Folder = ShellViewModel.WorkingDirectory, - ThumbnailSize = InstanceViewModel.FolderSettings.GetRoundedIconSize(), }; await ShellViewModel.SearchAsync(searchInstance); From 506d4727789707809941646da07c22ef4415c829 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:54:45 -0500 Subject: [PATCH 2/2] Fix font size --- src/Files.App/UserControls/SearchBox.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Files.App/UserControls/SearchBox.xaml b/src/Files.App/UserControls/SearchBox.xaml index 174b49bca712..aa9eef41149f 100644 --- a/src/Files.App/UserControls/SearchBox.xaml +++ b/src/Files.App/UserControls/SearchBox.xaml @@ -65,6 +65,7 @@