Skip to content

Feature: Added an option to disable the "Open in Windows Terminal" action #17250

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

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
5 changes: 5 additions & 0 deletions src/Files.App/Actions/Open/OpenTerminalAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal partial class OpenTerminalAction : ObservableObject, IAction
{
private readonly IContentPageContext context;

private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
Copy link
Member

Choose a reason for hiding this comment

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

Please use field for DI instances

Copy link
Member

Choose a reason for hiding this comment

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

The action should still be available when the menu item is turned off.


public virtual string Label
=> Strings.OpenTerminal.GetLocalizedResource();

Expand Down Expand Up @@ -96,6 +98,9 @@ protected virtual string[] GetPaths()

private bool GetIsExecutable()
{
if (UserSettingsService.GeneralSettingsService.ShowOpenTerminal is false)
return false;

if (context.PageType is ContentPageTypes.None or ContentPageTypes.Home or ContentPageTypes.RecycleBin or ContentPageTypes.ZipFolder or ContentPageTypes.ReleaseNotes or ContentPageTypes.Settings)
return false;

Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Actions/Open/OpenTerminalFromHomeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Files.App.Actions
internal sealed partial class OpenTerminalFromHomeAction : OpenTerminalAction
{
private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService<IHomePageContext>();
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

public override string Label
=> Strings.OpenTerminal.GetLocalizedResource();
Expand All @@ -14,6 +15,7 @@ public override string Description
=> Strings.OpenTerminalDescription.GetLocalizedResource();

public override bool IsExecutable =>
UserSettingsService.GeneralSettingsService.ShowOpenTerminal &&
HomePageContext.IsAnyItemRightClicked &&
HomePageContext.RightClickedItem is not null &&
(HomePageContext.RightClickedItem is WidgetFileTagCardItem fileTagItem
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Actions/Open/OpenTerminalFromSidebarAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Files.App.Actions
internal sealed partial class OpenTerminalFromSidebarAction : OpenTerminalAction
{
private ISidebarContext SidebarContext { get; } = Ioc.Default.GetRequiredService<ISidebarContext>();
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

public override string Label
=> Strings.OpenTerminal.GetLocalizedResource();
Expand All @@ -14,6 +15,7 @@ public override string Description
=> Strings.OpenTerminalDescription.GetLocalizedResource();

public override bool IsExecutable =>
UserSettingsService.GeneralSettingsService.ShowOpenTerminal &&
SidebarContext.IsItemRightClicked &&
SidebarContext.RightClickedItem is not null &&
SidebarContext.RightClickedItem.MenuOptions.ShowShellItems &&
Expand Down
5 changes: 5 additions & 0 deletions src/Files.App/Data/Contracts/IGeneralSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
/// </summary>
bool ShowOpenInNewPane { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to show the option to open folders in Windows Terminal.
/// </summary>
bool ShowOpenTerminal { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to show the option to copy an items path.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Files.App/Services/Settings/GeneralSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ public bool ShowOpenInNewPane
set => Set(value);
}

public bool ShowOpenTerminal
{
get => Get(true);
set => Set(value);
}

public bool ShowCopyPath
{
get => Get(true);
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -4264,4 +4264,7 @@
<data name="SeeMore" xml:space="preserve">
<value>See more</value>
</data>
<data name="ShowOpenTerminal" xml:space="preserve">
<value>Show option to open folders in Windows Terminal</value>
</data>
</root>
13 changes: 13 additions & 0 deletions src/Files.App/ViewModels/Settings/GeneralViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,19 @@ public bool ShowOpenInNewWindow
}
}

public bool ShowOpenTerminal
{
get => UserSettingsService.GeneralSettingsService.ShowOpenTerminal;
set
{
if (value != UserSettingsService.GeneralSettingsService.ShowOpenTerminal)
{
UserSettingsService.GeneralSettingsService.ShowOpenTerminal = value;
OnPropertyChanged();
}
}
}

private string selectedShellPaneArrangementType;
public string SelectedShellPaneArrangementType
{
Expand Down
5 changes: 5 additions & 0 deletions src/Files.App/Views/Settings/GeneralPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@
<ToggleSwitch AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenInNewPane}" IsOn="{x:Bind ViewModel.ShowOpenInNewPane, Mode=TwoWay}" />
</wctcontrols:SettingsCard>

<!-- Open in Windows Terminal -->
Copy link
Member

Choose a reason for hiding this comment

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

The setting should probably match the order of the context menu item.

<wctcontrols:SettingsCard Header="{helpers:ResourceString Name=ShowOpenTerminal}">
<ToggleSwitch AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenTerminal}" IsOn="{x:Bind ViewModel.ShowOpenTerminal, Mode=TwoWay}" />
</wctcontrols:SettingsCard>

<!-- Copy path -->
<wctcontrols:SettingsCard Header="{helpers:ResourceString Name=ShowCopyPath}">
<ToggleSwitch AutomationProperties.Name="{helpers:ResourceString Name=ShowCopyPath}" IsOn="{x:Bind ViewModel.ShowCopyPath, Mode=TwoWay}" />
Expand Down
Loading