Skip to content
Closed
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
5 changes: 5 additions & 0 deletions src/Files.App/Data/Contracts/IAppearanceSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,10 @@ public interface IAppearanceSettingsService : IBaseSettingsService, INotifyPrope
/// Gets or sets a value whether the home button should be displayed.
/// </summary>
bool ShowHomeButton { get; set; }

/// <summary>
/// Gets or sets a value whether the file extension should be displayed always or only during the editing.
/// </summary>
bool ShowFileExtensionsOnlyWhileEditing { get; set; }
}
}
9 changes: 8 additions & 1 deletion src/Files.App/Services/Settings/AppearanceSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ public bool ShowTabActions
/// <inheritdoc/>
public bool ShowHomeButton
{
get => Get(false);
get => Get(true);
set => Set(value);
}

/// <inheritdoc/>
public bool ShowFileExtensionsOnlyWhileEditing
{
get => Get<bool>(true);
set => Set(value);
}

Expand Down
21 changes: 18 additions & 3 deletions src/Files.App/Services/Storage/StorageCacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,28 @@ internal sealed class StorageCacheService : IStorageCacheService
{
private readonly ConcurrentDictionary<string, string> cachedDictionary = new();

private readonly IUserSettingsService _userSettingsService;

public StorageCacheService(IUserSettingsService userSettingsService)
{
_userSettingsService = userSettingsService;
}

/// <inheritdoc/>
public ValueTask<string> GetDisplayName(string path, CancellationToken cancellationToken)
{
return
cachedDictionary.TryGetValue(path, out var displayName)
if (_userSettingsService.AppearanceSettingsService.ShowFileExtensionsOnlyWhileEditing)
{
return cachedDictionary.TryGetValue(path, out var displayName)
? ValueTask.FromResult(displayName)
: ValueTask.FromResult(string.Empty);
: ValueTask.FromResult(SystemIO.Path.GetFileName(path));
}
else
{
return cachedDictionary.TryGetValue(path, out var displayName)
? ValueTask.FromResult(SystemIO.Path.GetFileNameWithoutExtension(displayName))
: ValueTask.FromResult(SystemIO.Path.GetFileNameWithoutExtension(path));
}
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ CancellationToken cancellationToken
)
{
var itemPath = Path.Combine(pathRoot, findData.cFileName);
var itemName = findData.cFileName;

var itemName = await fileListCache.GetDisplayName(itemPath, cancellationToken);
if (string.IsNullOrEmpty(itemName))
itemName = findData.cFileName;

DateTime itemModifiedDate, itemCreatedDate, itemLastAccessDate;

Expand Down
14 changes: 14 additions & 0 deletions src/Files.App/ViewModels/Settings/AppearanceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,19 @@ public bool ShowHomeButton
}
}
}

public bool ShowFileExtensions
{
get => UserSettingsService.AppearanceSettingsService.ShowFileExtensionsOnlyWhileEditing;
set
{
if (value != UserSettingsService.AppearanceSettingsService.ShowFileExtensionsOnlyWhileEditing)
{
UserSettingsService.AppearanceSettingsService.ShowFileExtensionsOnlyWhileEditing = value;

OnPropertyChanged();
}
}
}
}
}
5 changes: 5 additions & 0 deletions src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ override public void StartRenameItem()
return;

Grid.SetColumnSpan(textBox.FindParent<Grid>(), 8);

if (RenamingItem is ListedItem item)
{
textBox.Text = SystemIO.Path.GetFileName(item.ItemPath);
}
}

private void ItemNameTextBox_BeforeTextChanging(TextBox textBox, TextBoxBeforeTextChangingEventArgs args)
Expand Down
9 changes: 9 additions & 0 deletions src/Files.App/Views/Settings/AppearancePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@
IsOn="{x:Bind ViewModel.ShowToolbar, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Show file extensions -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowFileExtensions}" HorizontalAlignment="Stretch">
<ToggleSwitch
AutomationProperties.AutomationControlType="Custom"
AutomationProperties.Name="{helpers:ResourceString Name=ShowFileExtensions}"
IsOn="{x:Bind ViewModel.ShowFileExtensions, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>
</StackPanel>
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>
Expand Down