Skip to content

Commit 6922c25

Browse files
authored
Feature: Moved "open with" to main menu when right clicking recent files (#11304)
1 parent f62ed5b commit 6922c25

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Files.App/Helpers/ShellContextMenuHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,15 @@ public static async Task LoadShellMenuItems(string path, CommandBarFlyout itemCo
255255
var openWithItem = shellMenuItems.Where(x => (x.Tag as Win32ContextMenuItem)?.CommandString == "openas").ToList().FirstOrDefault();
256256
if (openWithItem is not null)
257257
{
258+
openWithItem.ColoredIcon = new ColoredIconModel()
259+
{
260+
BaseLayerGlyph = "\uF049",
261+
OverlayLayerGlyph = "\uF04A",
262+
};
258263
var (_, openWithItems) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(new List<ContextMenuFlyoutItemViewModel>() { openWithItem });
264+
var placeholder = itemContextMenuFlyout.SecondaryCommands.Where(x => Equals((x as AppBarButton)?.Tag, "OpenWithPlaceholder")).FirstOrDefault() as AppBarButton;
265+
if (placeholder is not null)
266+
placeholder.Visibility = Visibility.Collapsed;
259267
itemContextMenuFlyout.SecondaryCommands.Insert(0, openWithItems.FirstOrDefault());
260268
shellMenuItems.Remove(openWithItem);
261269
}

src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void Grid_RightTapped(object sender, RightTappedRoutedEventArgs e)
117117
secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i));
118118
itemContextMenuFlyout.ShowAt(recentItemsGrid, new FlyoutShowOptions { Position = e.GetPosition(recentItemsGrid) });
119119

120-
_ = ShellContextmenuHelper.LoadShellMenuItems(item.Path, itemContextMenuFlyout);
120+
_ = ShellContextmenuHelper.LoadShellMenuItems(item.Path, itemContextMenuFlyout, showOpenWithMenu: true);
121121

122122
e.Handled = true;
123123
}
@@ -126,6 +126,13 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard
126126
{
127127
return new List<ContextMenuFlyoutItemViewModel>()
128128
{
129+
new ContextMenuFlyoutItemViewModel()
130+
{
131+
Text = "OpenItemsWithCaptionText".GetLocalizedResource(),
132+
Glyph = "\uE17D",
133+
Tag = "OpenWithPlaceholder",
134+
IsEnabled = false
135+
},
129136
new ContextMenuFlyoutItemViewModel()
130137
{
131138
Text = "RecentItemRemove/Text".GetLocalizedResource(),

0 commit comments

Comments
 (0)