From d07cb1c1664f0eaaa1caa800ad8856c27fe596fb Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Fri, 7 Jun 2024 14:30:19 +0600 Subject: [PATCH] Explorer plugin native context menu: implement settings --- .../ContextMenu.cs | 14 ++++++++++- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 4 +++- .../ViewModels/SettingsViewModel.cs | 24 +++++++++++++++++++ .../Views/ExplorerSettings.xaml | 22 +++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index b0d392f1b..fd0e6419a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -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 diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 088bcf5d6..81a8332da 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -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; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 064795b43..f592629af 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -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 diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 5c92fc271..0a51598d5 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -348,6 +348,28 @@ + + + + + + + + +