Skip to content

Commit

Permalink
Feature: Renamed Preferences to General (#12086)
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisFriedmann committed Apr 16, 2023
1 parent 025692a commit 0a4985b
Show file tree
Hide file tree
Showing 34 changed files with 214 additions and 217 deletions.
14 changes: 7 additions & 7 deletions src/Files.App/App.xaml.cs
Expand Up @@ -122,19 +122,19 @@ private static async Task InitializeAppComponentsAsync()
{
var userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
var addItemService = Ioc.Default.GetRequiredService<IAddItemService>();
var preferencesSettingsService = 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 () =>
{
await Task.WhenAll(
StartAppCenter(),
DrivesManager.UpdateDrivesAsync(),
OptionalTask(CloudDrivesManager.UpdateDrivesAsync(), preferencesSettingsService.ShowCloudDrivesSection),
OptionalTask(CloudDrivesManager.UpdateDrivesAsync(), generalSettingsService.ShowCloudDrivesSection),
LibraryManager.UpdateLibrariesAsync(),
OptionalTask(NetworkDrivesManager.UpdateDrivesAsync(), preferencesSettingsService.ShowNetworkDrivesSection),
OptionalTask(WSLDistroManager.UpdateDrivesAsync(), preferencesSettingsService.ShowWslSection),
OptionalTask(FileTagsManager.UpdateFileTagsAsync(), preferencesSettingsService.ShowFileTagsSection),
OptionalTask(NetworkDrivesManager.UpdateDrivesAsync(), generalSettingsService.ShowNetworkDrivesSection),
OptionalTask(WSLDistroManager.UpdateDrivesAsync(), generalSettingsService.ShowWslSection),
OptionalTask(FileTagsManager.UpdateFileTagsAsync(), generalSettingsService.ShowFileTagsSection),
QuickAccessManager.InitializeAsync()
);
Expand Down Expand Up @@ -187,7 +187,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
services
.AddSingleton<IUserSettingsService, UserSettingsService>()
.AddSingleton<IAppearanceSettingsService, AppearanceSettingsService>((sp) => new AppearanceSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IPreferencesSettingsService, PreferencesSettingsService>((sp) => new PreferencesSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IGeneralSettingsService, GeneralSettingsService>((sp) => new GeneralSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IFoldersSettingsService, FoldersSettingsService>((sp) => new FoldersSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IApplicationSettingsService, ApplicationSettingsService>((sp) => new ApplicationSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IPreviewPaneSettingsService, PreviewPaneSettingsService>((sp) => new PreviewPaneSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
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
2 changes: 1 addition & 1 deletion src/Files.App/DataModels/SidebarPinnedModel.cs
Expand Up @@ -173,7 +173,7 @@ private void AddLocationItemToSidebar(LocationItem locationItem)
/// </summary>
public async Task AddAllItemsToSidebar()
{
if (userSettingsService.PreferencesSettingsService.ShowFavoritesSection)
if (userSettingsService.GeneralSettingsService.ShowFavoritesSection)
foreach (string path in FavoriteItems)
await AddItemToSidebarAsync(path);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Files.App/Dialogs/SettingsDialog.xaml
Expand Up @@ -72,22 +72,22 @@
<!-- Menu Items -->
<NavigationView.MenuItems>
<NavigationViewItem
AccessKey="A"
AutomationProperties.AutomationId="SettingsItemAppearance"
Content="{helpers:ResourceString Name=Appearance}"
AccessKey="P"
AutomationProperties.AutomationId="SettingsItemGeneral"
Content="{helpers:ResourceString Name=General}"
IsSelected="True"
Tag="0">
<NavigationViewItem.Icon>
<FontIcon HorizontalAlignment="Left" Glyph="&#xE790;" />
<FontIcon Glyph="&#xE9E9;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem
AccessKey="P"
AutomationProperties.AutomationId="SettingsItemPreferences"
Content="{helpers:ResourceString Name=SettingsNavPreferences/Content}"
AccessKey="A"
AutomationProperties.AutomationId="SettingsItemAppearance"
Content="{helpers:ResourceString Name=Appearance}"
Tag="1">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE9E9;" />
<FontIcon HorizontalAlignment="Left" Glyph="&#xE790;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Dialogs/SettingsDialog.xaml.cs
Expand Up @@ -45,8 +45,8 @@ private void MainSettingsNavigationView_SelectionChanged(NavigationView sender,

_ = selectedItemTag switch
{
0 => SettingsContentFrame.Navigate(typeof(AppearancePage)),
1 => SettingsContentFrame.Navigate(typeof(PreferencesPage)),
0 => SettingsContentFrame.Navigate(typeof(GeneralPage)),
1 => SettingsContentFrame.Navigate(typeof(AppearancePage)),
2 => SettingsContentFrame.Navigate(typeof(FoldersPage)),
3 => SettingsContentFrame.Navigate(typeof(TagsPage)),
4 => SettingsContentFrame.Navigate(typeof(AdvancedPage)),
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
16 changes: 8 additions & 8 deletions src/Files.App/Helpers/WidgetsHelpers.cs
Expand Up @@ -7,10 +7,10 @@ namespace Files.App.Helpers
{
public static class WidgetsHelpers
{
public static TWidget? TryGetWidget<TWidget>(IPreferencesSettingsService preferencesSettingsService, WidgetsListControlViewModel widgetsViewModel, out bool shouldReload, TWidget? defaultValue = default) where TWidget : IWidgetItemModel, new()
public static TWidget? TryGetWidget<TWidget>(IGeneralSettingsService generalSettingsService, WidgetsListControlViewModel widgetsViewModel, out bool shouldReload, TWidget? defaultValue = default) where TWidget : IWidgetItemModel, new()
{
bool canAddWidget = widgetsViewModel.CanAddWidget(typeof(TWidget).Name);
bool isWidgetSettingEnabled = TryGetIsWidgetSettingEnabled<TWidget>(preferencesSettingsService);
bool isWidgetSettingEnabled = TryGetIsWidgetSettingEnabled<TWidget>(generalSettingsService);

if (canAddWidget && isWidgetSettingEnabled)
{
Expand All @@ -35,27 +35,27 @@ public static class WidgetsHelpers
return (defaultValue);
}

public static bool TryGetIsWidgetSettingEnabled<TWidget>(IPreferencesSettingsService preferencesSettingsService) where TWidget : IWidgetItemModel
public static bool TryGetIsWidgetSettingEnabled<TWidget>(IGeneralSettingsService generalSettingsService) where TWidget : IWidgetItemModel
{
if (typeof(TWidget) == typeof(QuickAccessWidget))
{
return preferencesSettingsService.ShowQuickAccessWidget;
return generalSettingsService.ShowQuickAccessWidget;
}
if (typeof(TWidget) == typeof(DrivesWidget))
{
return preferencesSettingsService.ShowDrivesWidget;
return generalSettingsService.ShowDrivesWidget;
}
if (typeof(TWidget) == typeof(FileTagsWidget))
{
return preferencesSettingsService.ShowFileTagsWidget;
return generalSettingsService.ShowFileTagsWidget;
}
if (typeof(TWidget) == typeof(BundlesWidget))
{
return preferencesSettingsService.ShowBundlesWidget;
return generalSettingsService.ShowBundlesWidget;
}
if (typeof(TWidget) == typeof(RecentFilesWidget))
{
return preferencesSettingsService.ShowRecentFilesWidget;
return generalSettingsService.ShowRecentFilesWidget;
}

// A custom widget it is - TWidget implements ICustomWidgetItemModel
Expand Down
Expand Up @@ -33,15 +33,15 @@ public ITimeSpanLabel ToTimeSpanLabel(DateTimeOffset offset)

private void Update()
{
var dateTimeFormat = UserSettingsService.PreferencesSettingsService.DateTimeFormat;
var dateTimeFormat = UserSettingsService.GeneralSettingsService.DateTimeFormat;
var factory = Ioc.Default.GetService<IDateTimeFormatterFactory>();

formatter = factory.GetDateTimeFormatter(dateTimeFormat);
}

private void UserSettingsService_OnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
if (e.SettingName is nameof(UserSettingsService.PreferencesSettingsService.DateTimeFormat))
if (e.SettingName is nameof(UserSettingsService.GeneralSettingsService.DateTimeFormat))
Update();
}
}
Expand Down
Expand Up @@ -7,9 +7,9 @@

namespace Files.App.ServicesImplementation.Settings
{
internal sealed class PreferencesSettingsService : BaseObservableJsonSettings, IPreferencesSettingsService
internal sealed class GeneralSettingsService : BaseObservableJsonSettings, IGeneralSettingsService
{
public PreferencesSettingsService(ISettingsSharingContext settingsSharingContext)
public GeneralSettingsService(ISettingsSharingContext settingsSharingContext)
{
// Register root
RegisterSettingsContext(settingsSharingContext);
Expand Down
Expand Up @@ -12,10 +12,10 @@ namespace Files.App.ServicesImplementation.Settings
{
internal sealed class UserSettingsService : BaseJsonSettings, IUserSettingsService
{
private IPreferencesSettingsService _PreferencesSettingsService;
public IPreferencesSettingsService PreferencesSettingsService
private IGeneralSettingsService _GeneralSettingsService;
public IGeneralSettingsService GeneralSettingsService
{
get => GetSettingsService(ref _PreferencesSettingsService);
get => GetSettingsService(ref _GeneralSettingsService);
}

private IFoldersSettingsService _FoldersSettingsService;
Expand Down Expand Up @@ -68,7 +68,7 @@ public override object ExportSettings()
var export = (Dictionary<string, object>)base.ExportSettings();

// Remove session settings
export.Remove(nameof(PreferencesSettingsService.LastSessionTabList));
export.Remove(nameof(GeneralSettingsService.LastSessionTabList));

return JsonSettingsSerializer.SerializeToJson(export);
}
Expand Down
3 changes: 0 additions & 3 deletions src/Files.App/Strings/en-US/Resources.resw
Expand Up @@ -216,9 +216,6 @@
<data name="Advanced" xml:space="preserve">
<value>Advanced</value>
</data>
<data name="SettingsNavPreferences.Content" xml:space="preserve">
<value>Preferences</value>
</data>
<data name="SettingsOnStartupContinueWhereYouLeftOff.Content" xml:space="preserve">
<value>Continue where you left off</value>
</data>
Expand Down
20 changes: 10 additions & 10 deletions src/Files.App/UserControls/SidebarControl.xaml.cs
Expand Up @@ -219,7 +219,7 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
OpacityIconStyle = "ColorIconOpenInNewTab",
},
Command = OpenInNewTabCommand,
ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab
ShowItem = options.IsLocationItem && userSettingsService.GeneralSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Expand All @@ -229,13 +229,13 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
OpacityIconStyle = "ColorIconOpenInNewWindow",
},
Command = OpenInNewWindowCommand,
ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab
ShowItem = options.IsLocationItem && userSettingsService.GeneralSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Text = "OpenInNewPane".GetLocalizedResource(),
Command = OpenInNewPaneCommand,
ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewPane
ShowItem = options.IsLocationItem && userSettingsService.GeneralSettingsService.ShowOpenInNewPane
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down Expand Up @@ -319,25 +319,25 @@ private void HideSection()
switch (rightClickedItem.Section)
{
case SectionType.Favorites:
userSettingsService.PreferencesSettingsService.ShowFavoritesSection = false;
userSettingsService.GeneralSettingsService.ShowFavoritesSection = false;
break;
case SectionType.Library:
userSettingsService.PreferencesSettingsService.ShowLibrarySection = false;
userSettingsService.GeneralSettingsService.ShowLibrarySection = false;
break;
case SectionType.CloudDrives:
userSettingsService.PreferencesSettingsService.ShowCloudDrivesSection = false;
userSettingsService.GeneralSettingsService.ShowCloudDrivesSection = false;
break;
case SectionType.Drives:
userSettingsService.PreferencesSettingsService.ShowDrivesSection = false;
userSettingsService.GeneralSettingsService.ShowDrivesSection = false;
break;
case SectionType.Network:
userSettingsService.PreferencesSettingsService.ShowNetworkDrivesSection = false;
userSettingsService.GeneralSettingsService.ShowNetworkDrivesSection = false;
break;
case SectionType.WSL:
userSettingsService.PreferencesSettingsService.ShowWslSection = false;
userSettingsService.GeneralSettingsService.ShowWslSection = false;
break;
case SectionType.FileTag:
userSettingsService.PreferencesSettingsService.ShowFileTagsSection = false;
userSettingsService.GeneralSettingsService.ShowFileTagsSection = false;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/Widgets/BundlesWidget.xaml.cs
Expand Up @@ -27,7 +27,7 @@ public BundlesViewModel ViewModel

public string WidgetHeader => "Bundles".GetLocalizedResource();

public bool IsWidgetSettingEnabled => UserSettingsService.PreferencesSettingsService.ShowBundlesWidget;
public bool IsWidgetSettingEnabled => UserSettingsService.GeneralSettingsService.ShowBundlesWidget;

public bool ShowMenuFlyout => false;

Expand Down

0 comments on commit 0a4985b

Please sign in to comment.