Skip to content

Feature: Added an action to toggle the dot files setting #15906

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

Merged
merged 2 commits into from
Jul 31, 2024
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
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