Skip to content

Commit

Permalink
Merge branch 'main' into 12390_DisableDragAndDropWhenAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
QuaintMako authored Aug 7, 2023
2 parents c5123be + b03c2fd commit 13cc213
Show file tree
Hide file tree
Showing 65 changed files with 1,611 additions and 484 deletions.
5 changes: 1 addition & 4 deletions src/Files.App/Actions/Content/Install/InstallFontAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public InstallFontAction()

public Task ExecuteAsync()
{
foreach (ListedItem selectedItem in context.SelectedItems)
Win32API.InstallFont(selectedItem.ItemPath, false);

return Task.CompletedTask;
return Task.WhenAll(context.SelectedItems.Select(x => Win32API.InstallFont(x.ItemPath, false)));
}

public void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
Expand Down
4 changes: 1 addition & 3 deletions src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public RunWithPowershellAction()

public Task ExecuteAsync()
{
Win32API.RunPowershellCommand($"{context.ShellPage?.SlimContentPage?.SelectedItem.ItemPath}", false);

return Task.CompletedTask;
return Win32API.RunPowershellCommandAsync($"{context.ShellPage?.SlimContentPage?.SelectedItem.ItemPath}", false);
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
7 changes: 3 additions & 4 deletions src/Files.App/Actions/FileSystem/FormatDriveAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 Files Community
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Utils.Shell;
Expand All @@ -19,6 +19,7 @@ public string Description

public bool IsExecutable =>
context.HasItem &&
!context.HasSelection &&
(drivesViewModel.Drives.Cast<DriveItem>().FirstOrDefault(x =>
string.Equals(x.Path, context.Folder?.ItemPath))?.MenuOptions.ShowFormatDrive ?? false);

Expand All @@ -32,9 +33,7 @@ public FormatDriveAction()

public Task ExecuteAsync()
{
Win32API.OpenFormatDriveDialog(context.Folder?.ItemPath ?? string.Empty);

return Task.CompletedTask;
return Win32API.OpenFormatDriveDialog(context.Folder?.ItemPath ?? string.Empty);
}

public void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
4 changes: 1 addition & 3 deletions src/Files.App/Actions/Open/OpenInVSAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public OpenInVSAction()

public Task ExecuteAsync()
{
Win32API.RunPowershellCommand($"start \'{_context.SolutionFilePath}\'", false);

return Task.CompletedTask;
return Win32API.RunPowershellCommandAsync($"start \'{_context.SolutionFilePath}\'", false);
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
4 changes: 1 addition & 3 deletions src/Files.App/Actions/Open/OpenInVSCodeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public OpenInVSCodeAction()

public Task ExecuteAsync()
{
Win32API.RunPowershellCommand($"code \'{_context.ShellPage?.FilesystemViewModel.WorkingDirectory}\'", false);

return Task.CompletedTask;
return Win32API.RunPowershellCommandAsync($"code \'{_context.ShellPage?.FilesystemViewModel.WorkingDirectory}\'", false);
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<!-- Default list view item height -->
<x:Double x:Key="ListItemHeight">36</x:Double>

<!-- Default list view item margin -->
<x:Double x:Key="ListItemMargin">0</x:Double>

<!-- Default nav menu item height -->
<x:Double x:Key="NavigationViewItemOnLeftMinHeight">32</x:Double>

Expand Down
28 changes: 11 additions & 17 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ void ClearDisplay()

return;
}
var filesAndFoldersLocal = filesAndFolders.ToList();

// CollectionChanged will cause UI update, which may cause significant performance degradation,
// so suppress CollectionChanged event here while loading items heavily.
Expand Down Expand Up @@ -643,19 +644,19 @@ void ApplyBulkInsertEntries()
}
}

for (var i = 0; i < filesAndFolders.Count; i++)
for (var i = 0; i < filesAndFoldersLocal.Count; i++)
{
if (addFilesCTS.IsCancellationRequested)
return;

if (i < FilesAndFolders.Count)
{
if (FilesAndFolders[i] != filesAndFolders[i])
if (FilesAndFolders[i] != filesAndFoldersLocal[i])
{
if (startIndex == -1)
startIndex = i;

tempList.Add(filesAndFolders[i]);
tempList.Add(filesAndFoldersLocal[i]);
}
else
{
Expand All @@ -665,16 +666,16 @@ void ApplyBulkInsertEntries()
else
{
ApplyBulkInsertEntries();
FilesAndFolders.InsertRange(i, filesAndFolders.ToList().Skip(i));
FilesAndFolders.InsertRange(i, filesAndFoldersLocal.Skip(i));

break;
}
}

ApplyBulkInsertEntries();

if (FilesAndFolders.Count > filesAndFolders.Count)
FilesAndFolders.RemoveRange(filesAndFolders.Count, FilesAndFolders.Count - filesAndFolders.Count);
if (FilesAndFolders.Count > filesAndFoldersLocal.Count)
FilesAndFolders.RemoveRange(filesAndFoldersLocal.Count, FilesAndFolders.Count - filesAndFoldersLocal.Count);

if (folderSettings.DirectoryGroupOption != GroupOption.None)
OrderGroups();
Expand Down Expand Up @@ -1638,9 +1639,9 @@ await Task.Run(async () =>

filesAndFolders.AddRange(fileList);

await dispatcherQueue.EnqueueOrInvokeAsync(CheckForSolutionFile, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
await OrderFilesAndFoldersAsync();
await ApplyFilesAndFoldersChangesAsync();
await dispatcherQueue.EnqueueOrInvokeAsync(CheckForSolutionFile, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
});

rootFolder ??= await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path));
Expand Down Expand Up @@ -1688,16 +1689,9 @@ await Task.Run(async () =>

private void CheckForSolutionFile()
{
for (int i = 0; i < filesAndFolders.Count; i++)
{
if (FileExtensionHelpers.HasExtension(filesAndFolders[i].FileExtension, ".sln"))
{
SolutionFilePath = filesAndFolders[i].ItemPath;
return;
}
}

SolutionFilePath = null;
SolutionFilePath = filesAndFolders.ToList().AsParallel()
.Where(item => FileExtensionHelpers.HasExtension(item.FileExtension, ".sln"))
.FirstOrDefault()?.ItemPath;
}

private async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageItem item)
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Helpers/MenuFlyout/ShellContextMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,25 @@ async Task InvokeShellMenuItem(ContextMenu contextMenu, object? tag)
case "install" when isFont:
{
foreach (string path in contextMenu.ItemsPath)
Win32API.InstallFont(path, false);
await Win32API.InstallFont(path, false);
}
break;

case "installAllUsers" when isFont:
{
foreach (string path in contextMenu.ItemsPath)
Win32API.InstallFont(path, true);
await Win32API.InstallFont(path, true);
}
break;

case "mount":
var vhdPath = contextMenu.ItemsPath[0];
Win32API.MountVhdDisk(vhdPath);
await Win32API.MountVhdDisk(vhdPath);
break;

case "format":
var drivePath = contextMenu.ItemsPath[0];
Win32API.OpenFormatDriveDialog(drivePath);
await Win32API.OpenFormatDriveDialog(drivePath);
break;

default:
Expand Down
36 changes: 36 additions & 0 deletions src/Files.App/ResourceDictionaries/PathIcons.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,42 @@
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ColorIconEditTag" TargetType="local:OpacityIcon">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Viewbox Stretch="Fill">
<Grid Width="16" Height="16">
<Path
x:Name="Path1"
Data="M2.72037 6.7794L4.67008 8.72911C5.07982 9.13885 5.5932 9.42952 6.15535 9.57006L7.65326 9.94454C9.03705 10.2905 10.2905 9.03704 9.94454 7.65326L9.57006 6.15535C9.42952 5.5932 9.13885 5.07981 8.72911 4.67008L6.7794 2.72037L7.70688 1.79289C7.89442 1.60536 8.14877 1.5 8.41399 1.5H12.9998C13.8282 1.5 14.4998 2.17157 14.4998 3V7.58579C14.4998 7.851 14.3944 8.10536 14.2069 8.29289L8.31043 14.1893C7.72465 14.7751 6.7749 14.7751 6.18911 14.1893L1.81043 9.81066C1.22465 9.22487 1.22465 8.27513 1.81043 7.68934L2.72037 6.7794Z"
Fill="{ThemeResource Local.IconAltBrush}" />
<Path
x:Name="Path2"
Data="M3.19258 0.54776L8.02201 5.37719C8.30359 5.65876 8.50334 6.01157 8.59992 6.39789L8.9744 7.89579C9.13725 8.5472 8.5472 9.13725 7.89579 8.9744L6.39789 8.59992C6.01157 8.50334 5.65876 8.30358 5.37719 8.02201L0.54776 3.19258C-0.182587 2.46223 -0.182587 1.27811 0.54776 0.54776C1.27811 -0.182587 2.46223 -0.182587 3.19258 0.54776Z"
Fill="{ThemeResource Local.IconAccentStrokeColor}" />
<Path
x:Name="Path3"
Data="M7.13248 3.0744L7.91399 2.29289C8.10152 2.10536 8.35588 2 8.62109 2H13.073C13.6253 2 14.073 2.44772 14.073 3V7.37426C14.073 7.64122 13.9663 7.89709 13.7766 8.08491L7.95863 13.8446C7.56755 14.2318 6.93712 14.2302 6.54798 13.8411L2.16399 9.45711C1.77346 9.06658 1.77346 8.43342 2.16399 8.04289L3.07345 7.13343L2.36634 6.42632L1.45688 7.33579C0.675831 8.11684 0.675832 9.38317 1.45688 10.1642L5.84088 14.5482C6.61915 15.3265 7.88 15.3297 8.66218 14.5553L14.4801 8.79556C14.8595 8.41993 15.073 7.90818 15.073 7.37426V3C15.073 1.89543 14.1776 1 13.073 1H8.62109C8.09066 1 7.58195 1.21071 7.20688 1.58579L6.42538 2.36729L7.13248 3.0744Z"
Fill="{ThemeResource Local.IconBaseBrush}" />
<Path
x:Name="Path4"
Data="M12.4998 4.5C12.4998 5.05228 12.0521 5.5 11.4998 5.5C10.9475 5.5 10.4998 5.05228 10.4998 4.5C10.4998 3.94772 10.9475 3.5 11.4998 3.5C12.0521 3.5 12.4998 3.94772 12.4998 4.5Z"
Fill="{ThemeResource Local.IconBaseBrush}" />
</Grid>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ColorIconEnterCompactOverlay" TargetType="local:OpacityIcon">
<Setter Property="Template">
Expand Down
4 changes: 3 additions & 1 deletion src/Files.App/Services/ResourcesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ public void SetAppThemeFontFamily(string contentControlThemeFontFamily)
/// <inheritdoc/>
public void SetCompactSpacing(bool useCompactSpacing)
{
var listItemHeight = useCompactSpacing ? 24 : 36;
var listItemHeight = useCompactSpacing ? 28 : 36;
var listItemMargin = useCompactSpacing ? "-2" : "0";
var navigationViewItemOnLeftMinHeight = useCompactSpacing ? 20 : 32;

Application.Current.Resources["ListItemHeight"] = listItemHeight;
Application.Current.Resources["ListItemMargin"] = listItemMargin;
Application.Current.Resources["NavigationViewItemOnLeftMinHeight"] = navigationViewItemOnLeftMinHeight;
}

Expand Down
27 changes: 26 additions & 1 deletion src/Files.App/Strings/af/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<value>Maak alle items skoon</value>
</data>
<data name="NavigationToolbarVisiblePath.PlaceholderText" xml:space="preserve">
<value>Tik 'n pad in</value>
<value>Enter a path to navigate to or type "&gt;" to open the command palette</value>
</data>
<data name="Search" xml:space="preserve">
<value>Soek</value>
Expand Down Expand Up @@ -3405,4 +3405,29 @@
<data name="OpenAllTaggedItemsDescription" xml:space="preserve">
<value>Open all tagged items</value>
</data>
<data name="DriveWithLetter" xml:space="preserve">
<value>Drive ({0})</value>
<comment>{0} is the drive letter.</comment>
</data>
<data name="InvalidCommand" xml:space="preserve">
<value>Invalid command</value>
</data>
<data name="InvalidCommandContent" xml:space="preserve">
<value>'{0}' is not recognized as a command.</value>
</data>
<data name="CommandNotExecutable" xml:space="preserve">
<value>Command not executable</value>
</data>
<data name="CommandNotExecutableContent" xml:space="preserve">
<value>The '{0}' command is not ready to be executed.</value>
</data>
<data name="CommandPalette" xml:space="preserve">
<value>Command palette</value>
</data>
<data name="OpenCommandPaletteDescription" xml:space="preserve">
<value>Open command palette</value>
</data>
<data name="ShortcutItemWorkingDir" xml:space="preserve">
<value>Start in:</value>
</data>
</root>
Loading

0 comments on commit 13cc213

Please sign in to comment.