Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Files.App/UserControls/SearchBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,24 @@
Spacing="8"
Tag="{x:Bind ItemPath}">
<Grid
Width="24"
Height="24"
Width="16"
Height="16"
Tag="ItemImage">
<Border
x:Name="Picture"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
x:Load="{x:Bind LoadFileIcon, Mode=OneWay}">
<Image
Width="24"
Height="24"
Width="16"
Height="16"
Source="{x:Bind FileImage, Mode=OneWay}"
Stretch="Uniform" />
</Border>
<FontIcon
x:Name="EmptyIconGlyph"
x:Load="{x:Bind NeedsPlaceholderGlyph, Mode=OneWay}"
FontSize="14"
Glyph="{x:Bind IsRecentSearch, Mode=OneTime, Converter={StaticResource SearchSuggestionGlyphConverter}}" />
</Grid>
<TextBlock VerticalAlignment="Center" Text="{x:Bind Name}" />
Expand Down Expand Up @@ -98,6 +99,12 @@
<AutoSuggestBox.KeyboardAccelerators>
<KeyboardAccelerator Key="Escape" Invoked="SearchRegion_Escaped" />
</AutoSuggestBox.KeyboardAccelerators>

<AutoSuggestBox.ItemContainerStyle>
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="ListViewItem">
<Setter Property="MinHeight" Value="36" />
</Style>
</AutoSuggestBox.ItemContainerStyle>
</AutoSuggestBox>

</UserControl>
14 changes: 11 additions & 3 deletions src/Files.App/Utils/Storage/Search/FolderSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Views/Layouts/BaseLayoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading