Skip to content

Commit f743f2e

Browse files
authored
Feature: Use correct DPI settings for search suggestions (files-community#16688)
1 parent 7c96be6 commit f743f2e

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

src/Files.App/UserControls/SearchBox.xaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,24 @@
4848
Spacing="8"
4949
Tag="{x:Bind ItemPath}">
5050
<Grid
51-
Width="24"
52-
Height="24"
51+
Width="16"
52+
Height="16"
5353
Tag="ItemImage">
5454
<Border
5555
x:Name="Picture"
5656
HorizontalAlignment="Stretch"
5757
VerticalAlignment="Stretch"
5858
x:Load="{x:Bind LoadFileIcon, Mode=OneWay}">
5959
<Image
60-
Width="24"
61-
Height="24"
60+
Width="16"
61+
Height="16"
6262
Source="{x:Bind FileImage, Mode=OneWay}"
6363
Stretch="Uniform" />
6464
</Border>
6565
<FontIcon
6666
x:Name="EmptyIconGlyph"
6767
x:Load="{x:Bind NeedsPlaceholderGlyph, Mode=OneWay}"
68+
FontSize="14"
6869
Glyph="{x:Bind IsRecentSearch, Mode=OneTime, Converter={StaticResource SearchSuggestionGlyphConverter}}" />
6970
</Grid>
7071
<TextBlock VerticalAlignment="Center" Text="{x:Bind Name}" />
@@ -98,6 +99,12 @@
9899
<AutoSuggestBox.KeyboardAccelerators>
99100
<KeyboardAccelerator Key="Escape" Invoked="SearchRegion_Escaped" />
100101
</AutoSuggestBox.KeyboardAccelerators>
102+
103+
<AutoSuggestBox.ItemContainerStyle>
104+
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="ListViewItem">
105+
<Setter Property="MinHeight" Value="36" />
106+
</Style>
107+
</AutoSuggestBox.ItemContainerStyle>
101108
</AutoSuggestBox>
102109

103110
</UserControl>

src/Files.App/Utils/Storage/Search/FolderSearch.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public sealed class FolderSearch
2121
private const uint defaultStepSize = 500;
2222

2323
public string? Query { get; set; }
24+
2425
public string? Folder { get; set; }
2526

2627
public uint MaxItemCount { get; set; } = 0; // 0: no limit
27-
public uint ThumbnailSize { get; set; } = 24;
2828

2929
private uint UsedMaxItemCount => MaxItemCount > 0 ? MaxItemCount : uint.MaxValue;
3030

@@ -392,20 +392,28 @@ private ListedItem GetListedItemAsync(string itemPath, WIN32_FIND_DATA findData)
392392
};
393393
}
394394
}
395+
395396
if (listedItem is not null && MaxItemCount > 0) // Only load icon for searchbox suggestions
396397
{
397-
_ = FileThumbnailHelper.LoadIconFromPathAsync(listedItem.ItemPath, ThumbnailSize, ThumbnailMode.ListView, ThumbnailOptions.ResizeThumbnail, isFolder)
398+
_ = FileThumbnailHelper.GetIconAsync(
399+
listedItem.ItemPath,
400+
Constants.ShellIconSizes.Small,
401+
isFolder,
402+
IconOptions.ReturnIconOnly | IconOptions.UseCurrentScale)
398403
.ContinueWith((t) =>
399404
{
400405
if (t.IsCompletedSuccessfully && t.Result is not null)
401406
{
402407
_ = FilesystemTasks.Wrap(() => MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
403408
{
404-
listedItem.FileImage = await t.Result.ToBitmapAsync();
409+
var bitmapImage = await t.Result.ToBitmapAsync();
410+
if (bitmapImage is not null)
411+
listedItem.FileImage = bitmapImage;
405412
}, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low));
406413
}
407414
});
408415
}
416+
409417
return listedItem;
410418
}
411419

src/Files.App/Views/Layouts/BaseLayoutPage.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
482482
{
483483
Query = navigationArguments.SearchQuery,
484484
Folder = navigationArguments.SearchPathParam,
485-
ThumbnailSize = InstanceViewModel!.FolderSettings.GetRoundedIconSize(),
486485
};
487486

488487
_ = ParentShellPageInstance.ShellViewModel.SearchAsync(searchInstance);

src/Files.App/Views/Shells/BaseShellPage.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ public async Task Refresh_Click()
553553
{
554554
Query = InstanceViewModel.CurrentSearchQuery ?? (string)TabBarItemParameter.NavigationParameter,
555555
Folder = ShellViewModel.WorkingDirectory,
556-
ThumbnailSize = InstanceViewModel.FolderSettings.GetRoundedIconSize(),
557556
};
558557

559558
await ShellViewModel.SearchAsync(searchInstance);

0 commit comments

Comments
 (0)