diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs new file mode 100644 index 000000000..33c6d37dc --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/FolderLink.cs @@ -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) + ")"; + } +} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/QuickFolderAccess.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/QuickFolderAccess.cs new file mode 100644 index 000000000..11c735ea2 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickFolderLinks/QuickFolderAccess.cs @@ -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 FolderList(Query query, List 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; + } + } +} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 6119f635f..3cb2cf842 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -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); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 2d664c3db..c8eb87c34 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -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 FolderLinks { get; set; } = new List(); } }