Skip to content

Commit e1a05c6

Browse files
Lamparteryaira2
authored andcommitted
Add option to disable OpenTerminal action
1 parent 7203007 commit e1a05c6

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
@@ -215,6 +215,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
215215
/// </summary>
216216
bool ShowOpenInNewPane { get; set; }
217217

218+
/// <summary>
219+
/// Gets or sets a value indicating whether or not to show the option to open folders in Windows Terminal.
220+
/// </summary>
221+
bool ShowOpenTerminal { get; set; }
222+
218223
/// <summary>
219224
/// Gets or sets a value indicating whether or not to show the option to copy an items path.
220225
/// </summary>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ public bool ShowOpenInNewPane
281281
set => Set(value);
282282
}
283283

284+
public bool ShowOpenTerminal
285+
{
286+
get => Get(true);
287+
set => Set(value);
288+
}
289+
284290
public bool ShowCopyPath
285291
{
286292
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
@@ -4273,4 +4273,7 @@
42734273
<data name="Filename" xml:space="preserve">
42744274
<value>Filename</value>
42754275
</data>
4276+
<data name="ShowOpenTerminal" xml:space="preserve">
4277+
<value>Show option to open folders in Windows Terminal</value>
4278+
</data>
42764279
</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)