diff --git a/src/Files.App/Actions/Display/LayoutAction.cs b/src/Files.App/Actions/Display/LayoutAction.cs index 9d7f5a52b815..7104271d7885 100644 --- a/src/Files.App/Actions/Display/LayoutAction.cs +++ b/src/Files.App/Actions/Display/LayoutAction.cs @@ -82,6 +82,8 @@ public override HotKey HotKey [GeneratedRichCommand] internal sealed partial class LayoutColumnsAction : ToggleLayoutAction { + private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService(); + protected override LayoutTypes LayoutType => LayoutTypes.Columns; @@ -96,6 +98,24 @@ public override RichGlyph Glyph public override HotKey HotKey => new(Keys.Number5, KeyModifiers.CtrlShift); + + public override bool IsExecutable + => ContentPageContext.PageType is not ContentPageTypes.RecycleBin; + + public LayoutColumnsAction() + { + ContentPageContext.PropertyChanged += ContentPageContext_PropertyChanged; + } + + private void ContentPageContext_PropertyChanged(object? sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case nameof(IContentPageContext.PageType): + OnPropertyChanged(nameof(IsExecutable)); + break; + } + } } [GeneratedRichCommand] diff --git a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs index d3e74adb7433..d5f3a5122f50 100644 --- a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs +++ b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs @@ -486,6 +486,28 @@ public static void SetLayoutPreferencesForPath(string path, LayoutPreferencesIte private static LayoutPreferencesItem? GetLayoutPreferencesForPath(string path) { + if (path.StartsWith(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.Ordinal)) + { + var trimmedPath = path.TrimPath() ?? string.Empty; + + var recycleBinPreference = SafetyExtensions.IgnoreExceptions(() => + { + var folderFRN = Win32Helper.GetFolderFRN(trimmedPath); + + return GetLayoutPreferencesFromDatabase(trimmedPath, folderFRN) + ?? GetLayoutPreferencesFromAds(trimmedPath, folderFRN); + }, App.Logger); + + if (recycleBinPreference is not null && recycleBinPreference.LayoutMode != FolderLayoutModes.ColumnView) + return recycleBinPreference; + + var defaultPref = new LayoutPreferencesItem(); + if (defaultPref.LayoutMode == FolderLayoutModes.ColumnView) + defaultPref.LayoutMode = FolderLayoutModes.DetailsView; + + return defaultPref; + } + if (!UserSettingsService.LayoutSettingsService.SyncFolderPreferencesAcrossDirectories) { path = path.TrimPath() ?? string.Empty;