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

Added button to reset layout preferences in settings #9787

Merged
merged 6 commits into from Aug 22, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Files.Uwp/Strings/en-US/Resources.resw
Expand Up @@ -2795,8 +2795,8 @@ We use App Center to track which settings are being used, find bugs, and fix cra
<data name="SetAsDefault" xml:space="preserve">
<value>Set as default</value>
</data>
<data name="DefaultFolderPreferences" xml:space="preserve">
<value>Default Folder preferences</value>
<data name="FolderPreferences" xml:space="preserve">
<value>Folder preferences</value>
</data>
<data name="DisplayDateColumn" xml:space="preserve">
<value>Display Date column</value>
Expand All @@ -2813,6 +2813,15 @@ We use App Center to track which settings are being used, find bugs, and fix cra
<data name="DisplayTypeColumn" xml:space="preserve">
<value>Display Type column</value>
</data>
<data name="Reset" xml:space="preserve">
<value>Reset</value>
</data>
<data name="ResetLayoutPreferences" xml:space="preserve">
<value>This action will reset all directories back to your default preferences.</value>
</data>
<data name="AreYouSure" xml:space="preserve">
<value>Are you sure?</value>
</data>
<data name="Lockscreen" xml:space="preserve">
<value>Lockscreen</value>
</data>
Expand Down
Expand Up @@ -23,6 +23,7 @@
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.System;
using Windows.UI.Xaml.Controls;
using static Files.Uwp.Helpers.MenuFlyoutHelper;

namespace Files.Uwp.ViewModels.SettingsViewModels
Expand All @@ -46,11 +47,16 @@ public class PreferencesViewModel : ObservableObject, IDisposable

public ICommand OpenFilesAtStartupCommand { get; }

public ICommand ResetLayoutPreferencesCommand { get; }
public ICommand ShowResetLayoutPreferencesTipCommand { get; }

public PreferencesViewModel()
{
ChangePageCommand = new AsyncRelayCommand(ChangePage);
RemovePageCommand = new RelayCommand(RemovePage);
AddPageCommand = new RelayCommand<string>(async (path) => await AddPage(path));
ResetLayoutPreferencesCommand = new RelayCommand(ResetLayoutPreferences);
ShowResetLayoutPreferencesTipCommand = new RelayCommand(() => IsResetLayoutPreferencesTipOpen = true);

DefaultLanguages = App.AppSettings.DefaultLanguages;
Terminals = App.TerminalController.Model.Terminals;
Expand Down Expand Up @@ -716,6 +722,27 @@ public bool ShowDateColumn
}
}

private bool isLayoutResetCheckmarkVisible;
public bool IsLayoutResetCheckmarkVisible
{
get => isLayoutResetCheckmarkVisible;
set => SetProperty(ref isLayoutResetCheckmarkVisible, value);
}

private bool isResetLayoutPreferencesTipOpen;
public bool IsResetLayoutPreferencesTipOpen
{
get => isResetLayoutPreferencesTipOpen;
set => SetProperty(ref isResetLayoutPreferencesTipOpen, value);
}

public void ResetLayoutPreferences()
{
FolderSettingsViewModel.DbInstance.ResetAll();
IsResetLayoutPreferencesTipOpen = false;
IsLayoutResetCheckmarkVisible = true;
}

public void Dispose()
{
if (!disposed)
Expand Down