Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8e27a7d
Add UI and logic for changing default sorting and grouping options
manfromarce Nov 28, 2022
61344ac
Merge https://github.com/files-community/files
manfromarce Nov 28, 2022
818efb7
Changes to match new requirements
manfromarce Nov 29, 2022
33c9e7d
Update FolderSettingsViewModel comment
manfromarce Nov 29, 2022
c98a3c5
Swap SyncStatus and FileTag order
manfromarce Nov 29, 2022
c6caf1f
Merge branch 'main' into main
yaira2 Nov 30, 2022
7489fc7
Revert swapping SyncStatus and Tag
manfromarce Dec 8, 2022
265d9b7
Revert few unnecessary changes
manfromarce Dec 8, 2022
3e722b8
Fix spacing
manfromarce Dec 8, 2022
51dd7c8
Remove DefaultSortDirection changes
manfromarce Dec 8, 2022
6145fdd
Fix combobox index when FileTag is set as default sort/group option
manfromarce Dec 8, 2022
efe1923
Merge branch 'main' into main
manfromarce Dec 8, 2022
3de1f59
Strings
yaira2 Dec 8, 2022
cd32ec2
Update src/Files.App/ServicesImplementation/Settings/FoldersSettingsS…
manfromarce Dec 8, 2022
9dcdf02
Update src/Files.App/ServicesImplementation/Settings/FoldersSettingsS…
manfromarce Dec 8, 2022
097a731
Rename into DefaultSortOption and DefaultGroupOption
manfromarce Dec 8, 2022
8f54d5c
Update FoldersViewModel
manfromarce Dec 8, 2022
14ece5b
Update FoldersViewModel.cs
manfromarce Dec 9, 2022
08cfee5
Add comment
manfromarce Dec 11, 2022
d23ad1c
Merge branch 'main' into main
manfromarce Dec 11, 2022
24609e2
Merge branch 'main' into main
QuaintMako Dec 11, 2022
1bf150f
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
98bc28f
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
5041af4
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
f21c0da
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
2332c49
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
403b74e
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
79e9108
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
bb1b4e1
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
3ad30ef
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
13b6c4b
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
24f7bc6
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
756fd4a
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
753fad3
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
48a2928
Update src/Files.App/Strings/en-US/Resources.resw
manfromarce Dec 11, 2022
817fa13
Merge branch 'main' into main
QuaintMako Dec 11, 2022
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
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/LayoutPreferences/LayoutPreferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public LayoutPreferences()

this.LayoutMode = defaultLayout is FolderLayoutModes.Adaptive ? FolderLayoutModes.DetailsView : defaultLayout;
this.GridViewSize = UserSettingsService.LayoutSettingsService.DefaultGridViewSize;
this.DirectorySortOption = UserSettingsService.LayoutSettingsService.DefaultDirectorySortOption;
this.DirectoryGroupOption = UserSettingsService.LayoutSettingsService.DefaultDirectoryGroupOption;
this.DirectorySortOption = UserSettingsService.FoldersSettingsService.DefaultSortOption;
this.DirectoryGroupOption = UserSettingsService.FoldersSettingsService.DefaultGroupOption;
this.DirectorySortDirection = UserSettingsService.LayoutSettingsService.DefaultDirectorySortDirection;
this.SortDirectoriesAlongsideFiles = UserSettingsService.LayoutSettingsService.DefaultSortDirectoriesAlongsideFiles;
this.IsAdaptiveLayoutOverridden = defaultLayout is not FolderLayoutModes.Adaptive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ public bool CalculateFolderSizes
get => Get(false);
set => Set(value);
}

public SortOption DefaultSortOption
{
get => (SortOption)Get((long)SortOption.Name);
set => Set((long)value);
}

public GroupOption DefaultGroupOption
{
get => (GroupOption)Get((long)GroupOption.None);
set => Set((long)value);
}

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,10 @@ public SortDirection DefaultDirectorySortDirection
set => Set((long)value);
}

public SortOption DefaultDirectorySortOption
{
get => (SortOption)Get((long)SortOption.Name);
set => Set((long)value);
}

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

public GroupOption DefaultDirectoryGroupOption
{
get => (GroupOption)Get((long)GroupOption.None);
set => Set((long)value);
}
}
}
14 changes: 9 additions & 5 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,7 +24,6 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Expand All @@ -43,12 +40,10 @@
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
Expand Down Expand Up @@ -2862,6 +2857,9 @@
<data name="ExtractToPath" xml:space="preserve">
<value>Path</value>
</data>
<data name="SortingAndGrouping" xml:space="preserve">
<value>Sorting and grouping</value>
</data>
<data name="Archive" xml:space="preserve">
<value>Archive</value>
</data>
Expand Down Expand Up @@ -2931,4 +2929,10 @@
<data name="DetailsViewHeaderFlyout_ShowSyncStatus.Text" xml:space="preserve">
<value>Sync status column</value>
</data>
<data name="GroupBy" xml:space="preserve">
<value>Group by</value>
</data>
<data name="SortBy" xml:space="preserve">
<value>Sort by</value>
</data>
</root>
6 changes: 3 additions & 3 deletions src/Files.App/ViewModels/FolderSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,19 @@ public static void SetLayoutPreferencesForPath(string folderPath, LayoutPreferen
{
userSettingsService.FoldersSettingsService.DefaultLayoutMode = prefs.LayoutMode;
userSettingsService.LayoutSettingsService.DefaultGridViewSize = prefs.GridViewSize;
// Do not save OriginalPath as global sort option (only works in recycle bin)
// Do not save options which only work in recycle bin or cloud folders as global
if (prefs.DirectorySortOption != SortOption.OriginalFolder &&
prefs.DirectorySortOption != SortOption.DateDeleted &&
prefs.DirectorySortOption != SortOption.SyncStatus)
{
userSettingsService.LayoutSettingsService.DefaultDirectorySortOption = prefs.DirectorySortOption;
userSettingsService.FoldersSettingsService.DefaultSortOption = prefs.DirectorySortOption;
}
if (prefs.DirectoryGroupOption != GroupOption.OriginalFolder &&
prefs.DirectoryGroupOption != GroupOption.DateDeleted &&
prefs.DirectoryGroupOption != GroupOption.FolderPath &&
prefs.DirectoryGroupOption != GroupOption.SyncStatus)
{
userSettingsService.LayoutSettingsService.DefaultDirectoryGroupOption = prefs.DirectoryGroupOption;
userSettingsService.FoldersSettingsService.DefaultGroupOption = prefs.DirectoryGroupOption;
}
userSettingsService.LayoutSettingsService.DefaultDirectorySortDirection = prefs.DirectorySortDirection;
userSettingsService.LayoutSettingsService.DefaultSortDirectoriesAlongsideFiles = prefs.SortDirectoriesAlongsideFiles;
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/ViewModels/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ await dispatcherQueue.EnqueueAsync(() =>
RefreshItems(null);
});
break;
case nameof(UserSettingsService.FoldersSettingsService.DefaultSortOption):
case nameof(UserSettingsService.FoldersSettingsService.DefaultGroupOption):
case nameof(UserSettingsService.LayoutSettingsService.DefaultSortDirectoriesAlongsideFiles):
case nameof(UserSettingsService.FoldersSettingsService.EnableOverridingFolderPreferences):
await dispatcherQueue.EnqueueAsync(() =>
Expand Down
35 changes: 35 additions & 0 deletions src/Files.App/ViewModels/SettingsViewModels/FoldersViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public class FoldersViewModel : ObservableObject
{
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();


//FileTag combobox indexes (required to hide SyncStatus)
private readonly int FileTagSortingIndex = 5;
private readonly int FileTagGroupingIndex = 6;

// Commands
public RelayCommand ResetLayoutPreferencesCommand { get; }
public RelayCommand ShowResetLayoutPreferencesTipCommand { get; }
Expand All @@ -20,6 +25,8 @@ public FoldersViewModel()
ShowResetLayoutPreferencesTipCommand = new RelayCommand(() => IsResetLayoutPreferencesTipOpen = true);

SelectedDefaultLayoutModeIndex = (int)DefaultLayoutMode;
SelectedDefaultSortingIndex = UserSettingsService.FoldersSettingsService.DefaultSortOption == SortOption.FileTag ? FileTagSortingIndex : (int)UserSettingsService.FoldersSettingsService.DefaultSortOption;
SelectedDefaultGroupingIndex = UserSettingsService.FoldersSettingsService.DefaultGroupOption == GroupOption.FileTag ? FileTagGroupingIndex : (int)UserSettingsService.FoldersSettingsService.DefaultGroupOption;
}

// Properties
Expand Down Expand Up @@ -239,6 +246,34 @@ public bool CalculateFolderSizes
}
}

private int selectedDefaultSortingIndex;
public int SelectedDefaultSortingIndex
{
get => selectedDefaultSortingIndex;
set
{
if (SetProperty(ref selectedDefaultSortingIndex, value))
{
OnPropertyChanged(nameof(SelectedDefaultSortingIndex));
UserSettingsService.FoldersSettingsService.DefaultSortOption = value == FileTagSortingIndex ? SortOption.FileTag : (SortOption)value;
}
}
}

private int selectedDefaultGroupingIndex;
public int SelectedDefaultGroupingIndex
{
get => selectedDefaultGroupingIndex;
set
{
if (SetProperty(ref selectedDefaultGroupingIndex, value))
{
OnPropertyChanged(nameof(SelectedDefaultGroupingIndex));
UserSettingsService.FoldersSettingsService.DefaultGroupOption = value == FileTagGroupingIndex ? GroupOption.FileTag : (GroupOption)value;
}
}
}

// Local methods

public void ResetLayoutPreferences()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public string Text
{
if (Path == "Home".GetLocalizedResource())
return "Home".GetLocalizedResource();
return (Path == CommonPaths.RecycleBinPath)
return (Path == CommonPaths.RecycleBinPath)
? ApplicationData.Current.LocalSettings.Values.Get("RecycleBin_Title", "Recycle Bin")
: Path;
}
Expand Down
35 changes: 35 additions & 0 deletions src/Files.App/Views/SettingsPages/Folders.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,41 @@
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>

<!-- Default sorting and grouping options -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=SortingAndGrouping}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE8CB;" />
</local:SettingsBlockControl.Icon>
<local:SettingsBlockControl.ExpandableContent>
<StackPanel>
<!-- Sorting Options -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=SortBy}" HorizontalAlignment="Stretch">
<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=SortBy}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultSortingIndex, Mode=TwoWay}">
<ComboBoxItem Content="{helpers:ResourceString Name=Name}" />
<ComboBoxItem Content="{helpers:ResourceString Name=DateModifiedLowerCase}" />
<ComboBoxItem Content="{helpers:ResourceString Name=DateCreated}" />
<ComboBoxItem Content="{helpers:ResourceString Name=Size}" />
<ComboBoxItem Content="{helpers:ResourceString Name=BaseLayoutContextFlyoutSortByType/Text}" />
<ComboBoxItem Content="{helpers:ResourceString Name=Tag}" />
</ComboBox>
</local:SettingsBlockControl>

<!-- Grouping Options -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=GroupBy}" HorizontalAlignment="Stretch">
<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=GroupBy}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultGroupingIndex, Mode=TwoWay}">
<ComboBoxItem Content="{helpers:ResourceString Name=None}" />
<ComboBoxItem Content="{helpers:ResourceString Name=Name}" />
<ComboBoxItem Content="{helpers:ResourceString Name=DateModifiedLowerCase}" />
<ComboBoxItem Content="{helpers:ResourceString Name=DateCreated}" />
<ComboBoxItem Content="{helpers:ResourceString Name=Size}" />
<ComboBoxItem Content="{helpers:ResourceString Name=BaseLayoutContextFlyoutSortByType/Text}" />
<ComboBoxItem Content="{helpers:ResourceString Name=Tag}" />
</ComboBox>
</local:SettingsBlockControl>
</StackPanel>
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>

<!-- Layout mode -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=LayoutMode}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
Expand Down
10 changes: 10 additions & 0 deletions src/Files.Backend/Services/Settings/IFoldersSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,15 @@ public interface IFoldersSettingsService : IBaseSettingsService, INotifyProperty
/// Gets or sets a value indicating whether or not to show folder size.
/// </summary>
bool CalculateFolderSizes { get; set; }

/// <summary>
/// Gets or sets a value indicating the default sorting option.
/// </summary>
SortOption DefaultSortOption { get; set; }

/// <summary>
/// Gets or sets a value indicating the default grouping option.
/// </summary>
GroupOption DefaultGroupOption { get; set; }
}
}
5 changes: 0 additions & 5 deletions src/Files.Backend/Services/Settings/ILayoutSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ public interface ILayoutSettingsService : IBaseSettingsService, INotifyPropertyC
{
int DefaultGridViewSize { get; set; }

// move to folder settings and add UI to settings pages
SortDirection DefaultDirectorySortDirection { get; set; }

SortOption DefaultDirectorySortOption { get; set; }

bool DefaultSortDirectoriesAlongsideFiles { get; set; }

GroupOption DefaultDirectoryGroupOption { get; set; }
}
}
6 changes: 3 additions & 3 deletions src/Files.Shared/Enums/SortOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public enum SortOption : byte
DateCreated,
Size,
FileType,
SyncStatus,
SyncStatus, // Cloud drive
FileTag,
OriginalFolder,
DateDeleted
OriginalFolder, // Recycle bin
DateDeleted // Recycle bin
}
}