Skip to content

Feature: Moved context menu settings to preferences page #11287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2023
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
8 changes: 4 additions & 4 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ private void AddNewFileTagsToMenu(CommandBarFlyout contextMenu)
index = index >= 0 ? index : contextMenu.SecondaryCommands.Count;

// Only show the edit tags flyout if settings is enabled
if (!UserSettingsService.AppearanceSettingsService.ShowEditTagsMenu)
if (!UserSettingsService.PreferencesSettingsService.ShowEditTagsMenu)
return;

contextMenu.SecondaryCommands.Insert(index, new AppBarSeparator());
Expand All @@ -709,7 +709,7 @@ private void AddNewFileTagsToMenu(CommandBarFlyout contextMenu)
private void AddShellItemsToMenu(List<ContextMenuFlyoutItemViewModel> shellMenuItems, CommandBarFlyout contextMenuFlyout, bool shiftPressed)
{
var openWithSubItems = ItemModelListToContextFlyoutHelper.GetMenuFlyoutItemsFromModel(ShellContextmenuHelper.GetOpenWithItems(shellMenuItems));
var mainShellMenuItems = shellMenuItems.RemoveFrom(!UserSettingsService.AppearanceSettingsService.MoveShellExtensionsToSubMenu ? int.MaxValue : shiftPressed ? 6 : 0);
var mainShellMenuItems = shellMenuItems.RemoveFrom(!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu ? int.MaxValue : shiftPressed ? 6 : 0);
var overflowShellMenuItemsUnfiltered = shellMenuItems.Except(mainShellMenuItems).ToList();
var overflowShellMenuItems = overflowShellMenuItemsUnfiltered.Where(
(x, i) => (x.ItemType == ItemType.Separator &&
Expand Down Expand Up @@ -764,12 +764,12 @@ private void AddShellItemsToMenu(List<ContextMenuFlyoutItemViewModel> shellMenuI
index++;
}

if (overflowItemFlyout.Items.Count > 0 && UserSettingsService.AppearanceSettingsService.MoveShellExtensionsToSubMenu)
if (overflowItemFlyout.Items.Count > 0 && UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu)
{
overflowItem.Label = "ShowMoreOptions".GetLocalizedResource();
overflowItem.IsEnabled = true;
}
else if (!UserSettingsService.AppearanceSettingsService.MoveShellExtensionsToSubMenu)
else if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu)
overflowItem.Visibility = Visibility.Collapsed;
}
}
Expand Down
34 changes: 17 additions & 17 deletions src/Files.App/Helpers/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static List<ContextMenuFlyoutItemViewModel> Filter(List<ContextMenuFlyout
var overflow = items.Where(x => x.ID == "ItemOverflow").FirstOrDefault();
if (overflow is not null)
{
if (!shiftPressed && userSettingsService.AppearanceSettingsService.MoveShellExtensionsToSubMenu) // items with ShowOnShift to overflow menu
if (!shiftPressed && userSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu) // items with ShowOnShift to overflow menu
{
var overflowItems = items.Where(x => x.ShowOnShift).ToList();

Expand Down Expand Up @@ -642,7 +642,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
},
new ContextMenuFlyoutItemViewModel()
{
Text = "LoadingMoreOptions".GetLocalizedResource(),
Text = "Loading".GetLocalizedResource(),
Glyph = "\xE712",
Items = new List<ContextMenuFlyoutItemViewModel>(),
ID = "ItemOverflow",
Expand Down Expand Up @@ -723,24 +723,12 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
ShowInSearchPage = true,
},
new ContextMenuFlyoutItemViewModel()
{
Text = "BaseLayoutItemContextFlyoutOpenInNewPane/Text".GetLocalizedResource(),
Glyph = "\xF117",
GlyphFontFamilyName = "CustomGlyph",
Command = commandsViewModel.OpenDirectoryInNewPaneCommand,
ShowItem = userSettingsService.PreferencesSettingsService.IsDualPaneEnabled && areAllItemsFolders,
SingleItemOnly = true,
ShowInSearchPage = true,
ShowInFtpPage = true,
ShowInZipPage = true,
},
new ContextMenuFlyoutItemViewModel()
{
Text = "BaseLayoutItemContextFlyoutOpenInNewTab/Text".GetLocalizedResource(),
Glyph = "\uF113",
GlyphFontFamilyName = "CustomGlyph",
Command = commandsViewModel.OpenDirectoryInNewTabCommand,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab,
ShowInSearchPage = true,
ShowInFtpPage = true,
ShowInZipPage = true,
Expand All @@ -750,7 +738,19 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
Text = "BaseLayoutItemContextFlyoutOpenInNewWindow/Text".GetLocalizedResource(),
Glyph = "\uE737",
Command = commandsViewModel.OpenInNewWindowItemCommand,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.AppearanceSettingsService.ShowOpenInNewWindow,
ShowItem = selectedItems.Count < 5 && areAllItemsFolders && userSettingsService.PreferencesSettingsService.ShowOpenInNewWindow,
ShowInSearchPage = true,
ShowInFtpPage = true,
ShowInZipPage = true,
},
new ContextMenuFlyoutItemViewModel()
{
Text = "OpenInNewPane".GetLocalizedResource(),
Glyph = "\xF117",
GlyphFontFamilyName = "CustomGlyph",
Command = commandsViewModel.OpenDirectoryInNewPaneCommand,
ShowItem = userSettingsService.PreferencesSettingsService.ShowOpenInNewPane && areAllItemsFolders,
SingleItemOnly = true,
ShowInSearchPage = true,
ShowInFtpPage = true,
ShowInZipPage = true,
Expand Down Expand Up @@ -1109,7 +1109,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
},
new ContextMenuFlyoutItemViewModel()
{
Text = "LoadingMoreOptions".GetLocalizedResource(),
Text = "Loading".GetLocalizedResource(),
Glyph = "\xE712",
Items = new List<ContextMenuFlyoutItemViewModel>(),
ID = "ItemOverflow",
Expand Down
3 changes: 0 additions & 3 deletions src/Files.App/Helpers/NavigationHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ public static void OpenInSecondaryPane(IShellPage associatedInstance, ListedItem
if (associatedInstance is null || listedItem is null)
return;

if (!userSettingsService.PreferencesSettingsService.IsDualPaneEnabled)
return;

associatedInstance.PaneHolder?.OpenPathInNewPane((listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/ShellContextMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public static async Task LoadShellMenuItems(string path, CommandBarFlyout itemCo
itemContextMenuFlyout.SecondaryCommands.Insert(0, openWithItems.FirstOrDefault());
}

if (!UserSettingsService.AppearanceSettingsService.MoveShellExtensionsToSubMenu)
if (!UserSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu)
{
var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(shellMenuItems);
if (secondaryElements.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,6 @@ public String AppThemeFontFamily
set => Set(value);
}

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

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

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

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

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
Expand All @@ -100,10 +76,6 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(AppThemeAddressBarBackgroundColor):
case nameof(AppThemeSidebarBackgroundColor):
case nameof(AppThemeFileAreaBackgroundColor):
case nameof(MoveShellExtensionsToSubMenu):
case nameof(ShowEditTagsMenu):
case nameof(ShowOpenInNewTab):
case nameof(ShowOpenInNewWindow):
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ public DateTimeFormats DateTimeFormat
set => Set(value);
}

public bool IsDualPaneEnabled
{
get => Get(false);
set => Set(value);
}

public bool AlwaysOpenDualPaneInNewTab
{
get => Get(false);
Expand Down Expand Up @@ -183,6 +177,36 @@ public bool ShowFileTagsSection
set => Set(value);
}

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

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

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

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

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

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
Expand All @@ -192,7 +216,6 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(ContinueLastSessionOnStartUp):
case nameof(OpenNewTabOnStartup):
case nameof(AlwaysOpenNewInstance):
case nameof(IsDualPaneEnabled):
case nameof(AlwaysOpenDualPaneInNewTab):
case nameof(ShowQuickAccessWidget):
case nameof(ShowRecentFilesWidget):
Expand All @@ -208,6 +231,11 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(ShowNetworkDrivesSection):
case nameof(ShowWslSection):
case nameof(ShowFileTagsSection):
case nameof(MoveShellExtensionsToSubMenu):
case nameof(ShowEditTagsMenu):
case nameof(ShowOpenInNewTab):
case nameof(ShowOpenInNewWindow):
case nameof(ShowOpenInNewPane):
Analytics.TrackEvent($"Set {e.SettingName} to {e.NewValue}");
break;
}
Expand Down
15 changes: 6 additions & 9 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1245,17 +1245,14 @@
<data name="SettingsMultitaskingAlwaysOpenDualPane" xml:space="preserve">
<value>Open tabs in dual pane mode</value>
</data>
<data name="SettingsMultitaskingEnableDualPane" xml:space="preserve">
<value>Enable dual pane view</value>
</data>
<data name="BaseLayoutItemContextFlyoutOpenInNewPane.Text" xml:space="preserve">
<value>Open in secondary pane</value>
<data name="ShowOpenInNewPane" xml:space="preserve">
<value>Show option to open folders in a new pane</value>
</data>
<data name="NavigationToolbarNewPane.Label" xml:space="preserve">
<value>New pane</value>
</data>
<data name="SideBarOpenInNewPane.Text" xml:space="preserve">
<value>Open in secondary pane</value>
<data name="OpenInNewPane" xml:space="preserve">
<value>Open in new pane</value>
</data>
<data name="Folders" xml:space="preserve">
<value>Folders</value>
Expand Down Expand Up @@ -2934,8 +2931,8 @@
<data name="Never" xml:space="preserve">
<value>Never</value>
</data>
<data name="LoadingMoreOptions" xml:space="preserve">
<value>Loading more options...</value>
<data name="Loading" xml:space="preserve">
<value>Loading...</value>
</data>
<data name="ContextMenuOptions" xml:space="preserve">
<value>Context menu options</value>
Expand Down
24 changes: 12 additions & 12 deletions src/Files.App/UserControls/SidebarControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,27 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
Tag = "EmptyRecycleBin",
},
new ContextMenuFlyoutItemViewModel()
{
Text = "SideBarOpenInNewPane/Text".GetLocalizedResource(),
Glyph = "\uF117",
GlyphFontFamilyName = "CustomGlyph",
Command = OpenInNewPaneCommand,
ShowItem = options.IsLocationItem && CanOpenInNewPane
},
new ContextMenuFlyoutItemViewModel()
{
Text = "SideBarOpenInNewTab/Text".GetLocalizedResource(),
Glyph = "\uF113",
GlyphFontFamilyName = "CustomGlyph",
Command = OpenInNewTabCommand,
ShowItem = options.IsLocationItem && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Text = "SideBarOpenInNewWindow/Text".GetLocalizedResource(),
Glyph = "\uE737",
Command = OpenInNewWindowCommand,
ShowItem = options.IsLocationItem && userSettingsService.AppearanceSettingsService.ShowOpenInNewTab
ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewTab
},
new ContextMenuFlyoutItemViewModel()
{
Text = "OpenInNewPane".GetLocalizedResource(),
Glyph = "\uF117",
GlyphFontFamilyName = "CustomGlyph",
Command = OpenInNewPaneCommand,
ShowItem = options.IsLocationItem && userSettingsService.PreferencesSettingsService.ShowOpenInNewPane
},
new ContextMenuFlyoutItemViewModel()
{
Expand Down Expand Up @@ -282,7 +282,7 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
},
new ContextMenuFlyoutItemViewModel()
{
Text = "LoadingMoreOptions".GetLocalizedResource(),
Text = "Loading".GetLocalizedResource(),
Glyph = "\xE712",
Items = new List<ContextMenuFlyoutItemViewModel>(),
ID = "ItemOverflow",
Expand Down Expand Up @@ -429,7 +429,7 @@ private void NavigationViewItem_RightTapped(object sender, RightTappedRoutedEven
var menuItems = GetLocationItemMenuItems(item, itemContextMenuFlyout);
var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(menuItems);

if (!userSettingsService.AppearanceSettingsService.MoveShellExtensionsToSubMenu)
if (!userSettingsService.PreferencesSettingsService.MoveShellExtensionsToSubMenu)
secondaryElements.OfType<FrameworkElement>()
.ForEach(i => i.MinWidth = Constants.UI.ContextMenuItemsMaxWidth); // Set menu min width if the overflow menu setting is disabled

Expand Down
Loading