Skip to content

Commit

Permalink
Feature: Added an option to hide checkboxes in the details layout (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
hishitetsu authored Apr 16, 2023
1 parent 0a4985b commit 1457331
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ public bool ShowFileExtensionWarning
set => Set(value);
}

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

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
Expand Down Expand Up @@ -305,6 +311,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(SelectFilesOnHover):
case nameof(DoubleClickToGoUp):
case nameof(ShowFileExtensionWarning):
case nameof(ShowCheckboxesInDetailsLayout):
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
break;
}
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 @@ -3178,4 +3178,7 @@
<data name="MoveFileWithoutProperties" xml:space="preserve">
<value>Are you sure you want to move these files without their properties?</value>
</data>
<data name="ShowCheckboxesInDetailsLayout" xml:space="preserve">
<value>Show checkboxes when selecting items in the details layout</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/Files.App/ViewModels/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ private async void UserSettingsService_OnSettingChangedEvent(object? sender, Set
case nameof(UserSettingsService.FoldersSettingsService.ShowDotFiles):
case nameof(UserSettingsService.FoldersSettingsService.CalculateFolderSizes):
case nameof(UserSettingsService.FoldersSettingsService.SelectFilesOnHover):
case nameof(UserSettingsService.FoldersSettingsService.ShowCheckboxesInDetailsLayout):
await dispatcherQueue.EnqueueAsync(() =>
{
if (WorkingDirectory != "Home")
Expand Down
14 changes: 14 additions & 0 deletions src/Files.App/ViewModels/Settings/FoldersViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,20 @@ public bool ShowFileExtensionWarning
}
}

public bool ShowCheckboxesInDetailsLayout
{
get => UserSettingsService.FoldersSettingsService.ShowCheckboxesInDetailsLayout;
set
{
if (value != UserSettingsService.FoldersSettingsService.ShowCheckboxesInDetailsLayout)
{
UserSettingsService.FoldersSettingsService.ShowCheckboxesInDetailsLayout = value;

OnPropertyChanged();
}
}
}

public void ResetLayoutPreferences()
{
// Is this proper practice?
Expand Down
5 changes: 4 additions & 1 deletion src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,10 @@ private void UpdateCheckboxVisibility(object sender, bool isPointerOver)
if (sender is ListViewItem control && control.FindDescendant<UserControl>() is UserControl userControl)
{
// Handle visual states
if (control.IsSelected || isPointerOver || (control.FindDescendant("SelectionCheckbox") as CheckBox)!.IsPointerOver)
// Show checkboxes when hovering of the thumbnail as long as one item is selected (regardless of the setting to hide them)
// Show checkboxes when items are selected (as long as the setting is enabled)
if (UserSettingsService.FoldersSettingsService.ShowCheckboxesInDetailsLayout && control.IsSelected
|| isPointerOver || (control.FindDescendant("SelectionCheckbox") as CheckBox)!.IsPointerOver)
VisualStateManager.GoToState(userControl, "ShowCheckbox", true);
else
VisualStateManager.GoToState(userControl, "HideCheckbox", true);
Expand Down
13 changes: 12 additions & 1 deletion src/Files.App/Views/Settings/FoldersPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Show Checkboxes in the Details Layout -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowCheckboxesInDetailsLayout}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE73A;" />
</local:SettingsBlockControl.Icon>
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowCheckboxesInDetailsLayout}"
IsOn="{x:Bind ViewModel.ShowCheckboxesInDetailsLayout, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Behaviors -->
<TextBlock
Padding="0,12,0,4"
Expand Down Expand Up @@ -289,7 +300,7 @@
<ComboBoxItem Content="{helpers:ResourceString Name=Never}" />
</ComboBox>
</local:SettingsBlockControl>

<!-- File Extension Warning -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowFileExtensionWarning}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,10 @@ public interface IFoldersSettingsService : IBaseSettingsService, INotifyProperty
/// Gets or sets a value indicating if a warning dialog show be shown when changing file extensions.
/// </summary>
bool ShowFileExtensionWarning { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to show checkboxes when selecting items in the details layout.
/// </summary>
bool ShowCheckboxesInDetailsLayout { get; set; }
}
}

0 comments on commit 1457331

Please sign in to comment.