Skip to content

Feature: Added an option to hide checkboxes in the details layout #12083

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 6 commits into from
Apr 16, 2023
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
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; }
}
}