Skip to content

Commit

Permalink
Feature: Added support for hiding compression options from the contex…
Browse files Browse the repository at this point in the history
  • Loading branch information
mafra99 committed Dec 31, 2023
1 parent 732f13a commit ea43865
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/MenuFlyout/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi
new ContextMenuFlyoutItemViewModelBuilder(commands.CompressIntoZip).Build(),
new ContextMenuFlyoutItemViewModelBuilder(commands.CompressIntoSevenZip).Build(),
},
ShowItem = itemsSelected && CompressHelper.CanCompress(selectedItems)
ShowItem = userSettingsService.GeneralSettingsService.ShowCompressionOptions && itemsSelected && CompressHelper.CanCompress(selectedItems)
},
new ContextMenuFlyoutItemViewModel
{
Expand All @@ -532,7 +532,7 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi
new ContextMenuFlyoutItemViewModelBuilder(commands.DecompressArchiveHere).Build(),
new ContextMenuFlyoutItemViewModelBuilder(commands.DecompressArchiveToChildFolder).Build(),
},
ShowItem = CompressHelper.CanDecompress(selectedItems)
ShowItem = userSettingsService.GeneralSettingsService.ShowCompressionOptions && CompressHelper.CanDecompress(selectedItems)
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down
6 changes: 6 additions & 0 deletions src/Files.App/Services/Settings/GeneralSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ public bool ShowEditTagsMenu
set => Set(value);
}

public bool ShowCompressionOptions
{
get => Get(true);
set => Set(value);
}

public bool ShowSendToMenu
{
get => Get(true);
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 @@ -2229,6 +2229,9 @@
<data name="ShowEditTagsMenu" xml:space="preserve">
<value>Show edit tags flyout</value>
</data>
<data name="ShowCompressionOptions" xml:space="preserve">
<value>Show compression options</value>
</data>
<data name="ShowSendToMenu" xml:space="preserve">
<value>Show Send To menu</value>
</data>
Expand Down
13 changes: 13 additions & 0 deletions src/Files.App/ViewModels/Settings/GeneralViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,19 @@ public bool ShowOpenInNewTab
}
}

public bool ShowCompressionOptions
{
get => UserSettingsService.GeneralSettingsService.ShowCompressionOptions;
set
{
if (value == UserSettingsService.GeneralSettingsService.ShowCompressionOptions)
return;

UserSettingsService.GeneralSettingsService.ShowCompressionOptions = value;
OnPropertyChanged();
}
}

public bool ShowSendToMenu
{
get => UserSettingsService.GeneralSettingsService.ShowSendToMenu;
Expand Down
8 changes: 8 additions & 0 deletions src/Files.App/Views/Settings/GeneralPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Compression options -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowCompressionOptions}" HorizontalAlignment="Stretch">
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowCompressionOptions}"
IsOn="{x:Bind ViewModel.ShowCompressionOptions, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Send To -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowSendToMenu}" HorizontalAlignment="Stretch">
<ToggleSwitch
Expand Down
5 changes: 5 additions & 0 deletions src/Files.Core/Services/Settings/IGeneralSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
/// </summary>
bool ShowOpenInNewPane { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to show the compression options e.g. create archive, extract files.
/// </summary>
bool ShowCompressionOptions { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to show the Send To menu.
/// </summary>
Expand Down

0 comments on commit ea43865

Please sign in to comment.