Skip to content

Commit 03dba91

Browse files
committed
Add option to disable OpenTerminal action
1 parent 6e5a3fb commit 03dba91

File tree

8 files changed

+41
-0
lines changed

8 files changed

+41
-0
lines changed

src/Files.App/Actions/Open/OpenTerminalAction.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ internal partial class OpenTerminalAction : ObservableObject, IAction
1010
{
1111
private readonly IContentPageContext context;
1212

13+
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
14+
1315
public virtual string Label
1416
=> Strings.OpenTerminal.GetLocalizedResource();
1517

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

9799
private bool GetIsExecutable()
98100
{
101+
if (UserSettingsService.GeneralSettingsService.ShowOpenTerminal is false)
102+
return false;
103+
99104
if (context.PageType is ContentPageTypes.None or ContentPageTypes.Home or ContentPageTypes.RecycleBin or ContentPageTypes.ZipFolder or ContentPageTypes.ReleaseNotes or ContentPageTypes.Settings)
100105
return false;
101106

src/Files.App/Actions/Open/OpenTerminalFromHomeAction.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Files.App.Actions
66
internal sealed partial class OpenTerminalFromHomeAction : OpenTerminalAction
77
{
88
private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService<IHomePageContext>();
9+
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
910

1011
public override string Label
1112
=> Strings.OpenTerminal.GetLocalizedResource();
@@ -14,6 +15,7 @@ public override string Description
1415
=> Strings.OpenTerminalDescription.GetLocalizedResource();
1516

1617
public override bool IsExecutable =>
18+
UserSettingsService.GeneralSettingsService.ShowOpenTerminal &&
1719
HomePageContext.IsAnyItemRightClicked &&
1820
HomePageContext.RightClickedItem is not null &&
1921
(HomePageContext.RightClickedItem is WidgetFileTagCardItem fileTagItem

src/Files.App/Actions/Open/OpenTerminalFromSidebarAction.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Files.App.Actions
66
internal sealed partial class OpenTerminalFromSidebarAction : OpenTerminalAction
77
{
88
private ISidebarContext SidebarContext { get; } = Ioc.Default.GetRequiredService<ISidebarContext>();
9+
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
910

1011
public override string Label
1112
=> Strings.OpenTerminal.GetLocalizedResource();
@@ -14,6 +15,7 @@ public override string Description
1415
=> Strings.OpenTerminalDescription.GetLocalizedResource();
1516

1617
public override bool IsExecutable =>
18+
UserSettingsService.GeneralSettingsService.ShowOpenTerminal &&
1719
SidebarContext.IsItemRightClicked &&
1820
SidebarContext.RightClickedItem is not null &&
1921
SidebarContext.RightClickedItem.MenuOptions.ShowShellItems &&

src/Files.App/Data/Contracts/IGeneralSettingsService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
210210
/// </summary>
211211
bool ShowOpenInNewPane { get; set; }
212212

213+
/// <summary>
214+
/// Gets or sets a value indicating whether or not to show the option to open folders in Windows Terminal.
215+
/// </summary>
216+
bool ShowOpenTerminal { get; set; }
217+
213218
/// <summary>
214219
/// Gets or sets a value indicating whether or not to show the option to copy an items path.
215220
/// </summary>

src/Files.App/Services/Settings/GeneralSettingsService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ public bool ShowOpenInNewPane
275275
set => Set(value);
276276
}
277277

278+
public bool ShowOpenTerminal
279+
{
280+
get => Get(true);
281+
set => Set(value);
282+
}
283+
278284
public bool ShowCopyPath
279285
{
280286
get => Get(true);

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4264,4 +4264,7 @@
42644264
<data name="SeeMore" xml:space="preserve">
42654265
<value>See more</value>
42664266
</data>
4267+
<data name="ShowOpenTerminal" xml:space="preserve">
4268+
<value>Show option to open folders in Windows Terminal</value>
4269+
</data>
42674270
</root>

src/Files.App/ViewModels/Settings/GeneralViewModel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,19 @@ public bool ShowOpenInNewWindow
521521
}
522522
}
523523

524+
public bool ShowOpenTerminal
525+
{
526+
get => UserSettingsService.GeneralSettingsService.ShowOpenTerminal;
527+
set
528+
{
529+
if (value != UserSettingsService.GeneralSettingsService.ShowOpenTerminal)
530+
{
531+
UserSettingsService.GeneralSettingsService.ShowOpenTerminal = value;
532+
OnPropertyChanged();
533+
}
534+
}
535+
}
536+
524537
private string selectedShellPaneArrangementType;
525538
public string SelectedShellPaneArrangementType
526539
{

src/Files.App/Views/Settings/GeneralPage.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@
261261
<ToggleSwitch AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenInNewPane}" IsOn="{x:Bind ViewModel.ShowOpenInNewPane, Mode=TwoWay}" />
262262
</wctcontrols:SettingsCard>
263263

264+
<!-- Open in Windows Terminal -->
265+
<wctcontrols:SettingsCard Header="{helpers:ResourceString Name=ShowOpenTerminal}">
266+
<ToggleSwitch AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenTerminal}" IsOn="{x:Bind ViewModel.ShowOpenTerminal, Mode=TwoWay}" />
267+
</wctcontrols:SettingsCard>
268+
264269
<!-- Copy path -->
265270
<wctcontrols:SettingsCard Header="{helpers:ResourceString Name=ShowCopyPath}">
266271
<ToggleSwitch AutomationProperties.Name="{helpers:ResourceString Name=ShowCopyPath}" IsOn="{x:Bind ViewModel.ShowCopyPath, Mode=TwoWay}" />

0 commit comments

Comments
 (0)