From 6978b65d8eb99aca0f13669ed979f267936d65a3 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 30 Jul 2021 20:44:29 +1000 Subject: [PATCH 1/2] add Quick Access action keyword --- .../UserSettings/PluginSettings.cs | 23 ++++++++--- .../Languages/en.xaml | 2 + .../Search/SearchManager.cs | 38 +++++++++++-------- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 14 ++++++- .../Views/ActionKeywordSetting.xaml.cs | 16 ++++++-- .../Views/ExplorerSettings.xaml.cs | 4 +- .../Flow.Launcher.Plugin.Explorer/plugin.json | 3 +- 7 files changed, 70 insertions(+), 30 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs index abce8b41ea7..bdf74517dbd 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/PluginSettings.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Flow.Launcher.Plugin; namespace Flow.Launcher.Infrastructure.UserSettings @@ -15,13 +15,24 @@ public void UpdatePluginSettings(List metadatas) if (Plugins.ContainsKey(metadata.ID)) { var settings = Plugins[metadata.ID]; - - // TODO: Remove. This is backwards compatibility for 1.8.0 release. - // Introduced two new action keywords in Explorer, so need to update plugin setting in the UserData folder. + if (metadata.ID == "572be03c74c642baae319fc283e561a8" && metadata.ActionKeywords.Count != settings.ActionKeywords.Count) { - settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for index search - settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for path search + // TODO: Remove. This is backwards compatibility for Explorer 1.8.0 release. + // Introduced two new action keywords in Explorer, so need to update plugin setting in the UserData folder. + if (settings.Version.CompareTo("1.8.0") < 0) + { + settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for index search + settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for path search + settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for quick access action keyword + } + + // TODO: Remove. This is backwards compatibility for Explorer 1.9.0 release. + // Introduced a new action keywords in Explorer since 1.8.0, so need to update plugin setting in the UserData folder. + if (settings.Version.CompareTo("1.8.0") > 0) + { + settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for quick access action keyword + } } if (string.IsNullOrEmpty(settings.Version)) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index b23931fcf78..e2914d017d8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -10,6 +10,7 @@ Deletion successful Successfully deleted the {0} Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword + Quick Access can not be set to the global action keyword when enabled. Please choose a specific action keyword The required service for Windows Index Search does not appear to be running To fix this, start the Windows Search service. Select here to remove this warning The warning message has been switched off. As an alternative for searching files and folders, would you like to install Everything plugin?{0}{0}Select 'Yes' to install Everything plugin, or 'No' to return @@ -27,6 +28,7 @@ Path Search: File Content Search: Index Search: + Quick Access: Current Action Keyword: Done Enabled diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 9995f45d380..05fd071f736 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -42,15 +42,28 @@ internal async Task> SearchAsync(Query query, CancellationToken tok { var querySearch = query.Search; + var results = new HashSet(PathEqualityComparator.Instance); + + // This allows the user to type the below action keywords and see/search the list of quick folder links + if (ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword) + || ActionKeywordMatch(query, Settings.ActionKeyword.QuickAccessActionKeyword) + || ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword)) + { + if (string.IsNullOrEmpty(query.Search)) + return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks); + + var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks); + + results.UnionWith(quickaccessLinks); + } + if (IsFileContentSearch(query.ActionKeyword)) return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false); - var result = new HashSet(PathEqualityComparator.Instance); - if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) || ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) { - result.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false)); + results.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false)); } if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword) || @@ -58,11 +71,11 @@ internal async Task> SearchAsync(Query query, CancellationToken tok querySearch.Length > 0 && !querySearch.IsLocationPathString()) { - result.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token) + results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token) .ConfigureAwait(false)); } - return result.ToList(); + return results.ToList(); } private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword) @@ -75,10 +88,11 @@ private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActio keyword == Settings.SearchActionKeyword, Settings.ActionKeyword.PathSearchActionKeyword => Settings.PathSearchKeywordEnabled && keyword == Settings.PathSearchActionKeyword, - Settings.ActionKeyword.FileContentSearchActionKeyword => keyword == - Settings.FileContentSearchActionKeyword, + Settings.ActionKeyword.FileContentSearchActionKeyword => keyword == Settings.FileContentSearchActionKeyword, Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexOnlySearchKeywordEnabled && - keyword == Settings.IndexSearchActionKeyword + keyword == Settings.IndexSearchActionKeyword, + Settings.ActionKeyword.QuickAccessActionKeyword => Settings.QuickAccessKeywordEnabled && + keyword == Settings.QuickAccessActionKeyword }; } @@ -86,16 +100,8 @@ public async Task> PathSearchAsync(Query query, CancellationToken t { var querySearch = query.Search; - // This allows the user to type the assigned action keyword and only see the list of quick folder links - if (string.IsNullOrEmpty(query.Search)) - return QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks); - var results = new HashSet(PathEqualityComparator.Instance); - var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks); - - results.UnionWith(quickaccessLinks); - var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch); if (isEnvironmentVariable) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 88656a40172..e75d07cb012 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -21,6 +21,7 @@ public class Settings public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List(); public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; + public bool SearchActionKeywordEnabled { get; set; } = true; public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; @@ -33,6 +34,10 @@ public class Settings public bool IndexOnlySearchKeywordEnabled { get; set; } + public string QuickAccessActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; + + public bool QuickAccessKeywordEnabled { get; set; } + public bool WarnWindowsSearchServiceOff { get; set; } = true; internal enum ActionKeyword @@ -40,7 +45,8 @@ internal enum ActionKeyword SearchActionKeyword, PathSearchActionKeyword, FileContentSearchActionKeyword, - IndexSearchActionKeyword + IndexSearchActionKeyword, + QuickAccessActionKeyword } internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch @@ -48,7 +54,8 @@ internal enum ActionKeyword ActionKeyword.SearchActionKeyword => SearchActionKeyword, ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword, ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword, - ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword + ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword, + ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword }; internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch @@ -57,6 +64,7 @@ internal enum ActionKeyword ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword, ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword, ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword, + ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword, _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") }; @@ -65,6 +73,7 @@ internal enum ActionKeyword ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled, ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled, ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled, + ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled, _ => null }; @@ -73,6 +82,7 @@ internal enum ActionKeyword ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable, ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable, ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled = enable, + ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable, _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") }; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs index 18703e5eafd..14db6d4733f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs @@ -63,11 +63,19 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e) } - if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword - && ActionKeyword == Query.GlobalPluginWildcardSign) + if (ActionKeyword == Query.GlobalPluginWildcardSign + && (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword + || CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.QuickAccessActionKeyword)) { - MessageBox.Show( - settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); + switch (CurrentActionKeyword.KeywordProperty) + { + case Settings.ActionKeyword.FileContentSearchActionKeyword: + MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); + break; + case Settings.ActionKeyword.QuickAccessActionKeyword: + MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid")); + break; + } return; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs index 0c3799cee03..5758b84b8c8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs @@ -42,7 +42,9 @@ public ExplorerSettings(SettingsViewModel viewModel) new(Settings.ActionKeyword.PathSearchActionKeyword, viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_pathsearch")), new(Settings.ActionKeyword.IndexSearchActionKeyword, - viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexsearch")) + viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_indexsearch")), + new(Settings.ActionKeyword.QuickAccessActionKeyword, + viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_quickaccess")) }; lbxActionKeywords.ItemsSource = actionKeywordsListView; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index 59a31ec139c..d47c68cd38c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json @@ -4,12 +4,13 @@ "*", "doc:", "*", + "*", "*" ], "Name": "Explorer", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Author": "Jeremy Wu", - "Version": "1.8.2", + "Version": "1.9.0", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll", From 53e305d76544ef07f65c5c0e254b98214a408e44 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 6 Aug 2021 18:52:09 +1000 Subject: [PATCH 2/2] update per review --- .../Views/ActionKeywordSetting.xaml.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs index 14db6d4733f..dfac163bcec 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs @@ -63,23 +63,17 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e) } - if (ActionKeyword == Query.GlobalPluginWildcardSign - && (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword - || CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.QuickAccessActionKeyword)) - { + if (ActionKeyword == Query.GlobalPluginWildcardSign) switch (CurrentActionKeyword.KeywordProperty) { case Settings.ActionKeyword.FileContentSearchActionKeyword: MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); - break; + return; case Settings.ActionKeyword.QuickAccessActionKeyword: MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid")); - break; + return; } - return; - } - var oldActionKeyword = CurrentActionKeyword.Keyword; // == because of nullable @@ -92,7 +86,7 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e) switch (Enabled) { // reset to global so it does not take up an action keyword when disabled - // not for null Enable plugin + // not for null Enable plugin case false when oldActionKeyword != Query.GlobalPluginWildcardSign: settingsViewModel.UpdateActionKeyword(CurrentActionKeyword.KeywordProperty, Query.GlobalPluginWildcardSign, oldActionKeyword);