Skip to content

Feature: Added an action to toggle dual pane mode #17401

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

Merged
merged 2 commits into from
Aug 4, 2025
Merged
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
46 changes: 46 additions & 0 deletions src/Files.App/Actions/Show/ToggleDualPaneAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

namespace Files.App.Actions
{
internal sealed partial class ToggleDualPaneAction : ObservableObject, IToggleAction
{
private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
private readonly IGeneralSettingsService generalSettingsService = Ioc.Default.GetRequiredService<IGeneralSettingsService>();

public string Label
=> Strings.ToggleDualPane.GetLocalizedResource();

public string Description
=> Strings.ToggleDualPaneDescription.GetLocalizedResource();

public bool IsOn
=> ContentPageContext.IsMultiPaneActive;

public ToggleDualPaneAction()
{
ContentPageContext.PropertyChanged += ContentPageContext_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
if (IsOn)
ContentPageContext.ShellPage?.PaneHolder.CloseOtherPane();
else
ContentPageContext.ShellPage?.PaneHolder.OpenSecondaryPane(arrangement: generalSettingsService.ShellPaneArrangementOption);

return Task.CompletedTask;
}

private void ContentPageContext_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(IContentPageContext.ShellPage):
case nameof(IContentPageContext.IsMultiPaneActive):
OnPropertyChanged(nameof(IsOn));
break;
}
}
}
}
1 change: 1 addition & 0 deletions src/Files.App/Data/Commands/Manager/CommandCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum CommandCodes
ToggleToolbar,
ToggleShelfPane,
ToggleFilterHeader,
ToggleDualPane,

// File System
CopyItem,
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Data/Commands/Manager/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public IRichCommand this[HotKey hotKey]
public IRichCommand ToggleToolbar => commands[CommandCodes.ToggleToolbar];
public IRichCommand ToggleShelfPane => commands[CommandCodes.ToggleShelfPane];
public IRichCommand ToggleFilterHeader => commands[CommandCodes.ToggleFilterHeader];
public IRichCommand ToggleDualPane => commands[CommandCodes.ToggleDualPane];
public IRichCommand SelectAll => commands[CommandCodes.SelectAll];
public IRichCommand InvertSelection => commands[CommandCodes.InvertSelection];
public IRichCommand ClearSelection => commands[CommandCodes.ClearSelection];
Expand Down Expand Up @@ -266,6 +267,7 @@ public IEnumerator<IRichCommand> GetEnumerator() =>
[CommandCodes.ToggleToolbar] = new ToggleToolbarAction(),
[CommandCodes.ToggleShelfPane] = new ToggleShelfPaneAction(),
[CommandCodes.ToggleFilterHeader] = new ToggleFilterHeaderAction(),
[CommandCodes.ToggleDualPane] = new ToggleDualPaneAction(),
[CommandCodes.SelectAll] = new SelectAllAction(),
[CommandCodes.InvertSelection] = new InvertSelectionAction(),
[CommandCodes.ClearSelection] = new ClearSelectionAction(),
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Data/Commands/Manager/ICommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public interface ICommandManager : IEnumerable<IRichCommand>
IRichCommand ToggleToolbar { get; }
IRichCommand ToggleShelfPane { get; }
IRichCommand ToggleFilterHeader { get; }
IRichCommand ToggleDualPane { get; }

IRichCommand CopyItem { get; }
IRichCommand CopyItemPath { get; }
Expand Down
5 changes: 5 additions & 0 deletions src/Files.App/Data/Contracts/IShellPanesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public interface IShellPanesPage : IDisposable, INotifyPropertyChanged
/// </summary>
public void CloseActivePane();

/// <summary>
/// Closes the non active/focused pane.
/// </summary>
public void CloseOtherPane();

/// <summary>
/// Focuses the other pane.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,12 @@
<data name="ToggleFilterHeaderDescription" xml:space="preserve">
<value>Toggle visibility of the filter header</value>
</data>
<data name="ToggleDualPane" xml:space="preserve">
<value>Toggle dual pane</value>
</data>
<data name="ToggleDualPaneDescription" xml:space="preserve">
<value>Toggle dual pane mode</value>
</data>
<data name="DetailsPanePreviewNotAvaliableText" xml:space="preserve">
<value>No preview available</value>
</data>
Expand Down
12 changes: 12 additions & 0 deletions src/Files.App/Views/ShellPanesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,18 @@ ShellPaneArrangement is ShellPaneArrangement.Vertical
}
}

/// <inheritdoc/>
public void CloseOtherPane()
{
if (!IsMultiPaneActive)
return;

if (ActivePane == (IShellPage)GetPane(0)!)
RemovePane(1);
else
RemovePane(0);
}

/// <inheritdoc/>
public void CloseActivePane()
{
Expand Down
Loading