Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs
Copy link
Member Author

@yaira2 yaira2 Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the code for getting the icon size to LayoutSizeKindHelper.cs.

Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,13 @@ public uint GetRoundedIconSize()
{
return LayoutMode switch
{
FolderLayoutModes.DetailsView
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize <= DetailsViewSizeKind.Small
=> Constants.ShellIconSizes.Small,
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium
=> 20,
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large
=> 24,
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge
=> Constants.ShellIconSizes.Large,
FolderLayoutModes.ListView
=> Constants.ShellIconSizes.Large,
Expand Down
9 changes: 5 additions & 4 deletions src/Files.App/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
var loadNonCachedThumbnail = false;
var thumbnailSize = folderSettings.GetRoundedIconSize();
var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48;
var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView;

byte[]? result = null;

Expand All @@ -988,7 +989,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
item.ItemPath,
thumbnailSize,
item.IsFolder,
IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached);
IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached | (useCurrentScale ? IconOptions.UseCurrentScale : 0));

cancellationToken.ThrowIfCancellationRequested();
loadNonCachedThumbnail = true;
Expand All @@ -1001,7 +1002,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
item.ItemPath,
thumbnailSize,
item.IsFolder,
IconOptions.ReturnIconOnly);
IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0));

cancellationToken.ThrowIfCancellationRequested();
}
Expand All @@ -1013,7 +1014,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
item.ItemPath,
thumbnailSize,
item.IsFolder,
returnIconOnly ? IconOptions.ReturnIconOnly : IconOptions.None);
returnIconOnly ? IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0) : (useCurrentScale ? IconOptions.UseCurrentScale : 0));

cancellationToken.ThrowIfCancellationRequested();
}
Expand Down Expand Up @@ -1059,7 +1060,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () =>
item.ItemPath,
thumbnailSize,
item.IsFolder,
IconOptions.ReturnThumbnailOnly);
IconOptions.ReturnThumbnailOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0));
}
finally
{
Expand Down
12 changes: 7 additions & 5 deletions src/Files.App/Views/Layouts/DetailsLayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -903,13 +903,16 @@
Loaded="StackPanel_Loaded"
Orientation="Horizontal">
<!-- Item Thumbnail -->
<Grid HorizontalAlignment="Left" VerticalAlignment="Stretch">
<Grid
Width="{Binding ColumnsViewModel.IconColumn.Length.Value, ElementName=PageRoot, Mode=OneWay}"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">

<!-- Thumbnail -->
<Grid
x:Name="IconBox"
Width="24"
Height="24"
Width="{Binding ColumnsViewModel.IconColumn.Length.Value, ElementName=PageRoot, Mode=OneWay}"
Height="{Binding ColumnsViewModel.IconColumn.Length.Value, ElementName=PageRoot, Mode=OneWay}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
AutomationProperties.Name="{helpers:ResourceString Name=FileBrowserThumbnailIconColumnGrid/AutomationProperties/Name}"
Expand All @@ -918,8 +921,7 @@
Tag="ItemImage">
<ContentPresenter
x:Name="PicturePresenter"
Width="20"
Height="20"
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
x:Load="{x:Bind LoadFileIcon, Mode=OneWay}"
Expand Down
26 changes: 25 additions & 1 deletion src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public sealed partial class DetailsLayoutPage : BaseGroupableLayoutPage
// Fields

private ListedItem? _nextItemToSelect;
private uint currentIconSize;

// Properties

Expand Down Expand Up @@ -136,6 +137,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)

base.OnNavigatedTo(eventArgs);

currentIconSize = FolderSettings.GetRoundedIconSize();

if (FolderSettings?.ColumnsViewModel is not null)
{
ColumnsViewModel.DateCreatedColumn = FolderSettings.ColumnsViewModel.DateCreatedColumn;
Expand Down Expand Up @@ -191,7 +194,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
UserSettingsService.LayoutSettingsService.PropertyChanged -= LayoutSettingsService_PropertyChanged;
}

private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e)
private async void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(ILayoutSettingsService.DetailsViewSize))
{
Expand All @@ -205,6 +208,14 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang

// Restore correct scroll position
ContentScroller?.ChangeView(null, previousOffset, null);

// Reload icons with correct size but only if the size changed
var requestedIconSize = FolderSettings.GetRoundedIconSize();
if (requestedIconSize != currentIconSize)
{
currentIconSize = requestedIconSize;
_ = ReloadItemIconsAsync();
}
}
else
{
Expand Down Expand Up @@ -255,6 +266,19 @@ private void SetItemContainerStyle()
// Set correct style
FileList.ItemContainerStyle = RegularItemContainerStyle;
}

// Set icon column width
var iconColumnWidth = UserSettingsService.LayoutSettingsService.DetailsViewSize switch
{
DetailsViewSizeKind.Compact => new GridLength(20),
DetailsViewSizeKind.Small => new GridLength(20),
DetailsViewSizeKind.Medium => new GridLength(24),
DetailsViewSizeKind.Large => new GridLength(28),
DetailsViewSizeKind.ExtraLarge => new GridLength(36),
_ => new GridLength(20)
};

ColumnsViewModel.IconColumn.UserLength = iconColumnWidth;
}

private void FileList_LayoutUpdated(object? sender, object e)
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)

var parameters = (NavigationArguments)eventArgs.Parameter;
if (parameters.IsLayoutSwitch)
ReloadItemIconsAsync();
_ = ReloadItemIconsAsync();
}

protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
Expand Down Expand Up @@ -204,7 +204,7 @@ private async void FolderSettings_LayoutModeChangeRequested(object? sender, Layo
if (requestedIconSize != currentIconSize)
{
currentIconSize = requestedIconSize;
await ReloadItemIconsAsync();
_ = ReloadItemIconsAsync();
}
}
}
Expand Down Expand Up @@ -497,7 +497,7 @@ private async void FolderSettings_IconHeightChanged()
{
// Update icon size before refreshing
currentIconSize = requestedIconSize;
await ReloadItemIconsAsync();
_ = ReloadItemIconsAsync();
}
}

Expand Down
Loading