Skip to content

Commit 407864b

Browse files
committed
add option to open Indexing Options in context menu and settings page
1 parent 6befd6c commit 407864b

File tree

7 files changed

+76
-10
lines changed

7 files changed

+76
-10
lines changed

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
3838

3939
contextMenus.Add(CreateOpenContainingFolderResult(record));
4040

41+
contextMenus.Add(CreateOpenWindowsIndexingOptions(record));
42+
4143
if (record.ShowIndexState)
4244
contextMenus.Add(new Result {Title = "From index search: " + (record.WindowsIndexed ? "Yes" : "No"),
4345
SubTitle = "Location: " + record.FullPath,
@@ -186,13 +188,13 @@ private Result CreateOpenWithEditorResult(SearchResult record)
186188
}
187189
catch (Exception e)
188190
{
189-
var message = $"Fail to editor for file at {record.FullPath}";
191+
var message = $"Failed to open editor for file at {record.FullPath}";
190192
LogException(message, e);
191193
Context.API.ShowMsg(message);
192194
return false;
193195
}
194196
},
195-
IcoPath = editorPath
197+
IcoPath = Constants.FileImagePath
196198
};
197199
}
198200

@@ -225,6 +227,38 @@ private Result CreateAddToIndexSearchExclusionListResult(SearchResult record)
225227
};
226228
}
227229

230+
private Result CreateOpenWindowsIndexingOptions(SearchResult record)
231+
{
232+
return new Result
233+
{
234+
Title = "Open Windows Indexing Options",
235+
SubTitle = "Manage indexed files and folders",
236+
Action = _ =>
237+
{
238+
try
239+
{
240+
var psi = new ProcessStartInfo
241+
{
242+
FileName = "control.exe",
243+
UseShellExecute = true,
244+
Arguments = "srchadmin.dll"
245+
};
246+
247+
Process.Start(psi);
248+
return true;
249+
}
250+
catch (Exception e)
251+
{
252+
var message = $"Failed to open Windows Indexing Options";
253+
LogException(message, e);
254+
Context.API.ShowMsg(message);
255+
return false;
256+
}
257+
},
258+
IcoPath = Constants.IndexingOptionsIconImagePath
259+
};
260+
}
261+
228262
public void LogException(string message, Exception e)
229263
{
230264
Log.Exception($"|Flow.Launcher.Plugin.Folder.ContextMenu|{message}", e);

Plugins/Flow.Launcher.Plugin.Explorer/Flow.Launcher.Plugin.Explorer.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
<None Include="Images\user.png">
5757
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
5858
</None>
59+
60+
<None Include="Images\windowsindexingoptions.png">
61+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
62+
</None>
5963
</ItemGroup>
6064

6165
<ItemGroup>
3.68 KB
Loading

Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ internal static class Constants
1414
internal const string ExcludeFromIndexImagePath = "Images\\excludeindexpath.png";
1515
internal const string ExplorerIconImagePath = "Images\\explorer.png";
1616
internal const string DifferentUserIconImagePath = "Images\\user.png";
17+
internal const string IndexingOptionsIconImagePath = "Images\\windowsindexingoptions.png";
1718

1819
internal const string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";
1920

2021
internal const char AllFilesFolderSearchWildcard = '>';
2122

2223
internal const char DirectorySeperator = '\\';
24+
25+
internal const string WindowsIndexingOptions = "srchadmin.dll";
2326
}
2427
}

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using Flow.Launcher.Infrastructure.Storage;
2+
using Flow.Launcher.Plugin.Explorer.Search;
23
using Flow.Launcher.Plugin.Explorer.Search.FolderLinks;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Text;
4+
using System.Diagnostics;
65

76
namespace Flow.Launcher.Plugin.Explorer.ViewModels
87
{
@@ -29,5 +28,17 @@ public void Save()
2928
internal void RemoveFolderLinkFromQuickFolders(FolderLink selectedRow) => Settings.QuickFolderAccessLinks.Remove(selectedRow);
3029

3130
internal void RemoveFolderLinkFromExcludedIndexPaths(FolderLink selectedRow) => Settings.IndexSearchExcludedSubdirectoryPaths.Remove(selectedRow);
31+
32+
internal void OpenWindowsIndexingOptions()
33+
{
34+
var psi = new ProcessStartInfo
35+
{
36+
FileName = "control.exe",
37+
UseShellExecute = true,
38+
Arguments = Constants.WindowsIndexingOptions
39+
};
40+
41+
Process.Start(psi);
42+
}
3243
}
3344
}

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,19 @@
4444
</Expander>
4545
</StackPanel>
4646
</ScrollViewer>
47-
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
48-
<Button x:Name="btnDelete" Click="btnDelete_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_delete}"/>
49-
<Button x:Name="btnEdit" Click="btnEdit_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_edit}"/>
50-
<Button x:Name="btnAdd" Click="btnAdd_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_add}"/>
51-
</StackPanel>
47+
<Grid Grid.Row="1">
48+
<Grid.ColumnDefinitions>
49+
<ColumnDefinition Width="*"/>
50+
<ColumnDefinition Width="350"/>
51+
</Grid.ColumnDefinitions>
52+
<StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Orientation="Horizontal">
53+
<Button x:Name="btnIndexingOptions" Click="btnOpenIndexingOptions_Click" Width="130" Margin="10" Content="Indexing Options"/>
54+
</StackPanel>
55+
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
56+
<Button x:Name="btnDelete" Click="btnDelete_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_delete}"/>
57+
<Button x:Name="btnEdit" Click="btnEdit_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_edit}"/>
58+
<Button x:Name="btnAdd" Click="btnAdd_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_add}"/>
59+
</StackPanel>
60+
</Grid>
5261
</Grid>
5362
</UserControl>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,10 @@ private void lbxFolders_DragEnter(object sender, DragEventArgs e)
236236
e.Effects = DragDropEffects.None;
237237
}
238238
}
239+
240+
private void btnOpenIndexingOptions_Click(object sender, RoutedEventArgs e)
241+
{
242+
viewModel.OpenWindowsIndexingOptions();
243+
}
239244
}
240245
}

0 commit comments

Comments
 (0)