Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Rearranged folder options in the settings dialog #10962

Merged
merged 4 commits into from
Jan 9, 2023
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
6 changes: 3 additions & 3 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ private void RefreshContainer(SelectorItem container, bool inRecycleQueue)
{
container.PointerPressed += FileListItem_PointerPressed;
container.RightTapped += FileListItem_RightTapped;
if (UserSettingsService.PreferencesSettingsService.SelectFilesOnHover)
if (UserSettingsService.FoldersSettingsService.SelectFilesOnHover)
{
container.PointerEntered += FileListItem_PointerEntered;
container.PointerExited += FileListItem_PointerExited;
Expand Down Expand Up @@ -971,7 +971,7 @@ protected static void FileListItem_PointerPressed(object sender, PointerRoutedEv

protected internal void FileListItem_PointerEntered(object sender, PointerRoutedEventArgs e)
{
if (!UserSettingsService.PreferencesSettingsService.SelectFilesOnHover)
if (!UserSettingsService.FoldersSettingsService.SelectFilesOnHover)
return;

var hovered = GetItemFromElement(sender);
Expand Down Expand Up @@ -1015,7 +1015,7 @@ selectedItems is not null &&

protected internal void FileListItem_PointerExited(object sender, PointerRoutedEventArgs e)
{
if (!UserSettingsService.PreferencesSettingsService.SelectFilesOnHover)
if (!UserSettingsService.FoldersSettingsService.SelectFilesOnHover)
return;

hoverTimer.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task<ReturnResult> DeleteItemsAsync(IEnumerable<IStorageItemWithPat
var deleteFromRecycleBin = source.Select(item => item.Path).Any(path => recycleBinHelpers.IsPathUnderRecycleBin(path));
var canBeSentToBin = !deleteFromRecycleBin && await recycleBinHelpers.HasRecycleBin(source.FirstOrDefault()?.Path);

if (showDialog && UserSettingsService.PreferencesSettingsService.ShowConfirmDeleteDialog) // Check if the setting to show a confirmation dialog is on
if (showDialog && UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog) // Check if the setting to show a confirmation dialog is on
{
var incomingItems = new List<BaseFileSystemDialogItemViewModel>();
List<ShellFileItem>? binItems = null;
Expand Down Expand Up @@ -253,7 +253,7 @@ public async Task<ReturnResult> PerformOperationTypeAsync(DataPackageOperation o
}
if (destination.StartsWith(CommonPaths.RecycleBinPath, StringComparison.Ordinal))
{
showDialog |= UserSettingsService.PreferencesSettingsService.ShowConfirmDeleteDialog;
showDialog |= UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog;
return await RecycleItemsFromClipboard(packageView, destination, showDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Copy))
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Filesystem/ListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public virtual string Name
if (PrimaryItemAttribute == StorageItemTypes.File)
{
var nameWithoutExtension = Path.GetFileNameWithoutExtension(itemNameRaw);
if (!string.IsNullOrEmpty(nameWithoutExtension) && !UserSettingsService.PreferencesSettingsService.ShowFileExtensions)
if (!string.IsNullOrEmpty(nameWithoutExtension) && !UserSettingsService.FoldersSettingsService.ShowFileExtensions)
{
return nameWithoutExtension;
}
Expand Down Expand Up @@ -537,7 +537,7 @@ public override string Name
get
{
var nameWithoutExtension = Path.GetFileNameWithoutExtension(ItemNameRaw);
if (!string.IsNullOrEmpty(nameWithoutExtension) && !UserSettingsService.PreferencesSettingsService.ShowFileExtensions)
if (!string.IsNullOrEmpty(nameWithoutExtension) && !UserSettingsService.FoldersSettingsService.ShowFileExtensions)
{
return nameWithoutExtension;
}
Expand Down Expand Up @@ -588,7 +588,7 @@ public override string Name
{
var nameWithoutExtension = Path.GetFileNameWithoutExtension(ItemNameRaw);
var mainStreamNameWithoutExtension = Path.GetFileNameWithoutExtension(MainStreamName);
if (!UserSettingsService.PreferencesSettingsService.ShowFileExtensions)
if (!UserSettingsService.FoldersSettingsService.ShowFileExtensions)
{
return $"{(string.IsNullOrEmpty(mainStreamNameWithoutExtension) ? MainStreamName : mainStreamNameWithoutExtension)}:{(string.IsNullOrEmpty(nameWithoutExtension) ? ItemNameRaw : nameWithoutExtension)}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,30 @@ public GroupOption DefaultGroupOption
set => Set((long)value);
}

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

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

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

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

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
Expand All @@ -245,6 +269,10 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(ColumnLayoutOpenFoldersWithOneClick):
case nameof(OpenFoldersInNewTab):
case nameof(CalculateFolderSizes):
case nameof(ShowFileExtensions):
case nameof(ShowThumbnails):
case nameof(ShowConfirmDeleteDialog):
case nameof(SelectFilesOnHover):
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,6 @@ public PreferencesSettingsService(ISettingsSharingContext settingsSharingContext
RegisterSettingsContext(settingsSharingContext);
}

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

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

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

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

public bool SearchUnindexedItems
{
get => Get(false);
Expand Down Expand Up @@ -199,9 +175,6 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
{
switch (e.SettingName)
{
case nameof(ShowConfirmDeleteDialog):
case nameof(ShowFileExtensions):
case nameof(SelectFilesOnHover):
case nameof(SearchUnindexedItems):
case nameof(OpenSpecificPageOnStartup):
case nameof(ContinueLastSessionOnStartUp):
Expand Down
27 changes: 18 additions & 9 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@
<data name="ItemTypeFile" xml:space="preserve">
<value>File</value>
</data>
<data name="Display" xml:space="preserve">
<value>Display</value>
</data>
<data name="RenameDialog.Title" xml:space="preserve">
<value>Enter an item name</value>
</data>
Expand Down Expand Up @@ -696,6 +699,9 @@
<data name="InvalidItemDialogTitle" xml:space="preserve">
<value>Invalid item</value>
</data>
<data name="Version" xml:space="preserve">
<value>Version</value>
</data>
<data name="SettingsAboutVersionTitle" xml:space="preserve">
<value>Version:</value>
</data>
Expand Down Expand Up @@ -741,6 +747,12 @@
<data name="SponsorUsOnGitHub" xml:space="preserve">
<value>Sponsor us on GitHub</value>
</data>
<data name="Personalization" xml:space="preserve">
<value>Personalization</value>
</data>
<data name="LayoutAndSorting" xml:space="preserve">
<value>Layout and sorting</value>
</data>
<data name="AccessDeniedCreateDialog.Text" xml:space="preserve">
<value>We weren't able to create this item</value>
</data>
Expand Down Expand Up @@ -807,8 +819,8 @@
<data name="SettingsContextMenuOverflow" xml:space="preserve">
<value>Move overflow items into a sub menu</value>
</data>
<data name="SettingsPreferencesShowConfirmDeleteDialog.Title" xml:space="preserve">
<value>Show a confirmation dialog when deleting files or folders</value>
<data name="ShowConfirmationWhenDeletingItems" xml:space="preserve">
<value>Show confirmation dialog when deleting items</value>
</data>
<data name="PropertySaveErrorMessage.Text" xml:space="preserve">
<value>There was an issue saving some properties.</value>
Expand Down Expand Up @@ -2328,9 +2340,6 @@
<data name="SettingsPreferencesAppLanguageComboBox.AutomationProperties.Name" xml:space="preserve">
<value>Language</value>
</data>
<data name="SettingsShowConfirmDeleteDialogToggleSwitch.AutomationProperties.Name" xml:space="preserve">
<value>Show a confirmation dialog when deleting files or folders</value>
</data>
<data name="OngoingTasks" xml:space="preserve">
<value>Ongoing Tasks</value>
</data>
Expand Down Expand Up @@ -2409,9 +2418,6 @@
<data name="RestoreDefault" xml:space="preserve">
<value>Restore default</value>
</data>
<data name="FilesAndFolders" xml:space="preserve">
<value>Files and folders</value>
</data>
<data name="OpenNewInstance" xml:space="preserve">
<value>Open new instance when opening directories from the taskbar jumplist</value>
</data>
Expand Down Expand Up @@ -2653,7 +2659,10 @@
<value>Ctrl+Shift+7</value>
</data>
<data name="ShowAlternateStreams" xml:space="preserve">
<value>Show Alternate Data Streams</value>
<value>Show alternate data streams</value>
</data>
<data name="Behaviors" xml:space="preserve">
<value>Behaviors</value>
</data>
<data name="ReviewFiles" xml:space="preserve">
<value>Review Files</value>
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@
Grid.Column="1"
HorizontalAlignment="Right"
AutomationProperties.Name="{helpers:ResourceString Name=NavToolbarShowFileExtensions/AutomationProperties/Name}"
IsOn="{x:Bind UserSettingsService.PreferencesSettingsService.ShowFileExtensions, Mode=TwoWay}"
IsOn="{x:Bind UserSettingsService.FoldersSettingsService.ShowFileExtensions, Mode=TwoWay}"
Rotation="1"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</Grid>
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/ViewModels/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,14 @@ private async void UserSettingsService_OnSettingChangedEvent(object sender, Sett
{
switch (e.SettingName)
{
case nameof(UserSettingsService.PreferencesSettingsService.ShowFileExtensions):
case nameof(UserSettingsService.PreferencesSettingsService.ShowThumbnails):
case nameof(UserSettingsService.FoldersSettingsService.ShowFileExtensions):
case nameof(UserSettingsService.FoldersSettingsService.ShowThumbnails):
case nameof(UserSettingsService.FoldersSettingsService.ShowHiddenItems):
case nameof(UserSettingsService.FoldersSettingsService.ShowProtectedSystemFiles):
case nameof(UserSettingsService.FoldersSettingsService.AreAlternateStreamsVisible):
case nameof(UserSettingsService.FoldersSettingsService.ShowDotFiles):
case nameof(UserSettingsService.FoldersSettingsService.CalculateFolderSizes):
case nameof(UserSettingsService.PreferencesSettingsService.SelectFilesOnHover):
case nameof(UserSettingsService.FoldersSettingsService.SelectFilesOnHover):
await dispatcherQueue.EnqueueAsync(() =>
{
if (WorkingDirectory != "Home".GetLocalizedResource())
Expand Down Expand Up @@ -858,7 +858,7 @@ private async Task LoadItemThumbnail(ListedItem item, uint thumbnailSize = 96, I
var wasIconLoaded = false;
if (item.IsLibrary || item.PrimaryItemAttribute == StorageItemTypes.File || item.IsArchive)
{
if (UserSettingsService.PreferencesSettingsService.ShowThumbnails &&
if (UserSettingsService.FoldersSettingsService.ShowThumbnails &&
!item.IsShortcut && !item.IsHiddenItem && !FtpHelpers.IsFtpPath(item.ItemPath))
{
var matchingStorageFile = matchingStorageItem.AsBaseStorageFile() ?? await GetFileFromPathAsync(item.ItemPath);
Expand Down
67 changes: 66 additions & 1 deletion src/Files.App/ViewModels/SettingsViewModels/FoldersViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ public bool OpenFoldersNewTab
}
}

public bool ListAndSortDirectoriesAlongsideFiles
{
get => UserSettingsService.LayoutSettingsService.DefaultSortDirectoriesAlongsideFiles;
set
{
if (value != UserSettingsService.LayoutSettingsService.DefaultSortDirectoriesAlongsideFiles)
{
UserSettingsService.LayoutSettingsService.DefaultSortDirectoriesAlongsideFiles = value;
OnPropertyChanged();
}
}
}

public bool CalculateFolderSizes
{
get => UserSettingsService.FoldersSettingsService.CalculateFolderSizes;
Expand Down Expand Up @@ -273,7 +286,59 @@ public int SelectedDefaultGroupingIndex
}
}
}


public bool ShowFileExtensions
{
get => UserSettingsService.FoldersSettingsService.ShowFileExtensions;
set
{
if (value != UserSettingsService.FoldersSettingsService.ShowFileExtensions)
{
UserSettingsService.FoldersSettingsService.ShowFileExtensions = value;
OnPropertyChanged();
}
}
}

public bool ShowThumbnails
{
get => UserSettingsService.FoldersSettingsService.ShowThumbnails;
set
{
if (value != UserSettingsService.FoldersSettingsService.ShowThumbnails)
{
UserSettingsService.FoldersSettingsService.ShowThumbnails = value;
OnPropertyChanged();
}
}
}

public bool ShowConfirmDeleteDialog
{
get => UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog;
set
{
if (value != UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog)
{
UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog = value;
OnPropertyChanged();
}
}
}

public bool SelectFilesOnHover
{
get => UserSettingsService.FoldersSettingsService.SelectFilesOnHover;
set
{
if (value != UserSettingsService.FoldersSettingsService.SelectFilesOnHover)
{
UserSettingsService.FoldersSettingsService.SelectFilesOnHover = value;
OnPropertyChanged();
}
}
}

// Local methods

public void ResetLayoutPreferences()
Expand Down
Loading