Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Refresh Details Layout Columns after changing setting #16512

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/Files.App/Helpers/Layout/LayoutPreferencesItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public sealed class LayoutPreferencesItem

public ColumnsViewModel ColumnsViewModel { get; set; }

public bool IsDefault { get; set; } = true;
Copy link
Member

Choose a reason for hiding this comment

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

I think we already have a way to check if it's default without adding another property. Fyi @hishitetsu

Copy link
Member

Choose a reason for hiding this comment

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

Surprisingly, we don't seem to have it. We can check by searching the DB though.


public bool SortDirectoriesAlongsideFiles { get; set; }
public bool SortFilesFirst { get; set; }
public bool IsAdaptiveLayoutOverridden { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ private static bool SetLayoutPreferencesToDatabase(string path, ulong? frn, Layo
if (string.IsNullOrEmpty(path))
return false;

preferencesItem.IsDefault = false;
return SafetyExtensions.IgnoreExceptions(() =>
{
var dbInstance = GetDatabaseManagerInstance();
Expand Down
26 changes: 26 additions & 0 deletions src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,32 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang
// Restore correct scroll position
ContentScroller?.ChangeView(null, previousOffset, null);
}
else
{
var settings = sender as ILayoutSettingsService;
if (settings is not null &&
(settings.SyncFolderPreferencesAcrossDirectories || (FolderSettings?.LayoutPreferencesItem.IsDefault ?? false)))
{
switch (e.PropertyName)
{
case nameof(ILayoutSettingsService.ShowFileTagColumn):
ColumnsViewModel.TagColumn.UserCollapsed = !settings.ShowFileTagColumn;
break;
case nameof(ILayoutSettingsService.ShowSizeColumn):
ColumnsViewModel.SizeColumn.UserCollapsed = !settings.ShowSizeColumn;
break;
case nameof(ILayoutSettingsService.ShowTypeColumn):
ColumnsViewModel.ItemTypeColumn.UserCollapsed = !settings.ShowTypeColumn;
break;
case nameof(ILayoutSettingsService.ShowDateCreatedColumn):
ColumnsViewModel.DateCreatedColumn.UserCollapsed = !settings.ShowDateCreatedColumn;
break;
case nameof(ILayoutSettingsService.ShowDateColumn):
ColumnsViewModel.DateModifiedColumn.UserCollapsed = !settings.ShowDateColumn;
break;
}
}
}
}

/// <summary>
Expand Down