Skip to content

Commit e962ee7

Browse files
committed
Feature: Use DPI aware icons in the Details View
1 parent e8ed94d commit e962ee7

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,13 @@ public uint GetRoundedIconSize()
227227
{
228228
return LayoutMode switch
229229
{
230-
FolderLayoutModes.DetailsView
230+
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize <= DetailsViewSizeKind.Small
231+
=> Constants.ShellIconSizes.Small,
232+
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium
233+
=> 20,
234+
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large
235+
=> 24,
236+
_ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge
231237
=> Constants.ShellIconSizes.Large,
232238
FolderLayoutModes.ListView
233239
=> Constants.ShellIconSizes.Large,

src/Files.App/ViewModels/ShellViewModel.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
975975
var loadNonCachedThumbnail = false;
976976
var thumbnailSize = folderSettings.GetRoundedIconSize();
977977
var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48;
978+
var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView;
978979

979980
byte[]? result = null;
980981

@@ -988,7 +989,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
988989
item.ItemPath,
989990
thumbnailSize,
990991
item.IsFolder,
991-
IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached);
992+
IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached | (useCurrentScale ? IconOptions.UseCurrentScale : 0));
992993

993994
cancellationToken.ThrowIfCancellationRequested();
994995
loadNonCachedThumbnail = true;
@@ -1001,7 +1002,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
10011002
item.ItemPath,
10021003
thumbnailSize,
10031004
item.IsFolder,
1004-
IconOptions.ReturnIconOnly);
1005+
IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0));
10051006

10061007
cancellationToken.ThrowIfCancellationRequested();
10071008
}
@@ -1013,7 +1014,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell
10131014
item.ItemPath,
10141015
thumbnailSize,
10151016
item.IsFolder,
1016-
returnIconOnly ? IconOptions.ReturnIconOnly : IconOptions.None);
1017+
returnIconOnly ? IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0) : (useCurrentScale ? IconOptions.UseCurrentScale : 0));
10171018

10181019
cancellationToken.ThrowIfCancellationRequested();
10191020
}
@@ -1059,7 +1060,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () =>
10591060
item.ItemPath,
10601061
thumbnailSize,
10611062
item.IsFolder,
1062-
IconOptions.ReturnThumbnailOnly);
1063+
IconOptions.ReturnThumbnailOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0));
10631064
}
10641065
finally
10651066
{

src/Files.App/Views/Layouts/DetailsLayoutPage.xaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,14 @@
903903
Loaded="StackPanel_Loaded"
904904
Orientation="Horizontal">
905905
<!-- Item Thumbnail -->
906-
<Grid HorizontalAlignment="Left" VerticalAlignment="Stretch">
906+
<Grid
907+
Width="{Binding ColumnsViewModel.IconColumn.Length.Value, ElementName=PageRoot, Mode=OneWay}"
908+
HorizontalAlignment="Left"
909+
VerticalAlignment="Stretch">
907910

908911
<!-- Thumbnail -->
909912
<Grid
910913
x:Name="IconBox"
911-
Width="24"
912-
Height="24"
913914
HorizontalAlignment="Center"
914915
VerticalAlignment="Center"
915916
AutomationProperties.Name="{helpers:ResourceString Name=FileBrowserThumbnailIconColumnGrid/AutomationProperties/Name}"
@@ -918,8 +919,6 @@
918919
Tag="ItemImage">
919920
<ContentPresenter
920921
x:Name="PicturePresenter"
921-
Width="20"
922-
Height="20"
923922
HorizontalAlignment="Center"
924923
VerticalAlignment="Center"
925924
x:Load="{x:Bind LoadFileIcon, Mode=OneWay}"

src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
191191
UserSettingsService.LayoutSettingsService.PropertyChanged -= LayoutSettingsService_PropertyChanged;
192192
}
193193

194-
private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e)
194+
private async void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e)
195195
{
196196
if (e.PropertyName == nameof(ILayoutSettingsService.DetailsViewSize))
197197
{
@@ -205,6 +205,9 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang
205205

206206
// Restore correct scroll position
207207
ContentScroller?.ChangeView(null, previousOffset, null);
208+
209+
// Reload icons with correct size
210+
await ReloadItemIconsAsync();
208211
}
209212
else
210213
{
@@ -255,6 +258,19 @@ private void SetItemContainerStyle()
255258
// Set correct style
256259
FileList.ItemContainerStyle = RegularItemContainerStyle;
257260
}
261+
262+
// Set icon column width
263+
var iconColumnWidth = UserSettingsService.LayoutSettingsService.DetailsViewSize switch
264+
{
265+
DetailsViewSizeKind.Compact => new GridLength(16),
266+
DetailsViewSizeKind.Small => new GridLength(16),
267+
DetailsViewSizeKind.Medium => new GridLength(20),
268+
DetailsViewSizeKind.Large => new GridLength(24),
269+
DetailsViewSizeKind.ExtraLarge => new GridLength(32),
270+
_ => new GridLength(16)
271+
};
272+
273+
ColumnsViewModel.IconColumn.UserLength = iconColumnWidth;
258274
}
259275

260276
private void FileList_LayoutUpdated(object? sender, object e)

0 commit comments

Comments
 (0)