Skip to content

Commit 1d2a7bf

Browse files
authored
Merge pull request #3782 from Flow-Launcher/quick_access_link_volume
Support volume type for quick access link
2 parents 71e975a + d6310bc commit 1d2a7bf

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n
1717
{
1818
internal static PluginInitContext Context { get; set; }
1919

20-
internal Settings Settings;
20+
internal static Settings Settings { get; set; }
2121

2222
private SettingsViewModel viewModel;
2323

Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
66
{
77
internal static class QuickAccess
88
{
9-
private const int quickAccessResultScore = 100;
9+
private const int QuickAccessResultScore = 100;
1010

1111
internal static List<Result> AccessLinkListMatched(Query query, IEnumerable<AccessLink> accessLinks)
1212
{
@@ -19,8 +19,9 @@ internal static List<Result> AccessLinkListMatched(Query query, IEnumerable<Acce
1919
.ThenBy(x => x.Name)
2020
.Select(l => l.Type switch
2121
{
22-
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, quickAccessResultScore),
23-
ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore),
22+
ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore),
23+
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore),
24+
ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore),
2425
_ => throw new ArgumentOutOfRangeException()
2526
})
2627
.ToList();
@@ -32,8 +33,9 @@ internal static List<Result> AccessLinkListAll(Query query, IEnumerable<AccessLi
3233
.ThenBy(x => x.Name)
3334
.Select(l => l.Type switch
3435
{
35-
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query),
36-
ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore),
36+
ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore),
37+
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore),
38+
ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore),
3739
_ => throw new ArgumentOutOfRangeException()
3840
}).ToList();
3941
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,17 @@ internal static Result CreateFolderResult(string title, string subtitle, string
171171
};
172172
}
173173

174+
internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score)
175+
{
176+
return CreateDriveSpaceDisplayResult(path, actionKeyword, score, SearchManager.UseIndexSearch(path));
177+
}
178+
174179
internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, bool windowsIndexed = false)
180+
{
181+
return CreateDriveSpaceDisplayResult(path, actionKeyword, 500, windowsIndexed);
182+
}
183+
184+
private static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score, bool windowsIndexed = false)
175185
{
176186
var progressBarColor = "#26a0da";
177187
var title = string.Empty; // hide title when use progress bar,
@@ -197,7 +207,7 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK
197207
SubTitle = subtitle,
198208
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, actionKeyword),
199209
IcoPath = path,
200-
Score = 500,
210+
Score = score,
201211
ProgressBar = progressValue,
202212
ProgressBarColor = progressBarColor,
203213
Preview = new Result.PreviewInfo

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ private async Task<List<Result>> PathSearchAsync(Query query, CancellationToken
246246

247247
public bool IsFileContentSearch(string actionKeyword) => actionKeyword == Settings.FileContentSearchActionKeyword;
248248

249+
public static bool UseIndexSearch(string path)
250+
{
251+
if (Main.Settings.IndexSearchEngine is not Settings.IndexSearchEngineOption.WindowsIndex)
252+
return false;
253+
254+
// Check if the path is using windows index search
255+
var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
256+
257+
return !Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(
258+
x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory).StartsWith(x.Path, StringComparison.OrdinalIgnoreCase))
259+
&& WindowsIndex.WindowsIndex.PathIsIndexed(pathToDirectory);
260+
}
249261

250262
private bool UseWindowsIndexForDirectorySearch(string locationPath)
251263
{

0 commit comments

Comments
 (0)