diff --git a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs index e6f73a419648..68104f1a025e 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewPane/BaseOpenInNewPaneAction.cs @@ -18,8 +18,7 @@ public string Description public virtual bool IsExecutable => ContentPageContext.SelectedItem is not null && - ContentPageContext.SelectedItem.IsFolder && - UserSettingsService.GeneralSettingsService.ShowOpenInNewPane; + ContentPageContext.SelectedItem.IsFolder; public virtual bool IsAccessibleGlobally => true; diff --git a/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromHomeAction.cs b/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromHomeAction.cs index e946e6875e00..81a055b06422 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromHomeAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromHomeAction.cs @@ -6,7 +6,6 @@ namespace Files.App.Actions internal sealed class OpenInNewPaneFromHomeAction : BaseOpenInNewPaneAction { public override bool IsExecutable => - UserSettingsService.GeneralSettingsService.ShowOpenInNewPane && HomePageContext.IsAnyItemRightClicked && HomePageContext.RightClickedItem is not null && (HomePageContext.RightClickedItem is WidgetFileTagCardItem fileTagItem diff --git a/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromSidebarAction.cs b/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromSidebarAction.cs index 78280d31a0e2..e688772b57b5 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromSidebarAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewPane/OpenInNewPaneFromSidebarAction.cs @@ -6,7 +6,6 @@ namespace Files.App.Actions internal sealed class OpenInNewPaneFromSidebarAction : BaseOpenInNewPaneAction { public override bool IsExecutable => - UserSettingsService.GeneralSettingsService.ShowOpenInNewPane && SidebarContext.IsItemRightClicked && SidebarContext.RightClickedItem is not null && SidebarContext.RightClickedItem.MenuOptions.IsLocationItem; diff --git a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs index b6463457223c..4845e01b159b 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewTab/BaseOpenInNewTabAction.cs @@ -27,8 +27,7 @@ ContentPageContext.ShellPage is not null && ContentPageContext.ShellPage.SlimContentPage is not null && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && - ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count && - UserSettingsService.GeneralSettingsService.ShowOpenInNewTab; + ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count; public BaseOpenInNewTabAction() { diff --git a/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromHomeAction.cs b/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromHomeAction.cs index c4648ba08754..d05999e6d899 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromHomeAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromHomeAction.cs @@ -6,7 +6,6 @@ namespace Files.App.Actions internal sealed class OpenInNewTabFromHomeAction : BaseOpenInNewTabAction { public override bool IsExecutable => - UserSettingsService.GeneralSettingsService.ShowOpenInNewTab && HomePageContext.IsAnyItemRightClicked && HomePageContext.RightClickedItem is not null && (HomePageContext.RightClickedItem is WidgetFileTagCardItem fileTagItem diff --git a/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromSidebarAction.cs b/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromSidebarAction.cs index 20947764c9a9..156de0e83eb1 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromSidebarAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewTab/OpenInNewTabFromSidebarAction.cs @@ -6,7 +6,6 @@ namespace Files.App.Actions internal sealed class OpenInNewTabFromSidebarAction : BaseOpenInNewTabAction { public override bool IsExecutable => - UserSettingsService.GeneralSettingsService.ShowOpenInNewTab && SidebarContext.IsItemRightClicked && SidebarContext.RightClickedItem is not null && SidebarContext.RightClickedItem.MenuOptions.IsLocationItem; diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs index fbd023ed5c58..fd477288334c 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs @@ -32,8 +32,7 @@ ContentPageContext.ShellPage is not null && ContentPageContext.ShellPage.SlimContentPage is not null && ContentPageContext.SelectedItems.Count is not 0 && ContentPageContext.SelectedItems.Count <= 5 && - ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count && - UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow; + ContentPageContext.SelectedItems.Count(x => x.IsFolder) == ContentPageContext.SelectedItems.Count; public BaseOpenInNewWindowAction() { diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromHomeAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromHomeAction.cs index 2b419f3f6fe2..e02154a4eb6d 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromHomeAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromHomeAction.cs @@ -9,7 +9,6 @@ public override HotKey HotKey => HotKey.None; public override bool IsExecutable => - UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow && HomePageContext.IsAnyItemRightClicked && HomePageContext.RightClickedItem is not null && (HomePageContext.RightClickedItem is WidgetFileTagCardItem fileTagItem diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromSidebarAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromSidebarAction.cs index de2f8ab18417..e72aef69351d 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromSidebarAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/OpenInNewWindowFromSidebarAction.cs @@ -9,7 +9,6 @@ public override HotKey HotKey => HotKey.None; public override bool IsExecutable => - UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow && SidebarContext.IsItemRightClicked && SidebarContext.RightClickedItem is not null && SidebarContext.RightClickedItem.MenuOptions.IsLocationItem; diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index dfa20e6d538f..2c282955ac97 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -407,9 +407,18 @@ public static List GetBaseItemMenuItems( ShowItem = itemsSelected && showOpenItemWith }, new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenFileLocation).Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewTabAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewWindowAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewPaneAction).Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewTabAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewWindowAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewPaneAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane + }.Build(), new ContextMenuFlyoutItemViewModel() { Text = "BaseLayoutItemContextFlyoutSetAs/Text".GetLocalizedResource(), diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index ad7c4d36aedf..e6f76374ad94 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -254,9 +254,6 @@ public SidebarViewModel() HideSectionCommand = new RelayCommand(HideSection); UnpinItemCommand = new RelayCommand(UnpinItem); PinItemCommand = new RelayCommand(PinItem); - OpenInNewTabCommand = new AsyncRelayCommand(OpenInNewTabAsync); - OpenInNewWindowCommand = new AsyncRelayCommand(OpenInNewWindowAsync); - OpenInNewPaneCommand = new AsyncRelayCommand(OpenInNewPaneAsync); EjectDeviceCommand = new RelayCommand(EjectDevice); OpenPropertiesCommand = new RelayCommand(OpenProperties); ReorderItemsCommand = new AsyncRelayCommand(ReorderItemsAsync); @@ -830,41 +827,12 @@ public async void HandleItemInvokedAsync(object item, PointerUpdateKind pointerU private ICommand UnpinItemCommand { get; } - private ICommand OpenInNewTabCommand { get; } - - private ICommand OpenInNewWindowCommand { get; } - - private ICommand OpenInNewPaneCommand { get; } - private ICommand EjectDeviceCommand { get; } private ICommand OpenPropertiesCommand { get; } private ICommand ReorderItemsCommand { get; } - private async Task OpenInNewPaneAsync() - { - if (await DriveHelpers.CheckEmptyDrive(rightClickedItem.Path)) - return; - PaneHolder.OpenSecondaryPane(rightClickedItem.Path); - } - - private async Task OpenInNewTabAsync() - { - if (await DriveHelpers.CheckEmptyDrive(rightClickedItem.Path)) - return; - - await NavigationHelpers.OpenPathInNewTab(rightClickedItem.Path, false); - } - - private async Task OpenInNewWindowAsync() - { - if (await DriveHelpers.CheckEmptyDrive(rightClickedItem.Path)) - return; - - await NavigationHelpers.OpenPathInNewWindowAsync(rightClickedItem.Path); - } - private void PinItem() { if (rightClickedItem is DriveItem) @@ -971,14 +939,14 @@ private List GetLocationItemMenuItems(INavigatio { new ContextMenuFlyoutItemViewModel() { - Text = "SideBarCreateNewLibrary/Text".GetLocalizedResource(), + Text = Strings.SideBarCreateNewLibrary_Text.GetLocalizedResource(), Glyph = "\uE710", Command = CreateLibraryCommand, ShowItem = options.IsLibrariesHeader }, new ContextMenuFlyoutItemViewModel() { - Text = "SideBarRestoreLibraries/Text".GetLocalizedResource(), + Text = Strings.SideBarRestoreLibraries_Text.GetLocalizedResource(), Glyph = "\uE10E", Command = RestoreLibrariesCommand, ShowItem = options.IsLibrariesHeader @@ -991,9 +959,18 @@ private List GetLocationItemMenuItems(INavigatio { IsVisible = options.ShowEmptyRecycleBin, }.Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewTabFromSidebarAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewWindowFromSidebarAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewPaneFromSidebarAction).Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewTabFromSidebarAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewWindowFromSidebarAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenInNewPaneFromSidebarAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane + }.Build(), new ContextMenuFlyoutItemViewModel() { Text = "PinFolderToSidebar".GetLocalizedResource(), diff --git a/src/Files.App/ViewModels/UserControls/Widgets/BaseWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/BaseWidgetViewModel.cs index 32432770764c..80a4176834f2 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/BaseWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/BaseWidgetViewModel.cs @@ -37,8 +37,6 @@ public abstract class BaseWidgetViewModel : ObservableObject protected ICommand RemoveRecentItemCommand { get; set; } = null!; protected ICommand ClearAllItemsCommand { get; set; } = null!; protected ICommand OpenFileLocationCommand { get; set; } = null!; - protected ICommand OpenInNewTabCommand { get; set; } = null!; - protected ICommand OpenInNewWindowCommand { get; set; } = null!; protected ICommand OpenPropertiesCommand { get; set; } = null!; protected ICommand PinToSidebarCommand { get; set; } = null!; protected ICommand UnpinFromSidebarCommand { get; set; } = null!; @@ -100,16 +98,6 @@ widgetCardItem.DataContext is not WidgetCardItem item || // Command methods - public async Task ExecuteOpenInNewTabCommand(WidgetCardItem? item) - { - await NavigationHelpers.OpenPathInNewTab(item?.Path ?? string.Empty, false); - } - - public async Task ExecuteOpenInNewWindowCommand(WidgetCardItem? item) - { - await NavigationHelpers.OpenPathInNewWindowAsync(item?.Path ?? string.Empty); - } - public virtual async Task ExecutePinToSidebarCommand(WidgetCardItem? item) { await QuickAccessService.PinToSidebarAsync(item?.Path ?? string.Empty); diff --git a/src/Files.App/ViewModels/UserControls/Widgets/DrivesWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/DrivesWidgetViewModel.cs index 508ea5ac9283..2c061e8fdaa1 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/DrivesWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/DrivesWidgetViewModel.cs @@ -29,7 +29,6 @@ public sealed class DrivesWidgetViewModel : BaseWidgetViewModel, IWidgetViewMode // Commands private ICommand EjectDeviceCommand { get; } = null!; - private ICommand OpenInNewPaneCommand { get; } = null!; private ICommand DisconnectNetworkDriveCommand { get; } = null!; // Constructor @@ -40,12 +39,9 @@ public DrivesWidgetViewModel() DrivesViewModel.Drives.CollectionChanged += Drives_CollectionChanged; - OpenInNewTabCommand = new AsyncRelayCommand(ExecuteOpenInNewTabCommand); - OpenInNewWindowCommand = new AsyncRelayCommand(ExecuteOpenInNewWindowCommand); PinToSidebarCommand = new AsyncRelayCommand(ExecutePinToSidebarCommand); UnpinFromSidebarCommand = new AsyncRelayCommand(ExecuteUnpinFromSidebarCommand); EjectDeviceCommand = new RelayCommand(ExecuteEjectDeviceCommand); - OpenInNewPaneCommand = new AsyncRelayCommand(ExecuteOpenInNewPaneCommand); OpenPropertiesCommand = new RelayCommand(ExecuteOpenPropertiesCommand); DisconnectNetworkDriveCommand = new RelayCommand(ExecuteDisconnectNetworkDriveCommand); } @@ -92,9 +88,18 @@ public override List GetItemMenuItems(WidgetCard return new List() { - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewTabFromHomeAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewWindowFromHomeAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewPaneFromHomeAction).Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewTabFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewWindowFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewPaneFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane + }.Build(), new() { Text = Strings.PinFolderToSidebar.GetLocalizedResource(), @@ -174,14 +179,6 @@ private void ExecuteEjectDeviceCommand(WidgetDriveCardItem? item) DriveHelpers.EjectDeviceAsync(item.Item.Path); } - private async Task ExecuteOpenInNewPaneCommand(WidgetDriveCardItem? item) - { - if (item is null || await DriveHelpers.CheckEmptyDrive(item.Item.Path)) - return; - - ContentPageContext.ShellPage!.PaneHolder?.OpenSecondaryPane(item.Item.Path); - } - private void ExecuteOpenPropertiesCommand(WidgetDriveCardItem? item) { if (!HomePageContext.IsAnyItemRightClicked || item is null) diff --git a/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs index 75e748e13618..cc1d12013c18 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/FileTagsWidgetViewModel.cs @@ -3,7 +3,6 @@ using Microsoft.UI.Xaml.Controls; using System.IO; -using System.Windows.Input; using Windows.Storage; namespace Files.App.ViewModels.UserControls.Widgets @@ -28,9 +27,6 @@ public sealed partial class FileTagsWidgetViewModel : BaseWidgetViewModel, IWidg public static event EventHandler>? SelectedTaggedItemsChanged; - // Commands - - private ICommand OpenInNewPaneCommand { get; set; } = null!; // Constructor @@ -38,12 +34,9 @@ public FileTagsWidgetViewModel() { _ = InitializeWidget(); - OpenInNewTabCommand = new AsyncRelayCommand(ExecuteOpenInNewTabCommand); - OpenInNewWindowCommand = new AsyncRelayCommand(ExecuteOpenInNewWindowCommand); PinToSidebarCommand = new AsyncRelayCommand(ExecutePinToSidebarCommand); UnpinFromSidebarCommand = new AsyncRelayCommand(ExecuteUnpinFromSidebarCommand); OpenFileLocationCommand = new RelayCommand(ExecuteOpenFileLocationCommand); - OpenInNewPaneCommand = new RelayCommand(ExecuteOpenInNewPaneCommand); OpenPropertiesCommand = new RelayCommand(ExecuteOpenPropertiesCommand); } @@ -73,9 +66,18 @@ public override List GetItemMenuItems(WidgetCard { return new List() { - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewTabFromHomeAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewWindowFromHomeAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewPaneFromHomeAction).Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewTabFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewWindowFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewPaneFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane + }.Build(), new() { Text = "OpenWith".GetLocalizedResource(), @@ -172,11 +174,6 @@ private void ExecuteOpenPropertiesCommand(WidgetCardItem? item) flyout!.Closed += flyoutClosed; } - private void ExecuteOpenInNewPaneCommand(WidgetCardItem? item) - { - ContentPageContext.ShellPage!.PaneHolder?.OpenSecondaryPane(item?.Path ?? string.Empty); - } - private void ExecuteOpenFileLocationCommand(WidgetCardItem? item) { var itemPath = Directory.GetParent(item?.Path ?? string.Empty)?.FullName ?? string.Empty; diff --git a/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs index 25e3daa4c489..b12e4d175758 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/NetworkLocationsWidgetViewModel.cs @@ -41,7 +41,6 @@ public bool IsNoNetworkLocations // Commands private ICommand EjectDeviceCommand { get; } = null!; - private ICommand OpenInNewPaneCommand { get; } = null!; private ICommand MapNetworkDriveCommand { get; } = null!; private ICommand DisconnectNetworkDriveCommand { get; } = null!; @@ -55,12 +54,9 @@ public NetworkLocationsWidgetViewModel() DrivesViewModel.Drives.CollectionChanged += Drives_CollectionChanged; NetworkService.Shortcuts.CollectionChanged += Shortcuts_CollectionChanged; - OpenInNewTabCommand = new AsyncRelayCommand(ExecuteOpenInNewTabCommand); - OpenInNewWindowCommand = new AsyncRelayCommand(ExecuteOpenInNewWindowCommand); PinToSidebarCommand = new AsyncRelayCommand(ExecutePinToSidebarCommand); UnpinFromSidebarCommand = new AsyncRelayCommand(ExecuteUnpinFromSidebarCommand); EjectDeviceCommand = new RelayCommand(ExecuteEjectDeviceCommand); - OpenInNewPaneCommand = new AsyncRelayCommand(ExecuteOpenInNewPaneCommand); OpenPropertiesCommand = new RelayCommand(ExecuteOpenPropertiesCommand); DisconnectNetworkDriveCommand = new RelayCommand(ExecuteDisconnectNetworkDriveCommand); MapNetworkDriveCommand = new AsyncRelayCommand(ExecuteMapNetworkDriveCommand); @@ -105,29 +101,18 @@ public override List GetItemMenuItems(WidgetCard return new List() { - new() + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewTabFromHomeAction) { - Text = Strings.OpenInNewTab.GetLocalizedResource(), - ThemedIconModel = new ThemedIconModel() { ThemedIconStyle = "App.ThemedIcons.OpenInTab" }, - Command = OpenInNewTabCommand, - CommandParameter = item, - ShowItem = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab - }, - new() + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewWindowFromHomeAction) { - Text = Strings.OpenInNewWindow.GetLocalizedResource(), - ThemedIconModel = new ThemedIconModel() { ThemedIconStyle = "App.ThemedIcons.OpenInWindow" }, - Command = OpenInNewWindowCommand, - CommandParameter = item, - ShowItem = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow - }, - new() + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewPaneFromHomeAction) { - Text = Strings.OpenInNewPane.GetLocalizedResource(), - Command = OpenInNewPaneCommand, - CommandParameter = item, - ShowItem = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane - }, + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane + }.Build(), new() { Text = Strings.PinFolderToSidebar.GetLocalizedResource(), @@ -203,14 +188,6 @@ private void ExecuteEjectDeviceCommand(WidgetDriveCardItem? item) DriveHelpers.EjectDeviceAsync(item.Item.Path); } - private async Task ExecuteOpenInNewPaneCommand(WidgetDriveCardItem? item) - { - if (item is null || await DriveHelpers.CheckEmptyDrive(item.Item.Path)) - return; - - ContentPageContext.ShellPage!.PaneHolder?.OpenSecondaryPane(item.Item.Path); - } - private Task ExecuteMapNetworkDriveCommand() { return NetworkService.OpenMapNetworkDriveDialogAsync(); diff --git a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs index adedd220f698..86114c5e72ff 100644 --- a/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Widgets/QuickAccessWidgetViewModel.cs @@ -28,10 +28,6 @@ public sealed class QuickAccessWidgetViewModel : BaseWidgetViewModel, IWidgetVie public bool ShowMenuFlyout => false; public MenuFlyoutItem? MenuFlyoutItem => null; - // Commands - - public ICommand OpenInNewPaneCommand { get; set; } = null!; - // Constructor public QuickAccessWidgetViewModel() @@ -40,9 +36,6 @@ public QuickAccessWidgetViewModel() Items.CollectionChanged += Items_CollectionChanged; - OpenInNewTabCommand = new AsyncRelayCommand(ExecuteOpenInNewTabCommand); - OpenInNewWindowCommand = new AsyncRelayCommand(ExecuteOpenInNewWindowCommand); - OpenInNewPaneCommand = new RelayCommand(ExecuteOpenInNewPaneCommand); OpenPropertiesCommand = new RelayCommand(ExecuteOpenPropertiesCommand); PinToSidebarCommand = new AsyncRelayCommand(ExecutePinToSidebarCommand); UnpinFromSidebarCommand = new AsyncRelayCommand(ExecuteUnpinFromSidebarCommand); @@ -67,9 +60,18 @@ public override List GetItemMenuItems(WidgetCard { return new List() { - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewTabFromHomeAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewWindowFromHomeAction).Build(), - new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewPaneFromHomeAction).Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewTabFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewTab + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewWindowFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewWindow + }.Build(), + new ContextMenuFlyoutItemViewModelBuilder(CommandManager.OpenInNewPaneFromHomeAction) + { + IsVisible = UserSettingsService.GeneralSettingsService.ShowOpenInNewPane + }.Build(), new() { Text = "PinFolderToSidebar".GetLocalizedResource(), @@ -258,14 +260,6 @@ public override async Task ExecuteUnpinFromSidebarCommand(WidgetCardItem? item) ModifyItemAsync(this, new(new[] { item.Path }, false)); } - private void ExecuteOpenInNewPaneCommand(WidgetFolderCardItem? item) - { - if (item is null || item.Path is null) - return; - - ContentPageContext.ShellPage!.PaneHolder?.OpenSecondaryPane(item.Path); - } - private void ExecuteOpenPropertiesCommand(WidgetFolderCardItem? item) { if (!HomePageContext.IsAnyItemRightClicked || item is null || item.Item is null)