Skip to content

Commit

Permalink
Feature: Added an action to toggle the dot files setting (files-commu…
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 authored Jul 31, 2024
1 parent 5aedca3 commit 2c98606
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Files.App/Actions/Show/ToggleDotFilesSettingAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Actions
{
internal sealed class ToggleDotFilesSettingAction : ObservableObject, IToggleAction
{
private readonly IFoldersSettingsService FoldersSettingsService;

public string Label
=> "ShowDotFiles".GetLocalizedResource();

public string Description
=> "ToggleDotFilesSettingDescription".GetLocalizedResource();

public bool IsOn
=> FoldersSettingsService.ShowDotFiles;

public ToggleDotFilesSettingAction()
{
FoldersSettingsService = Ioc.Default.GetRequiredService<IFoldersSettingsService>();

FoldersSettingsService.PropertyChanged += Settings_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
FoldersSettingsService.ShowDotFiles = !FoldersSettingsService.ShowDotFiles;

return Task.CompletedTask;
}

private void Settings_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(IFoldersSettingsService.ShowDotFiles))
OnPropertyChanged(nameof(IsOn));
}
}
}
1 change: 1 addition & 0 deletions src/Files.App/Data/Commands/Manager/CommandCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum CommandCodes

// Show
ToggleShowHiddenItems,
ToggleDotFilesSetting,
ToggleShowFileExtensions,
TogglePreviewPane,
ToggleDetailsPane,
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Data/Commands/Manager/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public IRichCommand this[HotKey hotKey]
public IRichCommand Redo => commands[CommandCodes.Redo];
public IRichCommand Undo => commands[CommandCodes.Undo];
public IRichCommand ToggleShowHiddenItems => commands[CommandCodes.ToggleShowHiddenItems];
public IRichCommand ToggleDotFilesSetting => commands[CommandCodes.ToggleDotFilesSetting];
public IRichCommand ToggleShowFileExtensions => commands[CommandCodes.ToggleShowFileExtensions];
public IRichCommand TogglePreviewPane => commands[CommandCodes.TogglePreviewPane];
public IRichCommand ToggleDetailsPane => commands[CommandCodes.ToggleDetailsPane];
Expand Down Expand Up @@ -237,6 +238,7 @@ public IEnumerator<IRichCommand> GetEnumerator() =>
[CommandCodes.Redo] = new RedoAction(),
[CommandCodes.Undo] = new UndoAction(),
[CommandCodes.ToggleShowHiddenItems] = new ToggleShowHiddenItemsAction(),
[CommandCodes.ToggleDotFilesSetting] = new ToggleDotFilesSettingAction(),
[CommandCodes.ToggleShowFileExtensions] = new ToggleShowFileExtensionsAction(),
[CommandCodes.TogglePreviewPane] = new TogglePreviewPaneAction(),
[CommandCodes.ToggleDetailsPane] = new ToggleDetailsPaneAction(),
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Data/Commands/Manager/ICommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface ICommandManager : IEnumerable<IRichCommand>
IRichCommand Undo { get; }

IRichCommand ToggleShowHiddenItems { get; }
IRichCommand ToggleDotFilesSetting { get; }
IRichCommand ToggleShowFileExtensions { get; }
IRichCommand TogglePreviewPane { get; }
IRichCommand ToggleDetailsPane { get; }
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,9 @@
<data name="ToggleShowHiddenItemsDescription" xml:space="preserve">
<value>Toggle whether to show hidden items</value>
</data>
<data name="ToggleDotFilesSettingDescription" xml:space="preserve">
<value>Toggle whether to show dot files</value>
</data>
<data name="ToggleShowFileExtensionsDescription" xml:space="preserve">
<value>Toggle whether to show file extensions</value>
</data>
Expand Down

0 comments on commit 2c98606

Please sign in to comment.