Skip to content
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
35 changes: 35 additions & 0 deletions src/Files.App/Data/Contracts/IGeneralSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,72 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
/// Gets or sets a value indicating if the favorites section should be visible.
/// </summary>
bool ShowPinnedSection { get; set; }

/// <summary>
/// Gets or sets a value indicating if the favorites section should be expanded.
/// </summary>
bool IsPinnedSectionExpanded { get; set; }

/// <summary>
/// Gets or sets a value indicating if the library section should be visible.
/// </summary>
bool ShowLibrarySection { get; set; }

/// <summary>
/// Gets or sets a value indicating if the library section should be expanded.
/// </summary>
bool IsLibrarySectionExpanded { get; set; }

/// <summary>
/// Gets or sets a value indicating if the drive section should be visible.
/// </summary>
bool ShowDrivesSection { get; set; }

/// <summary>
/// Gets or sets a value indicating if the drive section should be expanded.
/// </summary>
bool IsDriveSectionExpanded { get; set; }

/// <summary>
/// Gets or sets a value indicating if the cloud drive section should be visible.
/// </summary>
bool ShowCloudDrivesSection { get; set; }

/// <summary>
/// Gets or sets a value indicating if the cloud drive section should be expanded.
/// </summary>
bool IsCloudDriveSectionExpanded { get; set; }

/// <summary>
/// Gets or sets a value indicating if the network section should be visible.
/// </summary>
bool ShowNetworkSection { get; set; }

/// <summary>
/// Gets or sets a value indicating if the network section should be expanded.
/// </summary>
bool IsNetworkSectionExpanded { get; set; }

/// <summary>
/// Gets or sets a value indicating if the wsl section should be visible.
/// </summary>
bool ShowWslSection { get; set; }

/// <summary>
/// Gets or sets a value indicating if the wsl section should be expanded.
/// </summary>
bool IsWslSectionExpanded { get; set; }

/// <summary>
/// Gets or sets a value indicating if the tags section should be visible.
/// </summary>
bool ShowFileTagsSection { get; set; }

/// <summary>
/// Gets or sets a value indicating if the file tags section should be expanded.
/// </summary>
bool IsFileTagsSectionExpanded { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to move shell extensions into a sub menu.
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ public static IHost ConfigureHost()
.AddSingleton<MainPageViewModel>()
.AddSingleton<InfoPaneViewModel>()
.AddSingleton<SidebarViewModel>()
.AddSingleton<SettingsViewModel>()
.AddSingleton<DrivesViewModel>()
.AddSingleton<StatusCenterViewModel>()
.AddSingleton<AppearanceViewModel>()
Expand Down
42 changes: 42 additions & 0 deletions src/Files.App/Services/Settings/GeneralSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,42 +143,84 @@ public bool ShowPinnedSection
set => Set(value);
}

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

public bool ShowLibrarySection
{
get => Get(false);
set => Set(value);
}

public bool IsLibrarySectionExpanded
{
get => Get(false);
set => Set(value);
}

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

public bool IsDriveSectionExpanded
{
get => Get(false);
set => Set(value);
}

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

public bool IsCloudDriveSectionExpanded
{
get => Get(false);
set => Set(value);
}

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

public bool IsNetworkSectionExpanded
{
get => Get(false);
set => Set(value);
}

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

public bool IsWslSectionExpanded
{
get => Get(false);
set => Set(value);

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

public bool IsFileTagsSectionExpanded
{
get => Get(false);
set => Set(value);
}

public bool MoveShellExtensionsToSubMenu
{
get => Get(true);
Expand Down
100 changes: 0 additions & 100 deletions src/Files.App/ViewModels/SettingsViewModel.cs

This file was deleted.

33 changes: 31 additions & 2 deletions src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,37 @@ await lib.CheckDefaultSaveFolderAccess() &&
}
}

section.IsExpanded = Ioc.Default.GetRequiredService<SettingsViewModel>().Get(section.Text == "Pinned".GetLocalizedResource(), $"section:{section.Text.Replace('\\', '_')}");
section.PropertyChanged += Section_PropertyChanged;
}

private void Section_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (sender is LocationItem section && e.PropertyName == nameof(section.IsExpanded))
{
Ioc.Default.GetRequiredService<SettingsViewModel>().Set(section.IsExpanded, $"section:{section.Text.Replace('\\', '_')}");
switch (section.Text)
{
case var text when text == "Pinned".GetLocalizedResource():
UserSettingsService.GeneralSettingsService.IsPinnedSectionExpanded = section.IsExpanded;
break;
case var text when text == "SidebarLibraries".GetLocalizedResource():
UserSettingsService.GeneralSettingsService.IsLibrarySectionExpanded = section.IsExpanded;
break;
case var text when text == "Drives".GetLocalizedResource():
UserSettingsService.GeneralSettingsService.IsDriveSectionExpanded = section.IsExpanded;
break;
case var text when text == "SidebarCloudDrives".GetLocalizedResource():
UserSettingsService.GeneralSettingsService.IsCloudDriveSectionExpanded = section.IsExpanded;
break;
case var text when text == "Network".GetLocalizedResource():
UserSettingsService.GeneralSettingsService.IsNetworkSectionExpanded = section.IsExpanded;
break;
case var text when text == "WSL".GetLocalizedResource():
UserSettingsService.GeneralSettingsService.IsWslSectionExpanded = section.IsExpanded;
break;
case var text when text == "FileTags".GetLocalizedResource():
UserSettingsService.GeneralSettingsService.IsFileTagsSectionExpanded = section.IsExpanded;
break;
}
}
}

Expand Down Expand Up @@ -448,6 +470,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
section = BuildSection("Pinned".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false);
icon = new BitmapImage(new Uri(Constants.FluentIconsPaths.StarIcon));
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsPinnedSectionExpanded;

break;
}
Expand All @@ -461,6 +484,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
section = BuildSection("SidebarLibraries".GetLocalizedResource(), sectionType, new ContextMenuOptions { IsLibrariesHeader = true, ShowHideSection = true }, false);
iconIdex = Constants.ImageRes.Libraries;
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsLibrarySectionExpanded;

break;
}
Expand All @@ -474,6 +498,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
section = BuildSection("Drives".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false);
iconIdex = Constants.ImageRes.ThisPC;
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsDriveSectionExpanded;

break;
}
Expand All @@ -487,6 +512,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
section = BuildSection("SidebarCloudDrives".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false);
icon = new BitmapImage(new Uri(Constants.FluentIconsPaths.CloudDriveIcon));
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsCloudDriveSectionExpanded;

break;
}
Expand All @@ -500,6 +526,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
section = BuildSection("Network".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false);
iconIdex = Constants.ImageRes.Network;
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsNetworkSectionExpanded;

break;
}
Expand All @@ -513,6 +540,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
section = BuildSection("WSL".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false);
icon = new BitmapImage(new Uri(Constants.WslIconsPaths.GenericIcon));
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsWslSectionExpanded;

break;
}
Expand All @@ -526,6 +554,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
section = BuildSection("FileTags".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false);
icon = new BitmapImage(new Uri(Constants.FluentIconsPaths.FileTagsIcon));
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsFileTagsSectionExpanded;

break;
}
Expand Down