diff --git a/src/Files.App/Actions/Open/OpenTerminalAction.cs b/src/Files.App/Actions/Open/OpenTerminalAction.cs index 208c24705b4a..aaa1aa17068d 100644 --- a/src/Files.App/Actions/Open/OpenTerminalAction.cs +++ b/src/Files.App/Actions/Open/OpenTerminalAction.cs @@ -10,6 +10,8 @@ internal partial class OpenTerminalAction : ObservableObject, IAction { private readonly IContentPageContext context; + private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService(); + public virtual string Label => Strings.OpenTerminal.GetLocalizedResource(); @@ -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; diff --git a/src/Files.App/Actions/Open/OpenTerminalFromHomeAction.cs b/src/Files.App/Actions/Open/OpenTerminalFromHomeAction.cs index 066d508ff23e..c14d6dc10239 100644 --- a/src/Files.App/Actions/Open/OpenTerminalFromHomeAction.cs +++ b/src/Files.App/Actions/Open/OpenTerminalFromHomeAction.cs @@ -6,6 +6,7 @@ namespace Files.App.Actions internal sealed partial class OpenTerminalFromHomeAction : OpenTerminalAction { private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService(); + private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService(); public override string Label => Strings.OpenTerminal.GetLocalizedResource(); @@ -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 diff --git a/src/Files.App/Actions/Open/OpenTerminalFromSidebarAction.cs b/src/Files.App/Actions/Open/OpenTerminalFromSidebarAction.cs index 91e7a29f1f1b..da260ef4d686 100644 --- a/src/Files.App/Actions/Open/OpenTerminalFromSidebarAction.cs +++ b/src/Files.App/Actions/Open/OpenTerminalFromSidebarAction.cs @@ -6,6 +6,7 @@ namespace Files.App.Actions internal sealed partial class OpenTerminalFromSidebarAction : OpenTerminalAction { private ISidebarContext SidebarContext { get; } = Ioc.Default.GetRequiredService(); + private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService(); public override string Label => Strings.OpenTerminal.GetLocalizedResource(); @@ -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 && diff --git a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs index b53fb24b756a..57e58ad60c22 100644 --- a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs +++ b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs @@ -210,6 +210,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty /// bool ShowOpenInNewPane { get; set; } + /// + /// Gets or sets a value indicating whether or not to show the option to open folders in Windows Terminal. + /// + bool ShowOpenTerminal { get; set; } + /// /// Gets or sets a value indicating whether or not to show the option to copy an items path. /// diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 0cf219d65a5e..f49b131a87b9 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -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); diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index c0ba4fad97f7..e8db185e01fd 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -4264,4 +4264,7 @@ See more + + Show option to open folders in Windows Terminal + diff --git a/src/Files.App/ViewModels/Settings/GeneralViewModel.cs b/src/Files.App/ViewModels/Settings/GeneralViewModel.cs index 14f49ce7d186..11cd979ce6a6 100644 --- a/src/Files.App/ViewModels/Settings/GeneralViewModel.cs +++ b/src/Files.App/ViewModels/Settings/GeneralViewModel.cs @@ -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 { diff --git a/src/Files.App/Views/Settings/GeneralPage.xaml b/src/Files.App/Views/Settings/GeneralPage.xaml index e8f302df9f82..903c1b1e7c37 100644 --- a/src/Files.App/Views/Settings/GeneralPage.xaml +++ b/src/Files.App/Views/Settings/GeneralPage.xaml @@ -261,6 +261,11 @@ + + + + +