Skip to content

Feature: Added support for hiding open in new tab/window options #11285

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

Merged
merged 4 commits into from
Feb 14, 2023
Merged
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
13 changes: 0 additions & 13 deletions builds/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ steps:
TargetFolder: '$(Build.SourcesDirectory)\src\Files.App\Resources'
overWrite: true

- task: DownloadSecureFile@1
name: appCenterDevKey
displayName: 'Download AppCenter Dev Key'
inputs:
secureFile: 'AppCenterKey.txt'

- task: CopyFiles@2
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: '$(appCenterDevKey.secureFilePath)'
TargetFolder: '$(Build.SourcesDirectory)\src\Files.App\Resources'
overWrite: true

- task: UseDotNet@2
inputs:
packageType: sdk
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ private void AddNewFileTagsToMenu(CommandBarFlyout contextMenu)
index = index >= 0 ? index : contextMenu.SecondaryCommands.Count;

// Only show the edit tags flyout if settings is enabled
if (!UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu)
if (!UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu)
return;

contextMenu.SecondaryCommands.Insert(index, new AppBarSeparator());
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Helpers/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.System;
using Files.App.ServicesImplementation.Settings;

namespace Files.App.Helpers
{
Expand Down Expand Up @@ -739,7 +740,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
Glyph = "\uF113",
GlyphFontFamilyName = "CustomGlyph",
Command = commandsViewModel.OpenDirectoryInNewTabCommand,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab,
ShowInSearchPage = true,
ShowInFtpPage = true,
ShowInZipPage = true,
Expand All @@ -749,10 +750,9 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
Text = "BaseLayoutItemContextFlyoutOpenInNewWindow/Text".GetLocalizedResource(),
Glyph = "\uE737",
Command = commandsViewModel.OpenInNewWindowItemCommand,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.AppearanceSettingsService.ShowOpenInNewWindow,
ShowInSearchPage = true,
ShowInFtpPage = true,
ShowOnShift = true,
ShowInZipPage = true,
},
new ContextMenuFlyoutItemViewModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,19 @@ public bool MoveShellExtensionsToSubMenu
set => Set(value);
}

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

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

public bool ShowOpenInNewWindow
{
get => Get(true);
set => Set(value);
Expand All @@ -89,7 +101,9 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(AppThemeSidebarBackgroundColor):
case nameof(AppThemeFileAreaBackgroundColor):
case nameof(MoveShellExtensionsToSubMenu):
case nameof(DisplayEditTagsMenu):
case nameof(ShowEditTagsMenu):
case nameof(ShowOpenInNewTab):
case nameof(ShowOpenInNewWindow):
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
break;
}
Expand Down
13 changes: 11 additions & 2 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2895,8 +2895,14 @@
<data name="BundlesBeingRemovedTitle" xml:space="preserve">
<value>Bundles will be retiring in a future update 📎</value>
</data>
<data name="DisplayEditTagsMenu" xml:space="preserve">
<value>Display the edit tags flyout</value>
<data name="ShowEditTagsMenu" xml:space="preserve">
<value>Show edit tags flyout</value>
</data>
<data name="ShowOpenInNewTab" xml:space="preserve">
<value>Show option to open folders in a new tab</value>
</data>
<data name="ShowOpenInNewWindow" xml:space="preserve">
<value>Show option to open folders in a new window</value>
</data>
<data name="QuickAccess" xml:space="preserve">
<value>Quick access</value>
Expand Down Expand Up @@ -2931,4 +2937,7 @@
<data name="LoadingMoreOptions" xml:space="preserve">
<value>Loading more options...</value>
</data>
<data name="ContextMenuOptions" xml:space="preserve">
<value>Context menu options</value>
</data>
</root>
4 changes: 2 additions & 2 deletions src/Files.App/UserControls/SidebarControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
Glyph = "\uF113",
GlyphFontFamilyName = "CustomGlyph",
Command = OpenInNewTabCommand,
ShowItem = options.IsLocationItem
ShowItem = options.IsLocationItem && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(),
Glyph = "\uE737",
Command = OpenInNewWindowCommand,
ShowItem = options.IsLocationItem
ShowItem = options.IsLocationItem && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down
10 changes: 7 additions & 3 deletions src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public async Task LoadCardThumbnailAsync()
}

public sealed partial class DrivesWidget : HomePageWidget, IWidgetItemModel, INotifyPropertyChanged
{
{
public IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

public delegate void DrivesWidgetInvokedEventHandler(object sender, DrivesWidgetInvokedEventArgs e);

public event DrivesWidgetInvokedEventHandler DrivesWidgetInvoked;
Expand Down Expand Up @@ -163,14 +165,16 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
Glyph = "\uF113",
GlyphFontFamilyName = "CustomGlyph",
Command = OpenInNewTabCommand,
CommandParameter = item
CommandParameter = item,
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(),
Glyph = "\uE737",
Command = OpenInNewWindowCommand,
CommandParameter = item
CommandParameter = item,
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewWindow
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down
17 changes: 8 additions & 9 deletions src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI;
using CommunityToolkit.WinUI.UI;
using Files.App.DataModels.NavigationControlItems;
using Files.App.Extensions;
using Files.App.Filesystem;
using Files.App.Helpers;
using Files.App.Helpers.ContextFlyouts;
using Files.App.ViewModels;
using Files.App.ViewModels.Widgets;
using Files.Shared.Extensions;
using Microsoft.UI.Input;
using Files.Backend.Services.Settings;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media.Imaging;
using System;
Expand Down Expand Up @@ -99,6 +94,8 @@ public async Task LoadCardThumbnailAsync()

public sealed partial class QuickAccessWidget : HomePageWidget, IWidgetItemModel, INotifyPropertyChanged
{
public IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

public ObservableCollection<FolderCardItem> ItemsAdded = new();

private bool showMultiPaneControls;
Expand Down Expand Up @@ -194,14 +191,16 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
Glyph = "\uF113",
GlyphFontFamilyName = "CustomGlyph",
Command = OpenInNewTabCommand,
CommandParameter = item
CommandParameter = item,
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(),
Glyph = "\uE737",
Command = OpenInNewWindowCommand,
CommandParameter = item
CommandParameter = item,
ShowItem = userSettingsService.AppearanceSettingsService.ShowOpenInNewWindow
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down Expand Up @@ -337,7 +336,7 @@ private async void Button_PointerPressed(object sender, PointerRoutedEventArgs e

private void OpenProperties(FolderCardItem item)
{
CardPropertiesInvoked?.Invoke(this, new QuickAccessCardEventArgs { Item = item.Item });
CardPropertiesInvoked?.Invoke(this, new QuickAccessCardEventArgs { Item = item.Item });
}

public override async void PinToFavorites(WidgetCardItem item)
Expand Down
34 changes: 30 additions & 4 deletions src/Files.App/ViewModels/SettingsViewModels/AppearanceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,40 @@ public bool MoveShellExtensionsToSubMenu
}
}

public bool DisplayEditTagsMenu
public bool ShowEditTagsMenu
{
get => UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu;
get => UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu;
set
{
if (value != UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu)
if (value != UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu)
{
UserSettingsService.AppearanceSettingsService.DisplayEditTagsMenu = value;
UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu = value;
OnPropertyChanged();
}
}
}

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

public bool ShowOpenInNewWindow
{
get => UserSettingsService.AppearanceSettingsService.ShowOpenInNewWindow;
set
{
if (value != UserSettingsService.AppearanceSettingsService.ShowOpenInNewWindow)
{
UserSettingsService.AppearanceSettingsService.ShowOpenInNewWindow = value;
OnPropertyChanged();
}
}
Expand Down
40 changes: 32 additions & 8 deletions src/Files.App/Views/SettingsPages/Appearance.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,42 @@
FontSize="14"
FontWeight="Medium"
Text="{helpers:ResourceString Name=SettingsContextMenu/Text}" />

<!-- Edit tags -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=DisplayEditTagsMenu}" HorizontalAlignment="Stretch">
<!-- Context menu options -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ContextMenuOptions}">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE1CB;" />
<FontIcon Glyph="&#xE74C;" />
</local:SettingsBlockControl.Icon>
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=DisplayEditTagsMenu}"
IsOn="{x:Bind ViewModel.DisplayEditTagsMenu, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
<local:SettingsBlockControl.ExpandableContent>
<StackPanel>
<!-- Open in new tab -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowOpenInNewTab}" HorizontalAlignment="Stretch">
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenInNewTab}"
IsOn="{x:Bind ViewModel.ShowOpenInNewTab, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Open in new window -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowOpenInNewWindow}" HorizontalAlignment="Stretch">
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowOpenInNewWindow}"
IsOn="{x:Bind ViewModel.ShowOpenInNewWindow, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Edit tags -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowEditTagsMenu}" HorizontalAlignment="Stretch">
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowEditTagsMenu}"
IsOn="{x:Bind ViewModel.ShowEditTagsMenu, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>
</StackPanel>
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>


<!-- Overflow Options -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=SettingsContextMenuOverflow}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public interface IAppearanceSettingsService : IBaseSettingsService, INotifyPrope
/// <summary>
/// Gets or sets a value indicating whether or not to show the edit tags menu.
/// </summary>
bool DisplayEditTagsMenu { get; set; }
bool ShowEditTagsMenu { get; set; }

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

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