Skip to content

Commit 797b7ce

Browse files
authored
Feature: Added support for pinning executable shortcuts to start (#14667)
1 parent d814791 commit 797b7ce

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/Files.App/Actions/Start/PinToStartAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task ExecuteAsync()
4040
IStorable storable = listedItem.IsFolder switch
4141
{
4242
true => await StorageService.GetFolderAsync(listedItem.ItemPath),
43-
_ => await StorageService.GetFileAsync(listedItem.ItemPath)
43+
_ => await StorageService.GetFileAsync((listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath)
4444
};
4545
await StartMenuService.PinAsync(storable, listedItem.Name);
4646
}

src/Files.App/Actions/Start/UnpinFromStartAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task ExecuteAsync()
3636
IStorable storable = listedItem.IsFolder switch
3737
{
3838
true => await StorageService.GetFolderAsync(listedItem.ItemPath),
39-
_ => await StorageService.GetFileAsync(listedItem.ItemPath)
39+
_ => await StorageService.GetFileAsync((listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath)
4040
};
4141
await StartMenuService.UnpinAsync(storable);
4242
}

src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,12 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
502502
}.Build(),
503503
new ContextMenuFlyoutItemViewModelBuilder(Commands.PinToStart)
504504
{
505-
IsVisible = selectedItems.All(x => !x.IsShortcut && (x.PrimaryItemAttribute == StorageItemTypes.Folder || x.IsExecutable) && !x.IsArchive && !x.IsItemPinnedToStart),
505+
IsVisible = selectedItems.All(x => (x.PrimaryItemAttribute == StorageItemTypes.Folder || x.IsExecutable || (x is ShortcutItem shortcutItem && FileExtensionHelpers.IsExecutableFile(shortcutItem.TargetPath))) && !x.IsArchive && !x.IsItemPinnedToStart),
506506
ShowOnShift = true,
507507
}.Build(),
508508
new ContextMenuFlyoutItemViewModelBuilder(Commands.UnpinFromStart)
509509
{
510-
IsVisible = selectedItems.All(x => !x.IsShortcut && (x.PrimaryItemAttribute == StorageItemTypes.Folder || x.IsExecutable) && !x.IsArchive && x.IsItemPinnedToStart),
510+
IsVisible = selectedItems.All(x => (x.PrimaryItemAttribute == StorageItemTypes.Folder || x.IsExecutable|| (x is ShortcutItem shortcutItem && FileExtensionHelpers.IsExecutableFile(shortcutItem.TargetPath))) && !x.IsArchive && x.IsItemPinnedToStart),
511511
ShowOnShift = true,
512512
}.Build(),
513513
new ContextMenuFlyoutItemViewModel

src/Files.App/Data/Items/ListedItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public BitmapImage FileImage
182182
}
183183
}
184184

185-
public bool IsItemPinnedToStart => StartMenuService.IsPinned(ItemPath);
185+
public bool IsItemPinnedToStart => StartMenuService.IsPinned((this as ShortcutItem)?.TargetPath ?? ItemPath);
186186

187187
private BitmapImage iconOverlay;
188188
public BitmapImage IconOverlay

0 commit comments

Comments
 (0)