@@ -43,6 +43,7 @@ public FolderSettingsViewModel()
4343 ToggleLayoutModeAdaptiveCommand = new RelayCommand ( ToggleLayoutModeAdaptive ) ;
4444
4545 ChangeGroupOptionCommand = new RelayCommand < GroupOption > ( ChangeGroupOption ) ;
46+ ChangeGroupDirectionCommand = new RelayCommand < SortDirection > ( ChangeGroupDirection ) ;
4647 }
4748 public FolderSettingsViewModel ( FolderLayoutModes modeOverride ) : this ( )
4849 => ( rootLayoutMode , LayoutPreference . IsAdaptiveLayoutOverridden ) = ( modeOverride , true ) ;
@@ -215,6 +216,8 @@ public int GridViewSize
215216
216217 public event EventHandler < SortDirection > ? SortDirectionPreferenceUpdated ;
217218
219+ public event EventHandler < SortDirection > ? GroupDirectionPreferenceUpdated ;
220+
218221 public event EventHandler < bool > ? SortDirectoriesAlongsideFilesPreferenceUpdated ;
219222
220223 public SortOption DirectorySortOption
@@ -258,6 +261,21 @@ public SortDirection DirectorySortDirection
258261 }
259262 }
260263
264+ public ICommand ChangeGroupDirectionCommand { get ; }
265+
266+ public SortDirection DirectoryGroupDirection
267+ {
268+ get => LayoutPreference . DirectoryGroupDirection ;
269+ set
270+ {
271+ if ( SetProperty ( ref LayoutPreference . DirectoryGroupDirection , value , nameof ( DirectoryGroupDirection ) ) )
272+ {
273+ LayoutPreferencesUpdateRequired ? . Invoke ( this , new LayoutPreferenceEventArgs ( LayoutPreference ) ) ;
274+ GroupDirectionPreferenceUpdated ? . Invoke ( this , DirectoryGroupDirection ) ;
275+ }
276+ }
277+ }
278+
261279 public bool SortDirectoriesAlongsideFiles
262280 {
263281 get
@@ -327,6 +345,7 @@ public static void SetLayoutPreferencesForPath(string folderPath, LayoutPreferen
327345 userSettingsService . FoldersSettingsService . DefaultGroupOption = prefs . DirectoryGroupOption ;
328346 }
329347 userSettingsService . LayoutSettingsService . DefaultDirectorySortDirection = prefs . DirectorySortDirection ;
348+ userSettingsService . LayoutSettingsService . DefaultDirectoryGroupDirection = prefs . DirectoryGroupDirection ;
330349 userSettingsService . LayoutSettingsService . DefaultSortDirectoriesAlongsideFiles = prefs . SortDirectoriesAlongsideFiles ;
331350
332351 userSettingsService . FoldersSettingsService . ShowDateColumn = ! prefs . ColumnsViewModel . DateModifiedColumn . UserCollapsed ;
@@ -376,7 +395,10 @@ private static LayoutPreferences GetDefaultLayoutPreferences(string folderPath)
376395
377396 if ( folderPath == CommonPaths . DownloadsPath )
378397 // Default for downloads folder is to group by date created
379- return new LayoutPreferences ( ) { DirectoryGroupOption = GroupOption . DateCreated } ;
398+ return new LayoutPreferences ( ) {
399+ DirectoryGroupOption = GroupOption . DateCreated ,
400+ DirectoryGroupDirection = SortDirection . Descending
401+ } ;
380402 else if ( LibraryManager . IsLibraryPath ( folderPath ) )
381403 // Default for libraries is to group by folder path
382404 return new LayoutPreferences ( ) { DirectoryGroupOption = GroupOption . FolderPath } ;
@@ -414,6 +436,7 @@ private set
414436 OnPropertyChanged ( nameof ( DirectoryGroupOption ) ) ;
415437 OnPropertyChanged ( nameof ( DirectorySortOption ) ) ;
416438 OnPropertyChanged ( nameof ( DirectorySortDirection ) ) ;
439+ OnPropertyChanged ( nameof ( DirectoryGroupDirection ) ) ;
417440 OnPropertyChanged ( nameof ( SortDirectoriesAlongsideFiles ) ) ;
418441 OnPropertyChanged ( nameof ( ColumnsViewModel ) ) ;
419442 }
@@ -498,6 +521,8 @@ public void ToggleLayoutModeAdaptive()
498521
499522 private void ChangeGroupOption ( GroupOption option ) => DirectoryGroupOption = option ;
500523
524+ private void ChangeGroupDirection ( SortDirection option ) => DirectoryGroupDirection = option ;
525+
501526 public void OnDefaultPreferencesChanged ( string folderPath , string settingsName )
502527 {
503528 var prefs = GetLayoutPreferencesForPath ( folderPath ) ;
0 commit comments