Skip to content

Commit 5b3a54f

Browse files
authored
Feature: Moved sidebar settings to preferences (#10933)
1 parent f0a0310 commit 5b3a54f

File tree

14 files changed

+284
-327
lines changed

14 files changed

+284
-327
lines changed

src/Files.App/App.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,19 @@ private static async Task StartAppCenter()
182182
private static async Task InitializeAppComponentsAsync()
183183
{
184184
var userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
185-
var appearanceSettingsService = userSettingsService.AppearanceSettingsService;
185+
var preferencesSettingsService = userSettingsService.PreferencesSettingsService;
186186

187187
// Start off a list of tasks we need to run before we can continue startup
188188
await Task.Run(async () =>
189189
{
190190
await Task.WhenAll(
191191
StartAppCenter(),
192192
DrivesManager.UpdateDrivesAsync(),
193-
OptionalTask(CloudDrivesManager.UpdateDrivesAsync(), appearanceSettingsService.ShowCloudDrivesSection),
193+
OptionalTask(CloudDrivesManager.UpdateDrivesAsync(), preferencesSettingsService.ShowCloudDrivesSection),
194194
LibraryManager.UpdateLibrariesAsync(),
195-
OptionalTask(NetworkDrivesManager.UpdateDrivesAsync(), appearanceSettingsService.ShowNetworkDrivesSection),
196-
OptionalTask(WSLDistroManager.UpdateDrivesAsync(), appearanceSettingsService.ShowWslSection),
197-
OptionalTask(FileTagsManager.UpdateFileTagsAsync(), appearanceSettingsService.ShowFileTagsSection),
195+
OptionalTask(NetworkDrivesManager.UpdateDrivesAsync(), preferencesSettingsService.ShowNetworkDrivesSection),
196+
OptionalTask(WSLDistroManager.UpdateDrivesAsync(), preferencesSettingsService.ShowWslSection),
197+
OptionalTask(FileTagsManager.UpdateFileTagsAsync(), preferencesSettingsService.ShowFileTagsSection),
198198
SidebarPinnedController.InitializeAsync()
199199
);
200200
await Task.WhenAll(

src/Files.App/DataModels/SidebarPinnedModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private void AddLocationItemToSidebar(LocationItem locationItem)
273273
/// </summary>
274274
public async Task AddAllItemsToSidebar()
275275
{
276-
if (UserSettingsService.AppearanceSettingsService.ShowFavoritesSection)
276+
if (UserSettingsService.PreferencesSettingsService.ShowFavoritesSection)
277277
{
278278
foreach (string path in FavoriteItems)
279279
{

src/Files.App/Helpers/ContextFlyoutItemHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
538538
Text = "BaseLayoutItemContextFlyoutPinToFavorites/Text".GetLocalizedResource(),
539539
Glyph = "\uE840",
540540
Command = commandsViewModel.PinDirectoryToFavoritesCommand,
541-
ShowItem = itemViewModel.CurrentFolder is not null && !itemViewModel.CurrentFolder.IsPinned & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
541+
ShowItem = itemViewModel.CurrentFolder is not null && !itemViewModel.CurrentFolder.IsPinned & userSettingsService.PreferencesSettingsService.ShowFavoritesSection,
542542
ShowInFtpPage = true,
543543
ShowInRecycleBin = true,
544544
},
@@ -547,7 +547,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
547547
Text = "BaseLayoutContextFlyoutUnpinFromFavorites/Text".GetLocalizedResource(),
548548
Glyph = "\uE77A",
549549
Command = commandsViewModel.UnpinDirectoryFromFavoritesCommand,
550-
ShowItem = itemViewModel.CurrentFolder is not null && itemViewModel.CurrentFolder.IsPinned & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
550+
ShowItem = itemViewModel.CurrentFolder is not null && itemViewModel.CurrentFolder.IsPinned & userSettingsService.PreferencesSettingsService.ShowFavoritesSection,
551551
ShowInFtpPage = true,
552552
ShowInRecycleBin = true,
553553
},
@@ -963,7 +963,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
963963
Text = "BaseLayoutItemContextFlyoutPinToFavorites/Text".GetLocalizedResource(),
964964
Glyph = "\uE840",
965965
Command = commandsViewModel.SidebarPinItemCommand,
966-
ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsArchive && !x.IsPinned) & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
966+
ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsArchive && !x.IsPinned) & userSettingsService.PreferencesSettingsService.ShowFavoritesSection,
967967
ShowInSearchPage = true,
968968
ShowInFtpPage = true,
969969
},
@@ -972,7 +972,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
972972
Text = "BaseLayoutContextFlyoutUnpinFromFavorites/Text".GetLocalizedResource(),
973973
Glyph = "\uE77A",
974974
Command = commandsViewModel.SidebarUnpinItemCommand,
975-
ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsArchive && x.IsPinned) & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
975+
ShowItem = selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsArchive && x.IsPinned) & userSettingsService.PreferencesSettingsService.ShowFavoritesSection,
976976
ShowInSearchPage = true,
977977
ShowInFtpPage = true,
978978
},

src/Files.App/ServicesImplementation/Settings/AppearanceSettingsService.cs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -27,48 +27,6 @@ public bool IsSidebarOpen
2727
set => Set(value);
2828
}
2929

30-
public bool ShowFavoritesSection
31-
{
32-
get => Get(true);
33-
set => Set(value);
34-
}
35-
36-
public bool ShowLibrarySection
37-
{
38-
get => Get(false);
39-
set => Set(value);
40-
}
41-
42-
public bool ShowDrivesSection
43-
{
44-
get => Get(true);
45-
set => Set(value);
46-
}
47-
48-
public bool ShowCloudDrivesSection
49-
{
50-
get => Get(true);
51-
set => Set(value);
52-
}
53-
54-
public bool ShowNetworkDrivesSection
55-
{
56-
get => Get(true);
57-
set => Set(value);
58-
}
59-
60-
public bool ShowWslSection
61-
{
62-
get => Get(true);
63-
set => Set(value);
64-
}
65-
66-
public bool ShowFileTagsSection
67-
{
68-
get => Get(true);
69-
set => Set(value);
70-
}
71-
7230
public bool MoveOverflowMenuItemsToSubMenu
7331
{
7432
get => Get(true);
@@ -121,12 +79,6 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
12179
switch (e.SettingName)
12280
{
12381
case nameof(MoveOverflowMenuItemsToSubMenu):
124-
case nameof(ShowFavoritesSection):
125-
case nameof(ShowLibrarySection):
126-
case nameof(ShowCloudDrivesSection):
127-
case nameof(ShowNetworkDrivesSection):
128-
case nameof(ShowWslSection):
129-
case nameof(ShowFileTagsSection):
13082
case nameof(UseCompactStyles):
13183
case nameof(AppThemeBackgroundColor):
13284
case nameof(AppThemeAddressBarBackgroundColor):

src/Files.App/ServicesImplementation/Settings/PreferencesSettingsService.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,48 @@ public bool BundlesWidgetExpanded
153153
set => Set(value);
154154
}
155155

156+
public bool ShowFavoritesSection
157+
{
158+
get => Get(true);
159+
set => Set(value);
160+
}
161+
162+
public bool ShowLibrarySection
163+
{
164+
get => Get(false);
165+
set => Set(value);
166+
}
167+
168+
public bool ShowDrivesSection
169+
{
170+
get => Get(true);
171+
set => Set(value);
172+
}
173+
174+
public bool ShowCloudDrivesSection
175+
{
176+
get => Get(true);
177+
set => Set(value);
178+
}
179+
180+
public bool ShowNetworkDrivesSection
181+
{
182+
get => Get(true);
183+
set => Set(value);
184+
}
185+
186+
public bool ShowWslSection
187+
{
188+
get => Get(true);
189+
set => Set(value);
190+
}
191+
192+
public bool ShowFileTagsSection
193+
{
194+
get => Get(true);
195+
set => Set(value);
196+
}
197+
156198
protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
157199
{
158200
switch (e.SettingName)
@@ -175,6 +217,12 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
175217
case nameof(RecentFilesWidgetExpanded):
176218
case nameof(BundlesWidgetExpanded):
177219
case nameof(DrivesWidgetExpanded):
220+
case nameof(ShowFavoritesSection):
221+
case nameof(ShowLibrarySection):
222+
case nameof(ShowCloudDrivesSection):
223+
case nameof(ShowNetworkDrivesSection):
224+
case nameof(ShowWslSection):
225+
case nameof(ShowFileTagsSection):
178226
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
179227
break;
180228
}

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,9 +1501,6 @@
15011501
<data name="BundlesOpenInNewPane.Text" xml:space="preserve">
15021502
<value>Open in new Pane</value>
15031503
</data>
1504-
<data name="SettingsShowLibrarySection.Title" xml:space="preserve">
1505-
<value>Show library section</value>
1506-
</data>
15071504
<data name="Default" xml:space="preserve">
15081505
<value>Default</value>
15091506
</data>
@@ -2164,18 +2161,6 @@
21642161
<data name="PropertyUncompressedSize" xml:space="preserve">
21652162
<value>Uncompressed size</value>
21662163
</data>
2167-
<data name="SettingsShowCloudDrivesSection.Title" xml:space="preserve">
2168-
<value>Show cloud drives section</value>
2169-
</data>
2170-
<data name="SettingsShowDrivesSection.Title" xml:space="preserve">
2171-
<value>Show drives section</value>
2172-
</data>
2173-
<data name="SettingsShowWslSection.Title" xml:space="preserve">
2174-
<value>Show WSL section</value>
2175-
</data>
2176-
<data name="SettingsShowNetworkDrivesSection.Title" xml:space="preserve">
2177-
<value>Show network section</value>
2178-
</data>
21792164
<data name="WSL" xml:space="preserve">
21802165
<value>WSL</value>
21812166
</data>
@@ -2278,9 +2263,6 @@
22782263
<data name="SettingsEditFileTagsExpander.Title" xml:space="preserve">
22792264
<value>Edit tags</value>
22802265
</data>
2281-
<data name="SettingsShowFavoritesSection.Title" xml:space="preserve">
2282-
<value>Show favorites section</value>
2283-
</data>
22842266
<data name="ConfictingItemsDialogOptionApplyToAll.Text" xml:space="preserve">
22852267
<value>Apply to all</value>
22862268
</data>
@@ -2321,7 +2303,7 @@
23212303
<value>Drives Widget</value>
23222304
</data>
23232305
<data name="FolderWidgetAutomationProperties.Name" xml:space="preserve">
2324-
<value>Libraries Widget</value>
2306+
<value>Folders Widget</value>
23252307
</data>
23262308
<data name="RecentFilesWidgetAutomationProperties.Name" xml:space="preserve">
23272309
<value>Recent Files Widget</value>
@@ -2359,33 +2341,15 @@
23592341
<data name="NavToolbarShowHiddenItemsHeader.Text" xml:space="preserve">
23602342
<value>Show hidden items</value>
23612343
</data>
2362-
<data name="SettingsShowFavoritesSectionSwitch.AutomationProperties.Name" xml:space="preserve">
2363-
<value>Show favorites section</value>
2364-
</data>
23652344
<data name="SettingsOpenFoldersNewTabToggleSwitch.AutomationProperties.Name" xml:space="preserve">
23662345
<value>Open folders in new tab</value>
23672346
</data>
23682347
<data name="SettingsPreferencesAppLanguageComboBox.AutomationProperties.Name" xml:space="preserve">
23692348
<value>Language</value>
23702349
</data>
2371-
<data name="SettingsShowCloudDrivesSectionSwitch.AutomationProperties.Name" xml:space="preserve">
2372-
<value>Show cloud drives section</value>
2373-
</data>
23742350
<data name="SettingsShowConfirmDeleteDialogToggleSwitch.AutomationProperties.Name" xml:space="preserve">
23752351
<value>Show a confirmation dialog when deleting files or folders</value>
23762352
</data>
2377-
<data name="SettingsShowDrivesSectionSwitch.AutomationProperties.Name" xml:space="preserve">
2378-
<value>Show drives section</value>
2379-
</data>
2380-
<data name="SettingsShowLibrarySectionSwitch.AutomationProperties.Name" xml:space="preserve">
2381-
<value>Show library section</value>
2382-
</data>
2383-
<data name="SettingsShowNetworkDrivesSectionSwitch.AutomationProperties.Name" xml:space="preserve">
2384-
<value>Show network section</value>
2385-
</data>
2386-
<data name="SettingsShowWslSectionSwitch.AutomationProperties.Name" xml:space="preserve">
2387-
<value>Show WSL section</value>
2388-
</data>
23892353
<data name="OngoingTasks" xml:space="preserve">
23902354
<value>Ongoing Tasks</value>
23912355
</data>
@@ -2659,12 +2623,6 @@
26592623
<data name="FileTags" xml:space="preserve">
26602624
<value>Tags</value>
26612625
</data>
2662-
<data name="SettingsShowFileTagsSection.Title" xml:space="preserve">
2663-
<value>Show Tags section</value>
2664-
</data>
2665-
<data name="SettingsShowFileTagsSectionSwitch.AutomationProperties.Name" xml:space="preserve">
2666-
<value>Show Tags section</value>
2667-
</data>
26682626
<data name="UseCompactSpacing" xml:space="preserve">
26692627
<value>Use compact spacing in the details layout</value>
26702628
</data>

src/Files.App/UserControls/SidebarControl.xaml.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,25 +331,25 @@ private void HideSection()
331331
switch (rightClickedItem.Section)
332332
{
333333
case SectionType.Favorites:
334-
UserSettingsService.AppearanceSettingsService.ShowFavoritesSection = false;
334+
UserSettingsService.PreferencesSettingsService.ShowFavoritesSection = false;
335335
break;
336336
case SectionType.Library:
337-
UserSettingsService.AppearanceSettingsService.ShowLibrarySection = false;
337+
UserSettingsService.PreferencesSettingsService.ShowLibrarySection = false;
338338
break;
339339
case SectionType.CloudDrives:
340-
UserSettingsService.AppearanceSettingsService.ShowCloudDrivesSection = false;
340+
UserSettingsService.PreferencesSettingsService.ShowCloudDrivesSection = false;
341341
break;
342342
case SectionType.Drives:
343-
UserSettingsService.AppearanceSettingsService.ShowDrivesSection = false;
343+
UserSettingsService.PreferencesSettingsService.ShowDrivesSection = false;
344344
break;
345345
case SectionType.Network:
346-
UserSettingsService.AppearanceSettingsService.ShowNetworkDrivesSection = false;
346+
UserSettingsService.PreferencesSettingsService.ShowNetworkDrivesSection = false;
347347
break;
348348
case SectionType.WSL:
349-
UserSettingsService.AppearanceSettingsService.ShowWslSection = false;
349+
UserSettingsService.PreferencesSettingsService.ShowWslSection = false;
350350
break;
351351
case SectionType.FileTag:
352-
UserSettingsService.AppearanceSettingsService.ShowFileTagsSection = false;
352+
UserSettingsService.PreferencesSettingsService.ShowFileTagsSection = false;
353353
break;
354354
}
355355
}

0 commit comments

Comments
 (0)