add Quick Access action keyword

This commit is contained in:
Jeremy 2021-07-30 20:44:29 +10:00
parent 309ee29bda
commit 6978b65d8e
7 changed files with 70 additions and 30 deletions

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
namespace Flow.Launcher.Infrastructure.UserSettings namespace Flow.Launcher.Infrastructure.UserSettings
@ -15,13 +15,24 @@ namespace Flow.Launcher.Infrastructure.UserSettings
if (Plugins.ContainsKey(metadata.ID)) if (Plugins.ContainsKey(metadata.ID))
{ {
var settings = Plugins[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) if (metadata.ID == "572be03c74c642baae319fc283e561a8" && metadata.ActionKeywords.Count != settings.ActionKeywords.Count)
{ {
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for index search // TODO: Remove. This is backwards compatibility for Explorer 1.8.0 release.
settings.ActionKeywords.Add(Query.GlobalPluginWildcardSign); // for path search // 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)) if (string.IsNullOrEmpty(settings.Version))

View file

@ -10,6 +10,7 @@
<system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String> <system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String> <system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String>
<system:String x:Key="plugin_explorer_globalActionKeywordInvalid">Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword</system:String> <system:String x:Key="plugin_explorer_globalActionKeywordInvalid">Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword</system:String>
<system:String x:Key="plugin_explorer_quickaccess_globalActionKeywordInvalid">Quick Access can not be set to the global action keyword when enabled. Please choose a specific action keyword</system:String>
<system:String x:Key="plugin_explorer_windowsSearchServiceNotRunning">The required service for Windows Index Search does not appear to be running</system:String> <system:String x:Key="plugin_explorer_windowsSearchServiceNotRunning">The required service for Windows Index Search does not appear to be running</system:String>
<system:String x:Key="plugin_explorer_windowsSearchServiceFix">To fix this, start the Windows Search service. Select here to remove this warning</system:String> <system:String x:Key="plugin_explorer_windowsSearchServiceFix">To fix this, start the Windows Search service. Select here to remove this warning</system:String>
<system:String x:Key="plugin_explorer_alternative">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</system:String> <system:String x:Key="plugin_explorer_alternative">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</system:String>
@ -27,6 +28,7 @@
<system:String x:Key="plugin_explorer_actionkeywordview_pathsearch">Path Search:</system:String> <system:String x:Key="plugin_explorer_actionkeywordview_pathsearch">Path Search:</system:String>
<system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String> <system:String x:Key="plugin_explorer_actionkeywordview_filecontentsearch">File Content Search:</system:String>
<system:String x:Key="plugin_explorer_actionkeywordview_indexsearch">Index Search:</system:String> <system:String x:Key="plugin_explorer_actionkeywordview_indexsearch">Index Search:</system:String>
<system:String x:Key="plugin_explorer_actionkeywordview_quickaccess">Quick Access:</system:String>
<system:String x:Key="plugin_explorer_actionkeyword_current">Current Action Keyword:</system:String> <system:String x:Key="plugin_explorer_actionkeyword_current">Current Action Keyword:</system:String>
<system:String x:Key="plugin_explorer_actionkeyword_done">Done</system:String> <system:String x:Key="plugin_explorer_actionkeyword_done">Done</system:String>
<system:String x:Key="plugin_explorer_actionkeyword_enabled">Enabled</system:String> <system:String x:Key="plugin_explorer_actionkeyword_enabled">Enabled</system:String>

View file

@ -42,15 +42,28 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{ {
var querySearch = query.Search; var querySearch = query.Search;
var results = new HashSet<Result>(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)) if (IsFileContentSearch(query.ActionKeyword))
return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false); return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false);
var result = new HashSet<Result>(PathEqualityComparator.Instance);
if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) || if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) ||
ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) 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) || if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword) ||
@ -58,11 +71,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
querySearch.Length > 0 && querySearch.Length > 0 &&
!querySearch.IsLocationPathString()) !querySearch.IsLocationPathString())
{ {
result.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token) results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token)
.ConfigureAwait(false)); .ConfigureAwait(false));
} }
return result.ToList(); return results.ToList();
} }
private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword) private bool ActionKeywordMatch(Query query, Settings.ActionKeyword allowedActionKeyword)
@ -75,10 +88,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
keyword == Settings.SearchActionKeyword, keyword == Settings.SearchActionKeyword,
Settings.ActionKeyword.PathSearchActionKeyword => Settings.PathSearchKeywordEnabled && Settings.ActionKeyword.PathSearchActionKeyword => Settings.PathSearchKeywordEnabled &&
keyword == Settings.PathSearchActionKeyword, keyword == Settings.PathSearchActionKeyword,
Settings.ActionKeyword.FileContentSearchActionKeyword => keyword == Settings.ActionKeyword.FileContentSearchActionKeyword => keyword == Settings.FileContentSearchActionKeyword,
Settings.FileContentSearchActionKeyword,
Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexOnlySearchKeywordEnabled && Settings.ActionKeyword.IndexSearchActionKeyword => Settings.IndexOnlySearchKeywordEnabled &&
keyword == Settings.IndexSearchActionKeyword keyword == Settings.IndexSearchActionKeyword,
Settings.ActionKeyword.QuickAccessActionKeyword => Settings.QuickAccessKeywordEnabled &&
keyword == Settings.QuickAccessActionKeyword
}; };
} }
@ -86,16 +100,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{ {
var querySearch = query.Search; 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<Result>(PathEqualityComparator.Instance); var results = new HashSet<Result>(PathEqualityComparator.Instance);
var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks);
results.UnionWith(quickaccessLinks);
var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch); var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);
if (isEnvironmentVariable) if (isEnvironmentVariable)

View file

@ -21,6 +21,7 @@ namespace Flow.Launcher.Plugin.Explorer
public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>(); public List<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new List<AccessLink>();
public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool SearchActionKeywordEnabled { get; set; } = true; public bool SearchActionKeywordEnabled { get; set; } = true;
public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword;
@ -33,6 +34,10 @@ namespace Flow.Launcher.Plugin.Explorer
public bool IndexOnlySearchKeywordEnabled { get; set; } public bool IndexOnlySearchKeywordEnabled { get; set; }
public string QuickAccessActionKeyword { get; set; } = Query.GlobalPluginWildcardSign;
public bool QuickAccessKeywordEnabled { get; set; }
public bool WarnWindowsSearchServiceOff { get; set; } = true; public bool WarnWindowsSearchServiceOff { get; set; } = true;
internal enum ActionKeyword internal enum ActionKeyword
@ -40,7 +45,8 @@ namespace Flow.Launcher.Plugin.Explorer
SearchActionKeyword, SearchActionKeyword,
PathSearchActionKeyword, PathSearchActionKeyword,
FileContentSearchActionKeyword, FileContentSearchActionKeyword,
IndexSearchActionKeyword IndexSearchActionKeyword,
QuickAccessActionKeyword
} }
internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch internal string GetActionKeyword(ActionKeyword actionKeyword) => actionKeyword switch
@ -48,7 +54,8 @@ namespace Flow.Launcher.Plugin.Explorer
ActionKeyword.SearchActionKeyword => SearchActionKeyword, ActionKeyword.SearchActionKeyword => SearchActionKeyword,
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword, ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword,
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword, ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword,
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword,
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword
}; };
internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch internal void SetActionKeyword(ActionKeyword actionKeyword, string keyword) => _ = actionKeyword switch
@ -57,6 +64,7 @@ namespace Flow.Launcher.Plugin.Explorer
ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword, ActionKeyword.PathSearchActionKeyword => PathSearchActionKeyword = keyword,
ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword, ActionKeyword.FileContentSearchActionKeyword => FileContentSearchActionKeyword = keyword,
ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword, ActionKeyword.IndexSearchActionKeyword => IndexSearchActionKeyword = keyword,
ActionKeyword.QuickAccessActionKeyword => QuickAccessActionKeyword = keyword,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
}; };
@ -65,6 +73,7 @@ namespace Flow.Launcher.Plugin.Explorer
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled, ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled,
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled, ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled,
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled, ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled,
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled,
_ => null _ => null
}; };
@ -73,6 +82,7 @@ namespace Flow.Launcher.Plugin.Explorer
ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable, ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable,
ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable, ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable,
ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled = enable, ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled = enable,
ActionKeyword.QuickAccessActionKeyword => QuickAccessKeywordEnabled = enable,
_ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property")
}; };
} }

View file

@ -63,11 +63,19 @@ namespace Flow.Launcher.Plugin.Explorer.Views
} }
if (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword if (ActionKeyword == Query.GlobalPluginWildcardSign
&& ActionKeyword == Query.GlobalPluginWildcardSign) && (CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword
|| CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.QuickAccessActionKeyword))
{ {
MessageBox.Show( switch (CurrentActionKeyword.KeywordProperty)
settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); {
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; return;
} }

View file

@ -42,7 +42,9 @@ namespace Flow.Launcher.Plugin.Explorer.Views
new(Settings.ActionKeyword.PathSearchActionKeyword, new(Settings.ActionKeyword.PathSearchActionKeyword,
viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_pathsearch")), viewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_pathsearch")),
new(Settings.ActionKeyword.IndexSearchActionKeyword, 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; lbxActionKeywords.ItemsSource = actionKeywordsListView;

View file

@ -4,12 +4,13 @@
"*", "*",
"doc:", "doc:",
"*", "*",
"*",
"*" "*"
], ],
"Name": "Explorer", "Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu", "Author": "Jeremy Wu",
"Version": "1.8.2", "Version": "1.9.0",
"Language": "csharp", "Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher", "Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",