Merge pull request #3782 from Flow-Launcher/quick_access_link_volume

Support volume type for quick access link
This commit is contained in:
Jack Ye 2025-06-28 15:58:49 +08:00 committed by GitHub
commit 1d2a7bf85a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 31 additions and 7 deletions

View file

@ -17,7 +17,7 @@ namespace Flow.Launcher.Plugin.Explorer
{
internal static PluginInitContext Context { get; set; }
internal Settings Settings;
internal static Settings Settings { get; set; }
private SettingsViewModel viewModel;

View file

@ -6,7 +6,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
{
internal static class QuickAccess
{
private const int quickAccessResultScore = 100;
private const int QuickAccessResultScore = 100;
internal static List<Result> AccessLinkListMatched(Query query, IEnumerable<AccessLink> accessLinks)
{
@ -19,8 +19,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
.ThenBy(x => x.Name)
.Select(l => l.Type switch
{
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, quickAccessResultScore),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore),
ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore),
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore),
_ => throw new ArgumentOutOfRangeException()
})
.ToList();
@ -32,8 +33,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
.ThenBy(x => x.Name)
.Select(l => l.Type switch
{
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore),
ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore),
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore),
_ => throw new ArgumentOutOfRangeException()
}).ToList();
}

View file

@ -171,7 +171,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search
};
}
internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score)
{
return CreateDriveSpaceDisplayResult(path, actionKeyword, score, SearchManager.UseIndexSearch(path));
}
internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, bool windowsIndexed = false)
{
return CreateDriveSpaceDisplayResult(path, actionKeyword, 500, windowsIndexed);
}
private static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score, bool windowsIndexed = false)
{
var progressBarColor = "#26a0da";
var title = string.Empty; // hide title when use progress bar,
@ -197,7 +207,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
SubTitle = subtitle,
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, actionKeyword),
IcoPath = path,
Score = 500,
Score = score,
ProgressBar = progressValue,
ProgressBarColor = progressBarColor,
Preview = new Result.PreviewInfo

View file

@ -246,6 +246,18 @@ namespace Flow.Launcher.Plugin.Explorer.Search
public bool IsFileContentSearch(string actionKeyword) => actionKeyword == Settings.FileContentSearchActionKeyword;
public static bool UseIndexSearch(string path)
{
if (Main.Settings.IndexSearchEngine is not Settings.IndexSearchEngineOption.WindowsIndex)
return false;
// Check if the path is using windows index search
var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
return !Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(
x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory).StartsWith(x.Path, StringComparison.OrdinalIgnoreCase))
&& WindowsIndex.WindowsIndex.PathIsIndexed(pathToDirectory);
}
private bool UseWindowsIndexForDirectorySearch(string locationPath)
{