Explorer plugin native context menu: implement settings

This commit is contained in:
Yusyuriv 2024-06-07 14:30:19 +06:00
parent 1747a64d6b
commit d07cb1c166
No known key found for this signature in database
GPG key ID: A91C52E6F73148E0
4 changed files with 62 additions and 2 deletions

View file

@ -282,7 +282,19 @@ namespace Flow.Launcher.Plugin.Explorer
if (record.Type is ResultType.File or ResultType.Folder)
{
var menuItems = ShellContextMenuDisplayHelper.GetContextMenuWithIcons(record.FullPath);
var filters = Settings
.WindowsContextMenuIgnoredItems
.Replace("\r", "")
.Split("\n")
.Where(v => !string.IsNullOrWhiteSpace(v))
.ToArray();
var menuItems = ShellContextMenuDisplayHelper
.GetContextMenuWithIcons(record.FullPath)
.Where(contextMenuItem =>
filters.Length == 0 || !filters.Any(filter =>
contextMenuItem.Label.Contains(filter, StringComparison.OrdinalIgnoreCase)
)
);
foreach (var menuItem in menuItems)
{
contextMenus.Add(new Result

View file

@ -30,6 +30,8 @@ namespace Flow.Launcher.Plugin.Explorer
public bool ShowWindowsContextMenu { get; set; } = true;
public string WindowsContextMenuIgnoredItems { get; set; } = string.Empty;
public bool DefaultOpenFolderInFileManager { get; set; } = false;
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
@ -62,7 +64,7 @@ namespace Flow.Launcher.Plugin.Explorer
public bool ShowModifiedDateInPreviewPanel { get; set; } = true;
public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";
public string PreviewPanelTimeFormat { get; set; } = "HH:mm";
private EverythingSearchManager _everythingManagerInstance;

View file

@ -102,6 +102,30 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
#endregion
#region Native Context Menu
public bool ShowWindowsContextMenu
{
get => Settings.ShowWindowsContextMenu;
set
{
Settings.ShowWindowsContextMenu = value;
OnPropertyChanged();
}
}
public string WindowsContextMenuIgnoredItems
{
get => Settings.WindowsContextMenuIgnoredItems;
set
{
Settings.WindowsContextMenuIgnoredItems = value;
OnPropertyChanged();
}
}
#endregion
#region Preview Panel
public bool ShowFileSizeInPreviewPanel

View file

@ -348,6 +348,28 @@
</StackPanel>
</StackPanel>
</TabItem>
<TabItem
Width="Auto"
Header="Native Context Menu"
Style="{DynamicResource ExplorerTabItem}">
<StackPanel Margin="30 20 10 10">
<CheckBox
Margin="0 10 0 0"
Content="Display native context menu (experimental)"
IsChecked="{Binding ShowWindowsContextMenu}" />
<TextBlock
Margin="0 10"
Foreground="{DynamicResource Color05B}"
Text="Below you can specify items you want to exclude from context menu, they can be partial (e.g. 'pen wit') or complete ('Open with')" />
<TextBox
Height="300"
AcceptsReturn="True"
Text="{Binding WindowsContextMenuIgnoredItems}"
TextWrapping="Wrap" />
</StackPanel>
</TabItem>
<TabItem
Width="Auto"
Header="{DynamicResource plugin_explorer_previewpanel_setting_header}"