Skip to content

Feature: Added option to hide the Send To menu #12674

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 8 commits into from
Jun 22, 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
5 changes: 3 additions & 2 deletions src/Files.App/Helpers/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.Commands;
using Files.App.ServicesImplementation.Settings;
using Files.Backend.Helpers;
using Files.Backend.Services;
using Microsoft.UI.Xaml.Media.Imaging;
Expand Down Expand Up @@ -545,7 +546,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
Tag = "SendTo",
CollapseLabel = true,
ShowInSearchPage = true,
ShowItem = itemsSelected
ShowItem = itemsSelected && userSettingsService.GeneralSettingsService.ShowSendToMenu
},
new ContextMenuFlyoutItemViewModel()
{
Expand All @@ -561,7 +562,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
}
},
ShowInSearchPage = true,
ShowItem = itemsSelected
ShowItem = itemsSelected && userSettingsService.GeneralSettingsService.ShowSendToMenu
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down
7 changes: 5 additions & 2 deletions src/Files.App/Helpers/ShellContextMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,13 @@ public static async Task LoadShellMenuItems(
if (openWithItem is not null)
shellMenuItems.Remove(openWithItem);

var sendToItem = showSendToMenu ? shellMenuItems.Where(x => (x.Tag as Win32ContextMenuItem)?.CommandString == "sendto").ToList().FirstOrDefault() : null;
if (sendToItem is not null)
var sendToItem = shellMenuItems.Where(x => (x.Tag as Win32ContextMenuItem)?.CommandString == "sendto").ToList().FirstOrDefault();
if (sendToItem is not null &&
(showSendToMenu || !UserSettingsService.GeneralSettingsService.ShowSendToMenu))
shellMenuItems.Remove(sendToItem);

sendToItem = showSendToMenu && UserSettingsService.GeneralSettingsService.ShowSendToMenu ? sendToItem : null;

if (!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu)
{
var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(shellMenuItems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ public bool ShowEditTagsMenu
set => Set(value);
}

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

public bool ShowOpenInNewTab
{
get => Get(true);
Expand Down Expand Up @@ -246,6 +252,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(ShowFileTagsSection):
case nameof(MoveShellExtensionsToSubMenu):
case nameof(ShowEditTagsMenu):
case nameof(ShowSendToMenu):
case nameof(ShowOpenInNewTab):
case nameof(ShowOpenInNewWindow):
case nameof(ShowOpenInNewPane):
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2391,6 +2391,9 @@
<data name="ShowEditTagsMenu" xml:space="preserve">
<value>Show edit tags flyout</value>
</data>
<data name="ShowSendToMenu" xml:space="preserve">
<value>Show Send To menu</value>
</data>
<data name="ShowOpenInNewTab" xml:space="preserve">
<value>Show option to open folders in a new tab</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
{
Text = "SendTo".GetLocalizedResource(),
Tag = "SendToPlaceholder",
ShowItem = !isFolder
ShowItem = !isFolder && userSettingsService.GeneralSettingsService.ShowSendToMenu
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down
5 changes: 4 additions & 1 deletion src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public sealed partial class RecentFilesWidget : HomePageWidget, IWidgetItemModel

private CancellationTokenSource refreshRecentsCTS;

private readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();

public string WidgetName => nameof(RecentFilesWidget);

public string AutomationProperties => "RecentFilesWidgetAutomationProperties/Name".GetLocalizedResource();
Expand Down Expand Up @@ -157,6 +159,7 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
{
Text = "SendTo".GetLocalizedResource(),
Tag = "SendToPlaceholder",
ShowItem = userSettingsService.GeneralSettingsService.ShowSendToMenu
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down Expand Up @@ -202,7 +205,7 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
Tag = "ItemOverflow",
IsEnabled = false,
}
};
}.Where(x => x.ShowItem).ToList();
}

public async Task RefreshWidget()
Expand Down
13 changes: 13 additions & 0 deletions src/Files.App/ViewModels/Settings/GeneralViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,19 @@ public bool ShowOpenInNewTab
}
}

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

public bool ShowOpenInNewWindow
{
get => UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow;
Expand Down
33 changes: 17 additions & 16 deletions src/Files.App/Views/LayoutModes/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using CommunityToolkit.WinUI.UI;
using Files.App.Filesystem.StorageItems;
using Files.App.Helpers.ContextFlyouts;
using Files.App.UserControls;
using Files.App.UserControls.Menus;
using Files.App.Views;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
Expand Down Expand Up @@ -809,26 +807,29 @@ private async Task AddShellMenuItemsAsync(List<ContextMenuFlyoutItemViewModel> s
}

// Add items to sendto dropdown
var sendToOverflow = contextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton abb && (abb.Tag as string) == "SendToOverflow") as AppBarButton;

var sendTo = contextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton abb && (abb.Tag as string) == "SendTo") as AppBarButton;
if (sendToMenuItem?.LoadSubMenuAction is not null && sendToOverflow is not null && sendTo is not null)
if (UserSettingsService.GeneralSettingsService.ShowSendToMenu)
{
await sendToMenuItem.LoadSubMenuAction();
var sendToSubItems = ItemModelListToContextFlyoutHelper.GetMenuFlyoutItemsFromModel(ShellContextmenuHelper.GetSendToItems(shellMenuItems));
var sendToOverflow = contextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton abb && (abb.Tag as string) == "SendToOverflow") as AppBarButton;

if (sendToSubItems is not null)
var sendTo = contextMenuFlyout.SecondaryCommands.FirstOrDefault(x => x is AppBarButton abb && (abb.Tag as string) == "SendTo") as AppBarButton;
if (sendToMenuItem?.LoadSubMenuAction is not null && sendToOverflow is not null && sendTo is not null)
{
var flyout = (MenuFlyout)sendToOverflow.Flyout;
await sendToMenuItem.LoadSubMenuAction();
var sendToSubItems = ItemModelListToContextFlyoutHelper.GetMenuFlyoutItemsFromModel(ShellContextmenuHelper.GetSendToItems(shellMenuItems));

flyout.Items.Clear();
if (sendToSubItems is not null)
{
var flyout = (MenuFlyout)sendToOverflow.Flyout;

foreach (var item in sendToSubItems)
flyout.Items.Add(item);
flyout.Items.Clear();

foreach (var item in sendToSubItems)
flyout.Items.Add(item);

sendToOverflow.Flyout = flyout;
sendTo.Visibility = Visibility.Collapsed;
sendToOverflow.Visibility = Visibility.Visible;
sendToOverflow.Flyout = flyout;
sendTo.Visibility = Visibility.Collapsed;
sendToOverflow.Visibility = Visibility.Visible;
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/Files.App/Views/Settings/GeneralPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@
IsOn="{x:Bind ViewModel.ShowEditTagsMenu, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Send To -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowSendToMenu}" HorizontalAlignment="Stretch">
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowSendToMenu}"
IsOn="{x:Bind ViewModel.ShowSendToMenu, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>
</StackPanel>
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,16 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
/// </summary>
bool ShowOpenInNewWindow { get; set; }


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

/// <summary>
/// Gets or sets a value indicating whether or not to show the Send To menu.
/// </summary>
bool ShowSendToMenu { get; set; }

/// <summary>
/// Gets or sets a value indicating the default option to resolve conflicts.
/// </summary>
Expand Down