mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add QuickFolderAccess functionality
This commit is contained in:
parent
5150d8a1f6
commit
327ee2d091
4 changed files with 57 additions and 3 deletions
|
|
@ -0,0 +1,18 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class FolderLink
|
||||
{
|
||||
[JsonProperty]
|
||||
public string Path { get; set; }
|
||||
|
||||
public string Nickname =>
|
||||
Path.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None)
|
||||
.Last()
|
||||
+ " (" + System.IO.Path.GetDirectoryName(Path) + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks
|
||||
{
|
||||
public class QuickFolderAccess
|
||||
{
|
||||
internal List<Result> FolderList(Query query, List<FolderLink> folderLinks)
|
||||
{
|
||||
string search = query.Search.ToLower();
|
||||
var userFolderLinks = folderLinks.Where(
|
||||
x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
|
||||
var results = userFolderLinks.Select(item =>
|
||||
new ResultManager().CreateFolderResult(item.Nickname, Constants.DefaultFolderSubtitleString, item.Path, query)).ToList();
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using System;
|
||||
|
|
@ -13,6 +14,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
private IndexSearcher searcher;
|
||||
|
||||
private QuickFolderAccess quickFolderAccess = new QuickFolderAccess();
|
||||
|
||||
public SearchManager(Settings settings, PluginInitContext context)
|
||||
{
|
||||
_settings = settings;
|
||||
|
|
@ -24,6 +27,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
{
|
||||
var querySearch = query.Search;
|
||||
|
||||
var quickFolderLinks = quickFolderAccess.FolderList(query, _settings.FolderLinks);
|
||||
|
||||
if (quickFolderLinks.Count > 0)
|
||||
return quickFolderLinks;
|
||||
|
||||
if (EnvironmentVariables.IsEnvironmentVariableSearch(querySearch))
|
||||
{
|
||||
return EnvironmentVariables.GetEnvironmentStringPathSuggestions(querySearch, query);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
using System;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.QuickFolderLinks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
public int MaxResult { get; set; } = 100;
|
||||
[JsonProperty]
|
||||
public int MaxResult { get; set; } = 100;
|
||||
|
||||
[JsonProperty]
|
||||
public List<FolderLink> FolderLinks { get; set; } = new List<FolderLink>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue