show if file or folder is indexed in context menu

This commit is contained in:
Jeremy Wu 2020-05-27 19:36:49 +10:00
parent af00ec5879
commit 2ea6642248
7 changed files with 21 additions and 8 deletions

View file

@ -23,6 +23,10 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(CreateOpenContainingFolderResult(record));
}
if (record.ShowIndexState)
contextMenus.Add(new Result { Title = "Indexed: " + (record.WindowsIndexed ? "Yes" : "No"),
Score = 501, IcoPath = Constants.IndexImagePath });
var icoPath = (record.Type == ResultType.File) ? Constants.FileImagePath : Constants.FolderImagePath;
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";
contextMenus.Add(new Result

View file

@ -27,6 +27,10 @@
<None Include="Images\explorer.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\index.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\copy.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -10,6 +10,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
public const string FileImagePath = "Images\\file.png";
public const string DeleteFileFolderImagePath = "Images\\deletefilefolder.png";
public const string CopyImagePath = "Images\\copy.png";
public const string IndexImagePath = "Images\\index.png";
public const string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";
}

View file

@ -71,11 +71,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
if (fileSystemInfo is System.IO.DirectoryInfo)
{
folderList.Add(ResultManager.CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, fileSystemInfo.FullName, query));
folderList.Add(ResultManager.CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, fileSystemInfo.FullName, query, true, false));
}
else
{
fileList.Add(ResultManager.CreateFileResult(fileSystemInfo.FullName, query));
fileList.Add(ResultManager.CreateFileResult(fileSystemInfo.FullName, query, true, false));
}
}
}

View file

@ -11,7 +11,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
internal static class ResultManager
{
internal static Result CreateFolderResult(string title, string subtitle, string path, Query query)
internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, bool showIndexState = false, bool windowsIndexed = false)
{
return new Result
{
@ -41,7 +41,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
query.ActionKeyword + " " + changeTo);
return false;
},
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path }
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
};
}
@ -85,7 +85,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
};
}
internal static Result CreateFileResult(string filePath, Query query)
internal static Result CreateFileResult(string filePath, Query query, bool showIndexState = false, bool windowsIndexed = false)
{
var result = new Result
{
@ -106,7 +106,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return true;
},
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath }
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
};
return result;
}
@ -116,6 +116,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
public string FullPath { get; set; }
public ResultType Type { get; set; }
public bool WindowsIndexed { get; set; }
public bool ShowIndexState { get; set; }
}
internal enum ResultType

View file

@ -71,10 +71,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
private Result CreateResult(string filename, string path, string fileType, Query query)
{
if (fileType == "Directory")
return ResultManager.CreateFolderResult(filename, path, path, query);
return ResultManager.CreateFolderResult(filename, path, path, query, true, true);
else
{
return ResultManager.CreateFileResult(path, query);
return ResultManager.CreateFileResult(path, query, true, true);
}
}