Skip to content

Commit ea43865

Browse files
Feature: Added support for hiding compression options from the context menu (#14330)
1 parent 732f13a commit ea43865

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

src/Files.App/Helpers/MenuFlyout/ContextFlyoutItemHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
515515
new ContextMenuFlyoutItemViewModelBuilder(commands.CompressIntoZip).Build(),
516516
new ContextMenuFlyoutItemViewModelBuilder(commands.CompressIntoSevenZip).Build(),
517517
},
518-
ShowItem = itemsSelected && CompressHelper.CanCompress(selectedItems)
518+
ShowItem = userSettingsService.GeneralSettingsService.ShowCompressionOptions && itemsSelected && CompressHelper.CanCompress(selectedItems)
519519
},
520520
new ContextMenuFlyoutItemViewModel
521521
{
@@ -532,7 +532,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
532532
new ContextMenuFlyoutItemViewModelBuilder(commands.DecompressArchiveHere).Build(),
533533
new ContextMenuFlyoutItemViewModelBuilder(commands.DecompressArchiveToChildFolder).Build(),
534534
},
535-
ShowItem = CompressHelper.CanDecompress(selectedItems)
535+
ShowItem = userSettingsService.GeneralSettingsService.ShowCompressionOptions && CompressHelper.CanDecompress(selectedItems)
536536
},
537537
new ContextMenuFlyoutItemViewModel()
538538
{

src/Files.App/Services/Settings/GeneralSettingsService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ public bool ShowEditTagsMenu
187187
set => Set(value);
188188
}
189189

190+
public bool ShowCompressionOptions
191+
{
192+
get => Get(true);
193+
set => Set(value);
194+
}
195+
190196
public bool ShowSendToMenu
191197
{
192198
get => Get(true);

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,9 @@
22292229
<data name="ShowEditTagsMenu" xml:space="preserve">
22302230
<value>Show edit tags flyout</value>
22312231
</data>
2232+
<data name="ShowCompressionOptions" xml:space="preserve">
2233+
<value>Show compression options</value>
2234+
</data>
22322235
<data name="ShowSendToMenu" xml:space="preserve">
22332236
<value>Show Send To menu</value>
22342237
</data>

src/Files.App/ViewModels/Settings/GeneralViewModel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,19 @@ public bool ShowOpenInNewTab
423423
}
424424
}
425425

426+
public bool ShowCompressionOptions
427+
{
428+
get => UserSettingsService.GeneralSettingsService.ShowCompressionOptions;
429+
set
430+
{
431+
if (value == UserSettingsService.GeneralSettingsService.ShowCompressionOptions)
432+
return;
433+
434+
UserSettingsService.GeneralSettingsService.ShowCompressionOptions = value;
435+
OnPropertyChanged();
436+
}
437+
}
438+
426439
public bool ShowSendToMenu
427440
{
428441
get => UserSettingsService.GeneralSettingsService.ShowSendToMenu;

src/Files.App/Views/Settings/GeneralPage.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@
294294
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
295295
</local:SettingsBlockControl>
296296

297+
<!-- Compression options -->
298+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowCompressionOptions}" HorizontalAlignment="Stretch">
299+
<ToggleSwitch
300+
AutomationProperties.Name="{helpers:ResourceString Name=ShowCompressionOptions}"
301+
IsOn="{x:Bind ViewModel.ShowCompressionOptions, Mode=TwoWay}"
302+
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
303+
</local:SettingsBlockControl>
304+
297305
<!-- Send To -->
298306
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowSendToMenu}" HorizontalAlignment="Stretch">
299307
<ToggleSwitch

src/Files.Core/Services/Settings/IGeneralSettingsService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
169169
/// </summary>
170170
bool ShowOpenInNewPane { get; set; }
171171

172+
/// <summary>
173+
/// Gets or sets a value indicating whether or not to show the compression options e.g. create archive, extract files.
174+
/// </summary>
175+
bool ShowCompressionOptions { get; set; }
176+
172177
/// <summary>
173178
/// Gets or sets a value indicating whether or not to show the Send To menu.
174179
/// </summary>

0 commit comments

Comments
 (0)