Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
19 changes: 19 additions & 0 deletions src/Files.App/Actions/Display/GroupAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public GroupByAction()
public Task ExecuteAsync(object? parameter = null)
{
DisplayContext.GroupOption = GroupOption;
ContentContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand Down Expand Up @@ -402,6 +403,7 @@ private void DisplayContext_PropertyChanged(object? sender, PropertyChangedEvent
internal sealed class GroupAscendingAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "Ascending".GetLocalizedResource();
Expand All @@ -418,13 +420,15 @@ public bool IsExecutable
public GroupAscendingAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.GroupDirection = SortDirection.Ascending;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -446,6 +450,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
internal sealed class GroupDescendingAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "Descending".GetLocalizedResource();
Expand All @@ -462,13 +467,15 @@ public bool IsExecutable
public GroupDescendingAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.GroupDirection = SortDirection.Descending;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -490,6 +497,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
internal sealed class ToggleGroupDirectionAction : IAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "ToggleSortDirection".GetLocalizedResource();
Expand All @@ -500,11 +508,13 @@ public string Description
public ToggleGroupDirectionAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
}

public Task ExecuteAsync(object? parameter = null)
{
context.GroupDirection = context.SortDirection is SortDirection.Descending ? SortDirection.Ascending : SortDirection.Descending;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -513,6 +523,7 @@ public Task ExecuteAsync(object? parameter = null)
internal sealed class GroupByYearAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "Year".GetLocalizedResource();
Expand All @@ -529,13 +540,15 @@ public bool IsExecutable
public GroupByYearAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.GroupByDateUnit = GroupByDateUnit.Year;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -557,6 +570,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
internal sealed class GroupByMonthAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "Month".GetLocalizedResource();
Expand All @@ -573,13 +587,15 @@ public bool IsExecutable
public GroupByMonthAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.GroupByDateUnit = GroupByDateUnit.Month;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -601,6 +617,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
internal sealed class ToggleGroupByDateUnitAction : IAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "ToggleGroupingUnit".GetLocalizedResource();
Expand All @@ -611,6 +628,7 @@ public string Description
public ToggleGroupByDateUnitAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
}

public Task ExecuteAsync(object? parameter = null)
Expand All @@ -621,6 +639,7 @@ public Task ExecuteAsync(object? parameter = null)
GroupByDateUnit.Month => GroupByDateUnit.Day,
_ => GroupByDateUnit.Year
};
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand Down
11 changes: 11 additions & 0 deletions src/Files.App/Actions/Display/SortAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public SortByAction()
public Task ExecuteAsync(object? parameter = null)
{
displayContext.SortOption = SortOption;
contentContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -187,6 +188,7 @@ private void DisplayContext_PropertyChanged(object? sender, PropertyChangedEvent
internal sealed class SortAscendingAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "Ascending".GetLocalizedResource();
Expand All @@ -200,13 +202,15 @@ public bool IsOn
public SortAscendingAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.SortDirection = SortDirection.Ascending;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -221,6 +225,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
internal sealed class SortDescendingAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "Descending".GetLocalizedResource();
Expand All @@ -234,13 +239,15 @@ public bool IsOn
public SortDescendingAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.SortDirection = SortDirection.Descending;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand All @@ -255,6 +262,7 @@ private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
internal sealed class ToggleSortDirectionAction : IAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "ToggleSortDirection".GetLocalizedResource();
Expand All @@ -265,6 +273,7 @@ public string Description
public ToggleSortDirectionAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
}

public Task ExecuteAsync(object? parameter = null)
Expand All @@ -273,6 +282,8 @@ public Task ExecuteAsync(object? parameter = null)
context.SortDirection is SortDirection.Descending
? SortDirection.Ascending
: SortDirection.Descending;

contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Files.App.Actions
internal sealed class SortFilesAndFoldersTogetherAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "SortFilesAndFoldersTogether".GetLocalizedResource();
Expand All @@ -19,13 +20,15 @@ public bool IsOn
public SortFilesAndFoldersTogetherAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.SortDirectoriesAlongsideFiles = true;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Actions/Display/SortFilesFirstAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Files.App.Actions
internal sealed class SortFilesFirstAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "SortFilesFirst".GetLocalizedResource();
Expand All @@ -19,6 +20,7 @@ public bool IsOn
public SortFilesFirstAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}
Expand All @@ -27,6 +29,7 @@ public Task ExecuteAsync(object? parameter = null)
{
context.SortFilesFirst = true;
context.SortDirectoriesAlongsideFiles = false;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Actions/Display/SortFoldersFirstAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Files.App.Actions
internal sealed class SortFoldersFirstAction : ObservableObject, IToggleAction
{
private readonly IDisplayPageContext context;
private readonly IContentPageContext contentPageContext;

public string Label
=> "SortFoldersFirst".GetLocalizedResource();
Expand All @@ -19,6 +20,7 @@ public bool IsOn
public SortFoldersFirstAction()
{
context = Ioc.Default.GetRequiredService<IDisplayPageContext>();
contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}
Expand All @@ -27,6 +29,7 @@ public Task ExecuteAsync(object? parameter = null)
{
context.SortFilesFirst = false;
context.SortDirectoriesAlongsideFiles = false;
contentPageContext.UpdateOpenTabsPreferences();

return Task.CompletedTask;
}
Expand Down
14 changes: 14 additions & 0 deletions src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ public ContentPageContext()
Update();
}

public void UpdateOpenTabsPreferences()
{
var multitaskingContext = Ioc.Default.GetRequiredService<IMultitaskingContext>();
var tabs = multitaskingContext.Control?.GetAllTabInstances();
var activePath = ((ShellPanesPage)multitaskingContext.CurrentTabItem.TabItemContent)?.ActivePane?.TabBarItemParameter?.NavigationParameter as string;
if (tabs is null || activePath is null)
return;

for (int i = 0; i < tabs.Count; i++)
{
((ShellPanesPage)tabs[i]).UpdatePanesLayout(activePath, i != multitaskingContext.CurrentTabIndex);
}
}

private void GitHelpers_IsExecutingGitActionChanged(object? sender, PropertyChangedEventArgs e)
{
OnPropertyChanged(nameof(CanExecuteGitAction));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ public interface IContentPageContext : INotifyPropertyChanged
bool CanExecuteGitAction { get; }

string? SolutionFilePath { get; }

void UpdateOpenTabsPreferences();
}
}
7 changes: 7 additions & 0 deletions src/Files.App/Data/Contracts/IShellPanesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,12 @@ public interface IShellPanesPage : IDisposable, INotifyPropertyChanged
/// Focuses the other pane.
/// </summary>
public void FocusOtherPane();

/// <summary>
/// Updates the layout of open panes.
/// </summary>
/// <param name="targetPath">The path of panes to update</param>
/// <param name="includeActivePane">Whether the active pane should be updated or not</param>
public void UpdatePanesLayout(string targetPath, bool includeActivePane = false);
}
}
18 changes: 18 additions & 0 deletions src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,24 @@ public Type GetLayoutType(string path, bool changeLayoutMode = true)
};
}

public void UpdateGroupAndSortOptions(string? path)
{
if (string.IsNullOrWhiteSpace(path))
return;

var preferencesItem = GetLayoutPreferencesForPath(path);
if (preferencesItem is null)
return;

DirectorySortOption = preferencesItem.DirectorySortOption;
DirectorySortDirection = preferencesItem.DirectorySortDirection;
DirectoryGroupOption = preferencesItem.DirectoryGroupOption;
DirectoryGroupByDateUnit = preferencesItem.DirectoryGroupByDateUnit;
DirectoryGroupDirection = preferencesItem.DirectoryGroupDirection;
SortDirectoriesAlongsideFiles = preferencesItem.SortDirectoriesAlongsideFiles;
SortFilesFirst = preferencesItem.SortFilesFirst;
}

public bool IsPathUsingDefaultLayout(string? path)
{
return UserSettingsService.LayoutSettingsService.SyncFolderPreferencesAcrossDirectories ||
Expand Down
Loading