From 02ee8435c5ad77d467d0850a33e410a67c366197 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 16 Apr 2023 13:02:05 -0400 Subject: [PATCH] Fixed PreferencesSettingsService --- src/Files.App/App.xaml.cs | 4 ++-- src/Files.App/BaseLayout.cs | 8 ++++---- src/Files.App/Helpers/ContextFlyoutItemHelper.cs | 12 ++++++------ src/Files.App/Helpers/ShellContextMenuHelper.cs | 4 ++-- .../UserControls/Widgets/FileTagsWidget.xaml.cs | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Files.App/App.xaml.cs b/src/Files.App/App.xaml.cs index 1af74353c9a6..7e301a5c8d2a 100644 --- a/src/Files.App/App.xaml.cs +++ b/src/Files.App/App.xaml.cs @@ -122,7 +122,7 @@ private static async Task InitializeAppComponentsAsync() { var userSettingsService = Ioc.Default.GetRequiredService(); var addItemService = Ioc.Default.GetRequiredService(); - var generalSettingsService = userSettingsService.PreferencesSettingsService; + var generalSettingsService = userSettingsService.GeneralSettingsService; // Start off a list of tasks we need to run before we can continue startup await Task.Run(async () => @@ -341,7 +341,7 @@ public static void SaveSessionTabs() bundlesSettingsService.FlushSettings(); - userSettingsService.PreferencesSettingsService.LastSessionTabList = MainPageViewModel.AppInstances.DefaultIfEmpty().Select(tab => + userSettingsService.GeneralSettingsService.LastSessionTabList = MainPageViewModel.AppInstances.DefaultIfEmpty().Select(tab => { if (tab is not null && tab.TabItemArguments is not null) { diff --git a/src/Files.App/BaseLayout.cs b/src/Files.App/BaseLayout.cs index fbde2c345616..de708ffc5b4f 100644 --- a/src/Files.App/BaseLayout.cs +++ b/src/Files.App/BaseLayout.cs @@ -705,7 +705,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.PreferencesSettingsService.ShowEditTagsMenu) + if (!UserSettingsService.GeneralSettingsService.ShowEditTagsMenu) return; contextMenu.SecondaryCommands.Insert(index, new AppBarSeparator()); @@ -725,7 +725,7 @@ private async Task AddShellMenuItemsAsync(List s var openWithMenuItem = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem { CommandString: "openas" }); var sendToMenuItem = shellMenuItems.FirstOrDefault(x => x.Tag is Win32ContextMenuItem { CommandString: "sendto" }); var shellMenuItemsFiltered = shellMenuItems.Where(x => x != openWithMenuItem && x != sendToMenuItem).ToList(); - var mainShellMenuItems = shellMenuItemsFiltered.RemoveFrom(!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu ? int.MaxValue : shiftPressed ? 6 : 0); + var mainShellMenuItems = shellMenuItemsFiltered.RemoveFrom(!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu ? int.MaxValue : shiftPressed ? 6 : 0); var overflowShellMenuItemsUnfiltered = shellMenuItemsFiltered.Except(mainShellMenuItems).ToList(); var overflowShellMenuItems = overflowShellMenuItemsUnfiltered.Where( (x, i) => (x.ItemType == ItemType.Separator && @@ -780,12 +780,12 @@ private async Task AddShellMenuItemsAsync(List s index++; } - if (overflowItemFlyout.Items.Count > 0 && UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) + if (overflowItemFlyout.Items.Count > 0 && UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu) { overflowItem.Label = "ShowMoreOptions".GetLocalizedResource(); overflowItem.IsEnabled = true; } - else if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) + else if (!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu) overflowItem.Visibility = Visibility.Collapsed; } } diff --git a/src/Files.App/Helpers/ContextFlyoutItemHelper.cs b/src/Files.App/Helpers/ContextFlyoutItemHelper.cs index abac3d7c5e25..0e8a534295b2 100644 --- a/src/Files.App/Helpers/ContextFlyoutItemHelper.cs +++ b/src/Files.App/Helpers/ContextFlyoutItemHelper.cs @@ -50,7 +50,7 @@ public static List Filter(List x.ID == "ItemOverflow").FirstOrDefault(); if (overflow is not null) { - if (!shiftPressed && userSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) // items with ShowOnShift to overflow menu + if (!shiftPressed && userSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu) // items with ShowOnShift to overflow menu { var overflowItems = items.Where(x => x.ShowOnShift).ToList(); @@ -273,7 +273,7 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi OpacityIconStyle = "ColorIconOpenInNewTab" }, Command = commandsViewModel.OpenDirectoryInNewTabCommand, - ShowItem = itemsSelected && selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab, + ShowItem = itemsSelected && selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.GeneralSettingsService.ShowOpenInNewTab, ShowInSearchPage = true, ShowInFtpPage = true, ShowInZipPage = true, @@ -286,7 +286,7 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi OpacityIconStyle = "ColorIconOpenInNewWindow" }, Command = commandsViewModel.OpenInNewWindowItemCommand, - ShowItem = itemsSelected && selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.PreferencesSettingsService.ShowOpenInNewWindow, + ShowItem = itemsSelected && selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.GeneralSettingsService.ShowOpenInNewWindow, ShowInSearchPage = true, ShowInFtpPage = true, ShowInZipPage = true, @@ -295,7 +295,7 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi { Text = "OpenInNewPane".GetLocalizedResource(), Command = commandsViewModel.OpenDirectoryInNewPaneCommand, - ShowItem = itemsSelected && userSettingsService.PreferencesSettingsService.ShowOpenInNewPane && areAllItemsFolders, + ShowItem = itemsSelected && userSettingsService.GeneralSettingsService.ShowOpenInNewPane && areAllItemsFolders, SingleItemOnly = true, ShowInSearchPage = true, ShowInFtpPage = true, @@ -398,11 +398,11 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi new ContextMenuFlyoutItemViewModelBuilder(commands.OpenParentFolder).Build(), new ContextMenuFlyoutItemViewModelBuilder(commands.PinItemToFavorites) { - IsVisible = commands.PinItemToFavorites.IsExecutable && userSettingsService.PreferencesSettingsService.ShowFavoritesSection, + IsVisible = commands.PinItemToFavorites.IsExecutable && userSettingsService.GeneralSettingsService.ShowFavoritesSection, }.Build(), new ContextMenuFlyoutItemViewModelBuilder(commands.UnpinItemFromFavorites) { - IsVisible = commands.UnpinItemFromFavorites.IsExecutable && userSettingsService.PreferencesSettingsService.ShowFavoritesSection, + IsVisible = commands.UnpinItemFromFavorites.IsExecutable && userSettingsService.GeneralSettingsService.ShowFavoritesSection, }.Build(), new ContextMenuFlyoutItemViewModelBuilder(commands.PinToStart) { diff --git a/src/Files.App/Helpers/ShellContextMenuHelper.cs b/src/Files.App/Helpers/ShellContextMenuHelper.cs index 451f25a20859..76281d62ea44 100644 --- a/src/Files.App/Helpers/ShellContextMenuHelper.cs +++ b/src/Files.App/Helpers/ShellContextMenuHelper.cs @@ -265,7 +265,7 @@ async void InvokeShellMenuItem(ContextMenu contextMenu, object? tag) if (sendToItem is not null) shellMenuItems.Remove(sendToItem); - if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) + if (!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu) { var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(shellMenuItems); if (secondaryElements.Any()) @@ -340,7 +340,7 @@ async void InvokeShellMenuItem(ContextMenu contextMenu, object? tag) shellMenuItems.Where(x => x.LoadSubMenuAction is not null).ForEach(async x => { await x.LoadSubMenuAction.Invoke(); - if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) + if (!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu) { AddItemsToMainMenu(itemContextMenuFlyout.SecondaryCommands, x); } diff --git a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs index af049a26ba7f..25f21f498b6b 100644 --- a/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs @@ -50,7 +50,7 @@ public FileTagsWidgetViewModel ViewModel public string AutomationProperties => "FileTags".GetLocalizedResource(); - public bool IsWidgetSettingEnabled => UserSettingsService.PreferencesSettingsService.ShowFileTagsWidget; + public bool IsWidgetSettingEnabled => UserSettingsService.GeneralSettingsService.ShowFileTagsWidget; public bool ShowMenuFlyout => false; @@ -118,7 +118,7 @@ private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e) var menuItems = GetItemMenuItems(item, QuickAccessService.IsItemPinned(item.Path), item.IsFolder); var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(menuItems); - if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) + if (!UserSettingsService.GeneralSettingsService.MoveShellExtensionsToSubMenu) secondaryElements.OfType() .ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width if the overflow menu setting is disabled @@ -185,7 +185,7 @@ public override List GetItemMenuItems(WidgetCard Text = "OpenInNewPane".GetLocalizedResource(), Command = OpenInNewPaneCommand, CommandParameter = item, - ShowItem = userSettingsService.PreferencesSettingsService.ShowOpenInNewPane && isFolder + ShowItem = userSettingsService.GeneralSettingsService.ShowOpenInNewPane && isFolder }, new ContextMenuFlyoutItemViewModel() {