Skip to content
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 @@ -561,9 +561,14 @@ await DialogDisplayHelper.ShowDialogAsync(
history = await filesystemOperations.RenameAsync(source, newName, collision, progress, cancellationToken);
break;

// Prompt user when extension has changed, not when file name has changed
case FilesystemItemType.File:
if (showExtensionDialog &&
Path.GetExtension(source.Path) != Path.GetExtension(newName)) // Only prompt user when extension has changed, not when file name has changed
if
(
showExtensionDialog &&
Path.GetExtension(source.Path) != Path.GetExtension(newName) &&
UserSettingsService.FoldersSettingsService.ShowFileExtensionWarning
)
{
var yesSelected = await DialogDisplayHelper.ShowDialogAsync("Rename".GetLocalizedResource(), "RenameFileDialog/Text".GetLocalizedResource(), "Yes".GetLocalizedResource(), "No".GetLocalizedResource());
if (yesSelected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ public bool DoubleClickToGoUp
set => Set(value);
}

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

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
Expand Down Expand Up @@ -298,6 +304,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(DeleteConfirmationPolicy):
case nameof(SelectFilesOnHover):
case nameof(DoubleClickToGoUp):
case nameof(ShowFileExtensionWarning):
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
break;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2667,4 +2667,7 @@
<data name="ToggleSelect" xml:space="preserve">
<value>Toggle Selection</value>
</data>
</root>
<data name="ShowFileExtensionWarning" xml:space="preserve">
<value>Show warning when changing file extensions</value>
</data>
</root>
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 @@ -407,6 +407,20 @@ public bool DoubleClickToGoUp
}
}

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

OnPropertyChanged();
}
}
}

public void ResetLayoutPreferences()
{
// Is this proper practice?
Expand Down
12 changes: 12 additions & 0 deletions src/Files.App/Views/Settings/FoldersPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,18 @@
<ComboBoxItem Content="{helpers:ResourceString Name=Never}" />
</ComboBox>
</local:SettingsBlockControl>

<!-- File Extension Warning -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowFileExtensionWarning}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE8AC;" />
</local:SettingsBlockControl.Icon>

<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowFileExtensionWarning}"
IsOn="{x:Bind ViewModel.ShowFileExtensionWarning, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Select On Hover -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=SelectFilesAndFoldersOnHover}" HorizontalAlignment="Stretch">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,10 @@ public interface IFoldersSettingsService : IBaseSettingsService, INotifyProperty
/// Gets or sets a value indicating if double clicking a blank space should go up a directory.
/// </summary>
bool DoubleClickToGoUp { get; set; }

/// <summary>
/// Gets or sets a value indicating if a warning dialog show be shown when changing file extensions.
/// </summary>
bool ShowFileExtensionWarning { get; set; }
}
}