Skip to content

Commit

Permalink
Fixed PreferencesSettingsService
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 committed Apr 16, 2023
1 parent 3baf4d2 commit 02ee843
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/Files.App/App.xaml.cs
Expand Up @@ -122,7 +122,7 @@ private static async Task InitializeAppComponentsAsync()
{
var userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
var addItemService = Ioc.Default.GetRequiredService<IAddItemService>();
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 () =>
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/BaseLayout.cs
Expand Up @@ -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());
Expand All @@ -725,7 +725,7 @@ private async Task AddShellMenuItemsAsync(List<ContextMenuFlyoutItemViewModel> 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 &&
Expand Down Expand Up @@ -780,12 +780,12 @@ private async Task AddShellMenuItemsAsync(List<ContextMenuFlyoutItemViewModel> 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;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Files.App/Helpers/ContextFlyoutItemHelper.cs
Expand Up @@ -50,7 +50,7 @@ public static List<ContextMenuFlyoutItemViewModel> Filter(List<ContextMenuFlyout
var overflow = items.Where(x => 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();

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/ShellContextMenuHelper.cs
Expand Up @@ -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())
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs
Expand Up @@ -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;

Expand Down Expand Up @@ -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<FrameworkElement>()
.ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width if the overflow menu setting is disabled

Expand Down Expand Up @@ -185,7 +185,7 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
Text = "OpenInNewPane".GetLocalizedResource(),
Command = OpenInNewPaneCommand,
CommandParameter = item,
ShowItem = userSettingsService.PreferencesSettingsService.ShowOpenInNewPane && isFolder
ShowItem = userSettingsService.GeneralSettingsService.ShowOpenInNewPane && isFolder
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down

0 comments on commit 02ee843

Please sign in to comment.