Skip to content

Commit c4b4c48

Browse files
authored
Feature: Added support for hiding open in new tab/window options (#11285)
1 parent fcbd997 commit c4b4c48

File tree

11 files changed

+121
-48
lines changed

11 files changed

+121
-48
lines changed

builds/azure-pipelines.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,6 @@ steps:
4646
TargetFolder: '$(Build.SourcesDirectory)\src\Files.App\Resources'
4747
overWrite: true
4848

49-
- task: DownloadSecureFile@1
50-
name: appCenterDevKey
51-
displayName: 'Download AppCenter Dev Key'
52-
inputs:
53-
secureFile: 'AppCenterKey.txt'
54-
55-
- task: CopyFiles@2
56-
inputs:
57-
SourceFolder: '$(Agent.TempDirectory)'
58-
Contents: '$(appCenterDevKey.secureFilePath)'
59-
TargetFolder: '$(Build.SourcesDirectory)\src\Files.App\Resources'
60-
overWrite: true
61-
6249
- task: UseDotNet@2
6350
inputs:
6451
packageType: sdk

src/Files.App/BaseLayout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ private void AddNewFileTagsToMenu(CommandBarFlyout contextMenu)
694694
index = index >= 0 ? index : contextMenu.SecondaryCommands.Count;
695695

696696
// Only show the edit tags flyout if settings is enabled
697-
if (!UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu)
697+
if (!UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu)
698698
return;
699699

700700
contextMenu.SecondaryCommands.Insert(index, new AppBarSeparator());

src/Files.App/Helpers/ContextFlyoutItemHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Windows.ApplicationModel.DataTransfer;
2121
using Windows.Storage;
2222
using Windows.System;
23+
using Files.App.ServicesImplementation.Settings;
2324

2425
namespace Files.App.Helpers
2526
{
@@ -739,7 +740,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
739740
Glyph = "\uF113",
740741
GlyphFontFamilyName = "CustomGlyph",
741742
Command = commandsViewModel.OpenDirectoryInNewTabCommand,
742-
ShowItem = selectedItems.Count < 5 && areAllItemsFolders,
743+
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab,
743744
ShowInSearchPage = true,
744745
ShowInFtpPage = true,
745746
ShowInZipPage = true,
@@ -749,10 +750,9 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
749750
Text = "BaseLayoutItemContextFlyoutOpenInNewWindow/Text".GetLocalizedResource(),
750751
Glyph = "\uE737",
751752
Command = commandsViewModel.OpenInNewWindowItemCommand,
752-
ShowItem = selectedItems.Count < 5 && areAllItemsFolders,
753+
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.AppearanceSettingsService.ShowOpenInNewWindow,
753754
ShowInSearchPage = true,
754755
ShowInFtpPage = true,
755-
ShowOnShift = true,
756756
ShowInZipPage = true,
757757
},
758758
new ContextMenuFlyoutItemViewModel()

src/Files.App/ServicesImplementation/Settings/AppearanceSettingsService.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,19 @@ public bool MoveShellExtensionsToSubMenu
7373
set => Set(value);
7474
}
7575

76-
public bool DisplayEditTagsMenu
76+
public bool ShowEditTagsMenu
77+
{
78+
get => Get(true);
79+
set => Set(value);
80+
}
81+
82+
public bool ShowOpenInNewTab
83+
{
84+
get => Get(true);
85+
set => Set(value);
86+
}
87+
88+
public bool ShowOpenInNewWindow
7789
{
7890
get => Get(true);
7991
set => Set(value);
@@ -89,7 +101,9 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
89101
case nameof(AppThemeSidebarBackgroundColor):
90102
case nameof(AppThemeFileAreaBackgroundColor):
91103
case nameof(MoveShellExtensionsToSubMenu):
92-
case nameof(DisplayEditTagsMenu):
104+
case nameof(ShowEditTagsMenu):
105+
case nameof(ShowOpenInNewTab):
106+
case nameof(ShowOpenInNewWindow):
93107
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
94108
break;
95109
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,8 +2895,14 @@
28952895
<data name="BundlesBeingRemovedTitle" xml:space="preserve">
28962896
<value>Bundles will be retiring in a future update 📎</value>
28972897
</data>
2898-
<data name="DisplayEditTagsMenu" xml:space="preserve">
2899-
<value>Display the edit tags flyout</value>
2898+
<data name="ShowEditTagsMenu" xml:space="preserve">
2899+
<value>Show edit tags flyout</value>
2900+
</data>
2901+
<data name="ShowOpenInNewTab" xml:space="preserve">
2902+
<value>Show option to open folders in a new tab</value>
2903+
</data>
2904+
<data name="ShowOpenInNewWindow" xml:space="preserve">
2905+
<value>Show option to open folders in a new window</value>
29002906
</data>
29012907
<data name="QuickAccess" xml:space="preserve">
29022908
<value>Quick access</value>
@@ -2931,4 +2937,7 @@
29312937
<data name="LoadingMoreOptions" xml:space="preserve">
29322938
<value>Loading more options...</value>
29332939
</data>
2940+
<data name="ContextMenuOptions" xml:space="preserve">
2941+
<value>Context menu options</value>
2942+
</data>
29342943
</root>

src/Files.App/UserControls/SidebarControl.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
228228
Glyph = "\uF113",
229229
GlyphFontFamilyName = "CustomGlyph",
230230
Command = OpenInNewTabCommand,
231-
ShowItem = options.IsLocationItem
231+
ShowItem = options.IsLocationItem && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
232232
},
233233
new ContextMenuFlyoutItemViewModel()
234234
{
235235
Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(),
236236
Glyph = "\uE737",
237237
Command = OpenInNewWindowCommand,
238-
ShowItem = options.IsLocationItem
238+
ShowItem = options.IsLocationItem && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
239239
},
240240
new ContextMenuFlyoutItemViewModel()
241241
{

src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public async Task LoadCardThumbnailAsync()
7171
}
7272

7373
public sealed partial class DrivesWidget : HomePageWidget, IWidgetItemModel, INotifyPropertyChanged
74-
{
74+
{
75+
public IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
76+
7577
public delegate void DrivesWidgetInvokedEventHandler(object sender, DrivesWidgetInvokedEventArgs e);
7678

7779
public event DrivesWidgetInvokedEventHandler DrivesWidgetInvoked;
@@ -163,14 +165,16 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
163165
Glyph = "\uF113",
164166
GlyphFontFamilyName = "CustomGlyph",
165167
Command = OpenInNewTabCommand,
166-
CommandParameter = item
168+
CommandParameter = item,
169+
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
167170
},
168171
new ContextMenuFlyoutItemViewModel()
169172
{
170173
Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(),
171174
Glyph = "\uE737",
172175
Command = OpenInNewWindowCommand,
173-
CommandParameter = item
176+
CommandParameter = item,
177+
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewWindow
174178
},
175179
new ContextMenuFlyoutItemViewModel()
176180
{

src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
using CommunityToolkit.Mvvm.ComponentModel;
21
using CommunityToolkit.Mvvm.DependencyInjection;
32
using CommunityToolkit.Mvvm.Input;
43
using CommunityToolkit.WinUI;
5-
using CommunityToolkit.WinUI.UI;
64
using Files.App.DataModels.NavigationControlItems;
75
using Files.App.Extensions;
86
using Files.App.Filesystem;
97
using Files.App.Helpers;
10-
using Files.App.Helpers.ContextFlyouts;
118
using Files.App.ViewModels;
129
using Files.App.ViewModels.Widgets;
13-
using Files.Shared.Extensions;
14-
using Microsoft.UI.Input;
10+
using Files.Backend.Services.Settings;
1511
using Microsoft.UI.Xaml;
1612
using Microsoft.UI.Xaml.Controls;
17-
using Microsoft.UI.Xaml.Controls.Primitives;
1813
using Microsoft.UI.Xaml.Input;
1914
using Microsoft.UI.Xaml.Media.Imaging;
2015
using System;
@@ -99,6 +94,8 @@ public async Task LoadCardThumbnailAsync()
9994

10095
public sealed partial class QuickAccessWidget : HomePageWidget, IWidgetItemModel, INotifyPropertyChanged
10196
{
97+
public IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
98+
10299
public ObservableCollection<FolderCardItem> ItemsAdded = new();
103100

104101
private bool showMultiPaneControls;
@@ -194,14 +191,16 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
194191
Glyph = "\uF113",
195192
GlyphFontFamilyName = "CustomGlyph",
196193
Command = OpenInNewTabCommand,
197-
CommandParameter = item
194+
CommandParameter = item,
195+
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
198196
},
199197
new ContextMenuFlyoutItemViewModel()
200198
{
201199
Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(),
202200
Glyph = "\uE737",
203201
Command = OpenInNewWindowCommand,
204-
CommandParameter = item
202+
CommandParameter = item,
203+
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewWindow
205204
},
206205
new ContextMenuFlyoutItemViewModel()
207206
{
@@ -337,7 +336,7 @@ private async void Button_PointerPressed(object sender, PointerRoutedEventArgs e
337336

338337
private void OpenProperties(FolderCardItem item)
339338
{
340-
CardPropertiesInvoked?.Invoke(this, new QuickAccessCardEventArgs { Item = item.Item });
339+
CardPropertiesInvoked?.Invoke(this, new QuickAccessCardEventArgs { Item = item.Item });
341340
}
342341

343342
public override async void PinToFavorites(WidgetCardItem item)

src/Files.App/ViewModels/SettingsViewModels/AppearanceViewModel.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,40 @@ public bool MoveShellExtensionsToSubMenu
110110
}
111111
}
112112

113-
public bool DisplayEditTagsMenu
113+
public bool ShowEditTagsMenu
114114
{
115-
get => UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu;
115+
get => UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu;
116116
set
117117
{
118-
if (value != UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu)
118+
if (value != UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu)
119119
{
120-
UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu = value;
120+
UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu = value;
121+
OnPropertyChanged();
122+
}
123+
}
124+
}
125+
126+
public bool ShowOpenInNewTab
127+
{
128+
get => UserSettingsService.AppearanceSettingsService.ShowOpenInNewTab;
129+
set
130+
{
131+
if (value != UserSettingsService.AppearanceSettingsService.ShowOpenInNewTab)
132+
{
133+
UserSettingsService.AppearanceSettingsService.ShowOpenInNewTab = value;
134+
OnPropertyChanged();
135+
}
136+
}
137+
}
138+
139+
public bool ShowOpenInNewWindow
140+
{
141+
get => UserSettingsService.AppearanceSettingsService.ShowOpenInNewWindow;
142+
set
143+
{
144+
if (value != UserSettingsService.AppearanceSettingsService.ShowOpenInNewWindow)
145+
{
146+
UserSettingsService.AppearanceSettingsService.ShowOpenInNewWindow = value;
121147
OnPropertyChanged();
122148
}
123149
}

src/Files.App/Views/SettingsPages/Appearance.xaml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,42 @@
174174
FontSize="14"
175175
FontWeight="Medium"
176176
Text="{helpers:ResourceString Name=SettingsContextMenu/Text}" />
177-
178-
<!-- Edit tags -->
179-
<local:SettingsBlockControl Title="{helpers:ResourceString Name=DisplayEditTagsMenu}" HorizontalAlignment="Stretch">
177+
178+
<!-- Context menu options -->
179+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ContextMenuOptions}">
180180
<local:SettingsBlockControl.Icon>
181-
<FontIcon Glyph="&#xE1CB;" />
181+
<FontIcon Glyph="&#xE74C;" />
182182
</local:SettingsBlockControl.Icon>
183-
<ToggleSwitch
184-
AutomationProperties.Name="{helpers:ResourceString Name=DisplayEditTagsMenu}"
185-
IsOn="{x:Bind ViewModel.DisplayEditTagsMenu, Mode=TwoWay}"
186-
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
183+
<local:SettingsBlockControl.ExpandableContent>
184+
<StackPanel>
185+
<!-- Open in new tab -->
186+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowOpenInNewTab}" HorizontalAlignment="Stretch">
187+
<ToggleSwitch
188+
AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenInNewTab}"
189+
IsOn="{x:Bind ViewModel.ShowOpenInNewTab, Mode=TwoWay}"
190+
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
191+
</local:SettingsBlockControl>
192+
193+
<!-- Open in new window -->
194+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowOpenInNewWindow}" HorizontalAlignment="Stretch">
195+
<ToggleSwitch
196+
AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenInNewWindow}"
197+
IsOn="{x:Bind ViewModel.ShowOpenInNewWindow, Mode=TwoWay}"
198+
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
199+
</local:SettingsBlockControl>
200+
201+
<!-- Edit tags -->
202+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowEditTagsMenu}" HorizontalAlignment="Stretch">
203+
<ToggleSwitch
204+
AutomationProperties.Name="{helpers:ResourceString Name=ShowEditTagsMenu}"
205+
IsOn="{x:Bind ViewModel.ShowEditTagsMenu, Mode=TwoWay}"
206+
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
207+
</local:SettingsBlockControl>
208+
</StackPanel>
209+
</local:SettingsBlockControl.ExpandableContent>
187210
</local:SettingsBlockControl>
188211

212+
189213
<!-- Overflow Options -->
190214
<local:SettingsBlockControl Title="{helpers:ResourceString Name=SettingsContextMenuOverflow}" HorizontalAlignment="Stretch">
191215
<local:SettingsBlockControl.Icon>

0 commit comments

Comments
 (0)