Skip to content

Commit 344a890

Browse files
authored
Feature: Added support for turning off file extension warning (#11880)
1 parent 67aa1e0 commit 344a890

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed

src/Files.App/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,14 @@ await DialogDisplayHelper.ShowDialogAsync(
561561
history = await filesystemOperations.RenameAsync(source, newName, collision, progress, cancellationToken);
562562
break;
563563

564+
// Prompt user when extension has changed, not when file name has changed
564565
case FilesystemItemType.File:
565-
if (showExtensionDialog &&
566-
Path.GetExtension(source.Path) != Path.GetExtension(newName)) // Only prompt user when extension has changed, not when file name has changed
566+
if
567+
(
568+
showExtensionDialog &&
569+
Path.GetExtension(source.Path) != Path.GetExtension(newName) &&
570+
UserSettingsService.FoldersSettingsService.ShowFileExtensionWarning
571+
)
567572
{
568573
var yesSelected = await DialogDisplayHelper.ShowDialogAsync("Rename".GetLocalizedResource(), "RenameFileDialog/Text".GetLocalizedResource(), "Yes".GetLocalizedResource(), "No".GetLocalizedResource());
569574
if (yesSelected)

src/Files.App/ServicesImplementation/Settings/FoldersSettingsService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ public bool DoubleClickToGoUp
268268
set => Set(value);
269269
}
270270

271+
public bool ShowFileExtensionWarning
272+
{
273+
get => Get(true);
274+
set => Set(value);
275+
}
276+
271277
protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
272278
{
273279
switch (e.SettingName)
@@ -298,6 +304,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
298304
case nameof(DeleteConfirmationPolicy):
299305
case nameof(SelectFilesOnHover):
300306
case nameof(DoubleClickToGoUp):
307+
case nameof(ShowFileExtensionWarning):
301308
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
302309
break;
303310
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2667,4 +2667,7 @@
26672667
<data name="ToggleSelect" xml:space="preserve">
26682668
<value>Toggle Selection</value>
26692669
</data>
2670-
</root>
2670+
<data name="ShowFileExtensionWarning" xml:space="preserve">
2671+
<value>Show warning when changing file extensions</value>
2672+
</data>
2673+
</root>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,20 @@ public bool DoubleClickToGoUp
407407
}
408408
}
409409

410+
public bool ShowFileExtensionWarning
411+
{
412+
get => UserSettingsService.FoldersSettingsService.ShowFileExtensionWarning;
413+
set
414+
{
415+
if (value != UserSettingsService.FoldersSettingsService.ShowFileExtensionWarning)
416+
{
417+
UserSettingsService.FoldersSettingsService.ShowFileExtensionWarning = value;
418+
419+
OnPropertyChanged();
420+
}
421+
}
422+
}
423+
410424
public void ResetLayoutPreferences()
411425
{
412426
// Is this proper practice?

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,18 @@
289289
<ComboBoxItem Content="{helpers:ResourceString Name=Never}" />
290290
</ComboBox>
291291
</local:SettingsBlockControl>
292+
293+
<!-- File Extension Warning -->
294+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ShowFileExtensionWarning}" HorizontalAlignment="Stretch">
295+
<local:SettingsBlockControl.Icon>
296+
<FontIcon Glyph="&#xE8AC;" />
297+
</local:SettingsBlockControl.Icon>
298+
299+
<ToggleSwitch
300+
AutomationProperties.Name="{helpers:ResourceString Name=ShowFileExtensionWarning}"
301+
IsOn="{x:Bind ViewModel.ShowFileExtensionWarning, Mode=TwoWay}"
302+
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
303+
</local:SettingsBlockControl>
292304

293305
<!-- Select On Hover -->
294306
<local:SettingsBlockControl Title="{helpers:ResourceString Name=SelectFilesAndFoldersOnHover}" HorizontalAlignment="Stretch">

src/Files.Backend/Services/Settings/IFoldersSettingsService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,10 @@ public interface IFoldersSettingsService : IBaseSettingsService, INotifyProperty
189189
/// Gets or sets a value indicating if double clicking a blank space should go up a directory.
190190
/// </summary>
191191
bool DoubleClickToGoUp { get; set; }
192+
193+
/// <summary>
194+
/// Gets or sets a value indicating if a warning dialog show be shown when changing file extensions.
195+
/// </summary>
196+
bool ShowFileExtensionWarning { get; set; }
192197
}
193198
}

0 commit comments

Comments
 (0)