Skip to content

Commit d07cb1c

Browse files
committed
Explorer plugin native context menu: implement settings
1 parent 1747a64 commit d07cb1c

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,19 @@ public List<Result> LoadContextMenus(Result selectedResult)
282282

283283
if (record.Type is ResultType.File or ResultType.Folder)
284284
{
285-
var menuItems = ShellContextMenuDisplayHelper.GetContextMenuWithIcons(record.FullPath);
285+
var filters = Settings
286+
.WindowsContextMenuIgnoredItems
287+
.Replace("\r", "")
288+
.Split("\n")
289+
.Where(v => !string.IsNullOrWhiteSpace(v))
290+
.ToArray();
291+
var menuItems = ShellContextMenuDisplayHelper
292+
.GetContextMenuWithIcons(record.FullPath)
293+
.Where(contextMenuItem =>
294+
filters.Length == 0 || !filters.Any(filter =>
295+
contextMenuItem.Label.Contains(filter, StringComparison.OrdinalIgnoreCase)
296+
)
297+
);
286298
foreach (var menuItem in menuItems)
287299
{
288300
contextMenus.Add(new Result

Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class Settings
3030

3131
public bool ShowWindowsContextMenu { get; set; } = true;
3232

33+
public string WindowsContextMenuIgnoredItems { get; set; } = string.Empty;
34+
3335
public bool DefaultOpenFolderInFileManager { get; set; } = false;
3436

3537
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
@@ -62,7 +64,7 @@ public class Settings
6264
public bool ShowModifiedDateInPreviewPanel { get; set; } = true;
6365

6466
public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";
65-
67+
6668
public string PreviewPanelTimeFormat { get; set; } = "HH:mm";
6769

6870
private EverythingSearchManager _everythingManagerInstance;

Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,30 @@ private void InitializeEngineSelection()
102102

103103
#endregion
104104

105+
#region Native Context Menu
106+
107+
public bool ShowWindowsContextMenu
108+
{
109+
get => Settings.ShowWindowsContextMenu;
110+
set
111+
{
112+
Settings.ShowWindowsContextMenu = value;
113+
OnPropertyChanged();
114+
}
115+
}
116+
117+
public string WindowsContextMenuIgnoredItems
118+
{
119+
get => Settings.WindowsContextMenuIgnoredItems;
120+
set
121+
{
122+
Settings.WindowsContextMenuIgnoredItems = value;
123+
OnPropertyChanged();
124+
}
125+
}
126+
127+
#endregion
128+
105129
#region Preview Panel
106130

107131
public bool ShowFileSizeInPreviewPanel

Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,28 @@
348348
</StackPanel>
349349
</StackPanel>
350350
</TabItem>
351+
<TabItem
352+
Width="Auto"
353+
Header="Native Context Menu"
354+
Style="{DynamicResource ExplorerTabItem}">
355+
<StackPanel Margin="30 20 10 10">
356+
<CheckBox
357+
Margin="0 10 0 0"
358+
Content="Display native context menu (experimental)"
359+
IsChecked="{Binding ShowWindowsContextMenu}" />
360+
361+
<TextBlock
362+
Margin="0 10"
363+
Foreground="{DynamicResource Color05B}"
364+
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')" />
365+
366+
<TextBox
367+
Height="300"
368+
AcceptsReturn="True"
369+
Text="{Binding WindowsContextMenuIgnoredItems}"
370+
TextWrapping="Wrap" />
371+
</StackPanel>
372+
</TabItem>
351373
<TabItem
352374
Width="Auto"
353375
Header="{DynamicResource plugin_explorer_previewpanel_setting_header}"

0 commit comments

Comments
 (0)